1214phps
1214phps
Html
<!DOCTYPE html>
<html>
<head>
</head><body> <form action="t10.php" method="post">
Name: <input type ="text" name ="name">
Add: <input type ="text" name="address">
<input type ="submit"> </form>
</body></html> Php
code:
<html>
<body>
Welcome :<?php echo $_POST['name'];?>
Your Address :<?php echo $_POST['address'];?>
</body>
</html>
HTML Code:
<!DOCTYPE html>
<html>
<head>
</head>
<body> <form action="t10.php" method="get">
Name: <input type ="text" name ="name">
Add: <input type ="text" name="address">
<input type ="submit">
</form>
</body>
</html>
Php code:<html>
<body>
Welcome :<?php echo $_POST['name'];?>!
Your Address :<?php echo $_POST['address'];?>
</body>
</html>
Html Code:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<form action ="t11.php"method="get">
<label>Moblie Number :</label>
<input type="tex" name="moblieno" id="moblieno">
<input type="submit" value="submit">
</form>
</body>
</html>
Php code: <?php
if(isset($_GET['moblieno']))
{
echo"<p> Moblie Number :".$_GET['moblieno']."</p>"; }?>
Practical no 14
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$to = filter_var($_POST["to"], FILTER_SANITIZE_EMAIL);
$from = filter_var($_POST["from"], FILTER_SANITIZE_EMAIL);
$subject = htmlspecialchars(strip_tags($_POST["subject"]));
$message = htmlspecialchars(strip_tags($_POST["message"]));
// Validate email addresses
if (!filter_var($to, FILTER_VALIDATE_EMAIL) || !filter_var($from,
FILTER_VALIDATE_EMAIL)) {
echo "Invalid email address.";
exit;}
// Prevent email header injection
if (preg_match("/(\r\n|\n|\r)/", $to) || preg_match("/(\r\n|\n|\r)/", $from)) {
echo "Invalid input detected.";
exit;}
$headers = "From: " . $from . "\r\n" .
"Reply-To: " . $from . "\r\n" .
"X-Mailer: PHP/" . phpversion();
if ("mail($to, $subject, $message, $headers)") {
echo "Email sent successfully.";
} else {
echo "Email failed to send.";
}}?>
<form method="post">
<label for="to">To:</label><br>
<input type="email" name="to" id="to" required><br><br>
<label for="from">From:</label><br>
<input type="email" name="from" id="from" required><br><br>
<label for="subject">Subject:</label><br>
<input type="text" name="subject" id="subject" required><br><br>
<label for="message">Message:</label><br>
<textarea name="message" id="message" required></textarea><br><br>
<input type="submit" value="Send">
</form>
Output::