Untitled
unknown
plain_text
2 days ago
1.4 kB
6
Indexable
Never
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Form Handling</title> </head> <body> <form method="POST" action="process_form.php"> <div> <label for="name">Name: </label> <input type="text" id="name" name="fullName"> </div> <div> <label for="email">Email: </label> <input type="email" id="email" name="emailAddress"> </div> <button type="submit">Submit</button> <!-- <input type="submit" value="Submit"> --> </form> </body> </html> <!-- process_form.php --> <?php if(isset($_GET['fullName']) && isset( $_GET['emailAddress'])){ $name = htmlspecialchars($_GET['fullName']); //fullName points to the field name echo $name; $email = $_GET['emailAddress']; //emailAddress points to the field email echo "<br>$email"; } if(isset($_POST['fullName']) && isset( $_POST['emailAddress'])){ $name = htmlspecialchars($_POST['fullName']); //htmlspecialcharacters sanitizes form inputs to avoid xss attacks $email = $_POST['emailAddress']; echo "Name is $name<br>Email is $email"; echo "<br>". html_entity_decode($name); //Convert HTML entities to their corresponding characters }
Leave a Comment