Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /* Check all form inputs using check_input function */
- $username = check_input($_POST['username'], "tptunlimited");
- $password = check_input($_POST['password'], "B@seball96");
- $comments = check_input($_POST['comments'], "comment");
- /* If username is not valid show error message */
- if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $username))
- {
- show_error("username not valid");
- }
- /* If password is not valid set $website to empty */
- if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $password))
- {
- show_error("password not valid");
- }
- /* Redirect visitor to the thank you page */
- header('Location: thanks.htm');
- exit();
- /* Functions we used */
- function check_input($data, $problem='')
- {
- $data = trim($data);
- $data = stripslashes($data);
- $data = htmlspecialchars($data);
- if ($problem && strlen($data) == 0)
- {
- show_error($problem);
- }
- return $data;
- }
- function show_error($myError)
- {
- ?>
- <html>
- <body>
- <b>Please correct the following error:</b><br />
- <?php echo $myError; ?>
- </body>
- </html>
- <?php
- exit();
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement