What is the PHP form | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

What is the PHP form

DOCTYPE HTML> <html> <head> </head> <body> <?php //define variables and set to empty values $name = $email = $gender = $comment = $website =""; if($_SERVER["REQUEST_METHOD"])=="POST") { $name=test_input($_post["name"]); $email=test_input($_post["email"]); $website=test_input($_post["website"]); $comment=test_input($_post["comment"]); $gender=test_input($_post["gender"]); } function test_input($data) { $data=trim($data); $data=stripslashes($data); $data=htmlspecialchars($data); return $data; ?> <h2> PHP form validation example</h2> <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?> Name:<input type="text" name="name"> <br><br> E-mail: <input type="text" name="email"> <br><br> website: <input type="text" name="website"> <br><br> comment: <textarea name="comment" row="5" cols="40"></textarea> <br><br> Gender: <input type="radio" name="gender" value="female">Female <input type="radio" name="gender" value="male">Male <input type="radio" name="gender" value="other">Other <br><br> <inpu

21st Jul 2018, 2:55 PM
asim lodi
asim lodi - avatar
2 Respostas
+ 4
That's same as leaving the action empty.
21st Jul 2018, 3:05 PM
Toni Isotalo
Toni Isotalo - avatar
+ 2
This form is getting the data of the inputs that are sent by method post(protected) to the self page, it means that you are not loading another php page to validate the data, because you are doing it in the same page.
21st Jul 2018, 3:01 PM
Guillem Padilla
Guillem Padilla - avatar