script programming
script programming
Software required
Xampp
Program
1.Type the program in notepad and save it in C:\xampp\htdocs as paul1.php(all files selected)
<?php
$s="Welcome to php";
echo "the given string is".$s."<br>";
$length=strlen($s);
echo "the length of the string is".$length."<br>";
$upper=strtoupper($s);
echo "the upper case of the string is".$upper."<br>";
$lower=strtolower($s);
echo "the lower case of the string is".$lower."<br>";
$reversed=strrev($s);
echo "the reversed string is".$reversed."<br>";
$arr=str_split($s,3);
echo "Array after splitting:<br>";
print_r($arr);
echo "<br>";
$arr=array(33,11,44,16,25,89,92);
echo "The elements in the array are:<br>";
print_r($arr);
echo "<br>";
$count1=count($arr);
echo "Count of elements in the array:".$count1."<br>";
$cur=current($arr);
echo "Current element:".$cur."<br>";
$last=end($arr);
echo "Last element:".$last."<br>";
$reverse=array_reverse($arr);
echo "Reversed array:<br>";
print_r($reverse);
echo "<br>";
sort($arr);
echo "Sorted array:";
print_r($arr);
?>
Result:
Aim
Software required
Xampp
Program
1.Type the program in notepad and save it in C:\xampp\htdocs as the following names in the
heading of programs
Sandoosh.html
<!doctype html>
<html>
<head>
<title> Biodata Form</title>
</head>
<body>
<h2 align="center"; style="font-size:30px"> Biodata Form</h2>
<form action="YARU.php" method="POST">
<label for="name">Name:</label>
<input type="text" id="name" name="name" required><br><br>
<label for="age">Age:</label>
<input type="number" id="age" name="age" required min="0" max="45"><br><br>
<h3>JGLC</h3>
<label for="s1">subject1:</label>
<input type="number" id="s1" name="marks[]" required min="0" max="99"><br><br>
<label for="s2">subject2:</label>
<input type="number" id="s2" name="marks[]" required min="0" max="99"><br><br>
<label for="s3">subject3:</label>
<input type="number" id="s3" name="marks[]" required min="0" max="99"><br><br>
<label for="s4">subject4:</label>
<input type="number" id="s4" name="marks[]" required min="0" max="99"><br><br>
<label for="s5">subject5:</label>
<input type="number" id="s5" name="marks[]" required min="0" max="99"><br><br>
<input type="submit" value="submit">
</form>
<h2 align="center"; style="font-size:00px">giri deepa</h2>
</body>
</html>
YARU.php
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name=$_POST["name"];
$age=$_POST["age"];
$marks=$_POST["marks"];
$total=array_sum($marks);
$average=$total/count($marks);
echo "<h2>jaga das biodata form</h2>";
echo "Name:" .$name . "<br>";
echo "Age:" . $age . "<br>";
echo "Total Marks:" . $total . "<br>";
echo "Average Marks:" . number_format($average,2) . "<br>";
}
else
{
echo "Invalid request method";
}
?>
Result:
Aim
Software required
Xampp
Mysql
Program
1.Type the program in notepad and save it in C:\xampp\htdocs as the following names in the
heading of programs
Search.html
<html>
<body>
</body>
</html>
phpSearch.php
<?php
$search = $_POST['search'];
$servername = "localhost";
$username = "root";
$password = "";
$db = "college";
if ($conn->connect_error){
die("Connection failed: ". $conn->connect_error);
}
$sql = "select * from student where regno like '%$search%'";
$result = $conn->query($sql);
$conn->close();
?>
Result:
Ex5
Aim
Program
<!doctype html>
<html lang="en">
<head>
<meta name="viewport"content="width=device-width,initial-scale=1.0">
<title>Disable Right Click</title>
<script src="jquery-1.7.1.js"></script>
<script>
$(document).ready(function()
{
$(document).on("contextmenu",function(e)
{
e.preventDefault();
alert("right-click is disabled on this webpage.");
});
});
</script>
</head>
<body>
<h1>right click disabled example</h1>
<p>try right clicking anywhere on this page!</p>
</body>
</html>
Ex7
Aim
Program
server.js
app.use(express.static('public'));
// handle success
return res.status(200).json({ message: 'File uploaded successfully!' });
} catch (error) {
// handle error
return res.status(400).json({ message: error.message });
}
});
app.listen(port, () => {
console.log(`Example app listening on port ${port}`)
})
package.json
{
"name": "nodejs-multer",
"version": "1.0.0",
"description": "",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js"
},
"author": "",
"license": "ISC"
}
index.html
Aim
Program
var mailOptions = {
from: '[email protected]',
to: '[email protected]',
subject: 'Sending Email using Node.js',
text: 'That was easy!'
};
Aim
Program
login.php
<html>
<form method="post" action="login_check.php">
<input type="text" name="user" value="username" placeholder="Username" style="font-
size:24px" required>
<input type="text" name="pass" value="password" placeholder="Password" style="font-
size:24px" required>
<button type="submit" name="Login" value="Login">LogIn </button>
</form>
</html>
connection.php
<?php
$host = "localhost";
$user = "root";
$password = '';
$db_name = "college";
login_check.php
<?php
session_start();
if ($_SERVER["REQUEST_METHOD"] == "POST") {
include('connection.php');
$username = $_POST['user'];
$password = $_POST['pass'];
if($count == 1){
//echo "<h1><center> Login successful </center></h1>";
//$row = mysqli_fetch_array($result, MYSQLI_ASSOC);
//$username=$row['username' ];
$_SESSION['username']=$username;
header("Location: wel.php");
exit;
}
else{
//echo "<h1> Login failed. Invalid username or password.</h1>";
session_destroy();
header("Location: login.php");
exit;
}
}
?>
wel.php
<?php
session_start();
//$username=$_SESSION['username'];
//echo $username;
?>
<ul>
<li><a href='#'>Welcome <?php echo $_SESSION['username']; ?>