GIF89a; %PDF-1.5 %���� ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY
Server IP : 134.29.175.74 / Your IP : 216.73.216.160 Web Server : nginx/1.10.2 System : Windows NT CST-WEBSERVER 10.0 build 19045 (Windows 10) i586 User : Administrator ( 0) PHP Version : 7.1.0 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/nginx/html/JimMartinson/CST1146/Resources/Examples/Week/10/ |
Upload File : |
<!DOCTYPE HTML> <html> <head> <style> .error {color: #FF0000;} </style> </head> <body> <?php function test_input($data) { $data = trim($data); #$data = stripslashes($data); // Do not do this if you do not addslashes() before sending. $data = htmlspecialchars($data); return $data; } $error = NULL; // define variables and set to empty values $nameErr = $emailErr = $genderErr = $websiteErr = ""; $name = $email = $gender = $comment = $website = ""; if ($_SERVER["REQUEST_METHOD"] == "GET") { $error = false; if (empty($_GET["name"])) { $nameErr = "Name is required"; $error = true; } else { $name = test_input($_GET["name"]); } if (empty($_GET["email"])) { $emailErr = "Email is required"; $error = true; } else { $email = test_input($_GET["email"]); } if (empty($_GET["website"])) { $website = ""; } else { $website = test_input($_GET["website"]); } if (empty($_GET["comment"])) { $comment = ""; } else { $comment = test_input($_GET["comment"]); } if (empty($_GET["gender"])) { $genderErr = "Gender is required"; $error = true; } else { $gender = test_input($_GET["gender"]); } } if ($error === false) { echo "<h2>Your Input:</h2>"; echo $name; echo "<br>"; echo $email; echo "<br>"; echo $website; echo "<br>"; echo $comment; echo "<br>"; echo $gender; } else { ?> <form method="GET" action="<?=htmlspecialchars($_SERVER["PHP_SELF"])?>"> Name: <input type="text" name="name" value="<?php echo $name;?>"> <span class="error">* <?php echo $nameErr;?></span> <br><br> E-mail: <input type="text" name="email" value="<?php echo $email;?>"> <span class="error">* <?php echo $emailErr;?></span> <br><br> Website: <input type="text" name="website" value="<?php echo $website;?>"> <span class="error"><?php echo $websiteErr;?></span> <br><br> Comment: <textarea name="comment" rows="5" cols="40"><?php echo $comment;?></textarea> <br><br> Gender: <input type="radio" name="gender" value="female"<?php if ($gender=="female") echo " checked";?>>Female <input type="radio" name="gender" value="male"<?php if ($gender=="male") echo " checked";?>>Male <input type="radio" name="gender" value="other"<?php if ($gender=="other") echo " checked";?>>Other <span class="error">* <?php echo $genderErr;?></span> <br><br> <input type="submit" name="submit" value="Submit"> </form> <?php } ?> </body> </html>