Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(!isset($_POST['Capnumber']) || !isset($_POST['Captcha']) ) {
- echo "<!DOCTYPE html>";
- echo "<html>";
- echo "<head>";
- echo "<link rel='stylesheet' type='text/css' href='../css/style.css'>";
- echo "<link rel='icon' type='image/ico' href='../images/favicon.ico'>";
- echo "</head>";
- echo "<body>";
- echo "<div id='maindiv'>";
- echo "<div id='formdiv'>";
- echo "<p>CAPTCHA mismatch</p>";
- echo "<p>Please go <a href='../register'>back</a> to fix these errors.</p>";
- echo "</div>";
- echo "</div>";
- echo "</body>";
- echo "</html>";
- die();
- } else {
- switch ($_POST['Capnumber']) {
- case "cap1":
- $captchanum = "6";
- break;
- case "cap2":
- $captchanum = "5";
- break;
- case "cap3":
- $captchanum = "7";
- break;
- case "cap4":
- $captchanum = "4";
- break;
- case "cap5":
- $captchanum = "8";
- break;
- case "cap6":
- $captchanum = "9";
- break;
- }
- if($captchanum <> $_POST['Captcha']) {
- //CAPTCHA FAILED
- echo "<!DOCTYPE html>";
- echo "<html>";
- echo "<head>";
- echo "<link rel='stylesheet' type='text/css' href='../css/style.css'>";
- echo "<link rel='icon' type='image/ico' href='../images/favicon.ico'>";
- echo "</head>";
- echo "<body>";
- echo "<div id='maindiv'>";
- echo "<div id='formdiv'>";
- echo "<p>CAPTCHA mismatch</p>";
- echo "<p>Please go <a href='../register'>back</a> to fix these errors.</p>";
- echo "</div>";
- echo "</div>";
- echo "</body>";
- echo "</html>";
- die();
- }
- }
- if(isset($_POST['Email'])){
- //error code
- function died($error){
- echo "<!DOCTYPE html>";
- echo "<html>";
- echo "<head>";
- echo "<link rel='stylesheet' type='text/css' href='../css/style.css'>";
- echo "<link rel='icon' type='image/ico' href='../images/favicon.ico'>";
- echo "</head>";
- echo "<body>";
- echo "<div id='maindiv'>";
- echo "<div id='formdiv'>";
- echo "<p>We are sorry, but there were error(s) found with the form you submitted.</p>";
- echo "<p>These errors appear below.</p><br/><br/>";
- echo "<p>" . $error . "</p><br/><br/>";
- echo "<p>Please go <a href='../register'>back</a> to fix these errors.</p><br/>";
- echo "</div>";
- echo "</div>";
- echo "</body>";
- echo "</html>";
- die();
- }
- function nooptin($error){
- echo "<!DOCTYPE html>";
- echo "<html>";
- echo "<head>";
- echo "<link rel='stylesheet' type='text/css' href='../css/style.css'>";
- echo "<link rel='icon' type='image/ico' href='../images/favicon.ico'>";
- echo "</head>";
- echo "<body>";
- echo "<div id='maindiv'>";
- echo "<div id='formdiv'>";
- echo "<p>You must opt in to receive communication from TEST Pharmaceuticals.<br/><a href='../register'>Back</a></p>";
- echo "</div>";
- echo "</div>";
- echo "</body>";
- echo "</html>";
- die();
- }
- // validation
- if(!isset($_POST['Optin'])) {
- nooptin('You must opt in to receive communication from TEST Pharmaceuticals.');
- }
- if(!isset($_POST['Name']) ||
- !isset($_POST['Email'])) {
- died('We are sorry but there appears to be a problem with the form you submitted.');
- }
- $name = $_POST['Name'];
- $email = $_POST['Email'];
- $optin = $_POST['Optin'];
- $error_message = "";
- $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
- if(!preg_match($email_exp, $email)){
- $error_message .='The email address you entered does not appear to be valid.<br/>';
- }
- $string_exp = "/^[[A-Za-z' - ]+$/";
- if (!preg_match($string_exp, $name)){
- $error_message .= 'The name you entered does not appear to be valid.<br/>';
- }
- if(strlen($error_message) > 0 ){
- died($error_message);
- }
- function clean_string($string){
- $bad = array("content-type", "bcc:", "to:", "cc:", "href");
- return str_replace($bad, "", $string);
- }
- //DATABASE SECTION
- session_start();
- $user_name = clean_string($name);
- $user_email = clean_string($email);
- if ($user_name == '' || $user_email == '') {
- echo "<!DOCTYPE html>";
- echo "<html>";
- echo "<head>";
- echo "<link rel='stylesheet' type='text/css' href='../css/style.css'>";
- echo "<link rel='icon' type='image/ico' href='../images/favicon.ico'>";
- echo "</head>";
- echo "<body>";
- echo "<div id='maindiv'>";
- echo "<div id='formdiv'>";
- echo "<p>Something went wrong</p>";
- echo "</div>";
- echo "</div>";
- echo "</body>";
- echo "</html>";
- } else {
- $_SESSION['user_name2'] = $user_name;
- $_SESSION['email_name2'] = $user_email;
- include '../backend/reg.php';
- }
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <link rel="stylesheet" type="text/css" href="../css/style.css">
- <link rel="icon" type="image/ico" href="../images/favicon.ico">
- </head>
- <body>
- <div id="maindiv">
- <div id="formdiv">
- <p id="thankstext">Thank you for signing up! You're all set to recieve the latest news and information from TEST Pharmaceuticals.</p>
- </div>
- </div>
- </body>
- </html>
- <?php
- }
- ?>
Add Comment
Please, Sign In to add comment