Advertisement
Guest User

Untitled

a guest
May 15th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.53 KB | None | 0 0
  1. <?php
  2.     //Access database connection.
  3.  
  4.     //Get customer's contact details from form. Sends information to customer table
  5.  
  6.     $customerFirstName = $_POST['customerFirstName'];
  7.     $customerLastName = $_POST['customerLastName'];
  8.     $customerAddress = $_POST['customerAddress'];
  9.     $customerPhonenumber = $_POST['customerPhonenumber'];
  10.     $customerEmailAddress = $_POST['customerEmailAddress'];
  11.  
  12.     //Get customer's desired login details from form. Sends information to user table      
  13.  
  14.     $userName = $_POST['userName'];
  15.     $userPassword = $_POST['userPassword'];
  16.     $userRepassword= $_POST['userRepassword'];
  17.     //Insert user data into user table.
  18.  
  19.     if (($userName == "") or ($customerFirstName == "") or ($customerLastName=="") or ($customerAddress == "") or ($customerPhonenumber=="") or ($customerEmailAddress=="") or ($userPassword==""))
  20.     {
  21.         echo"Fields missing, all fields must be completed";
  22.     }
  23.     elseif (!(strstr($customerEmailAddress, "@")) or !(strstr($customerEmailAddress, ".")))
  24.     {
  25.         echo"Invalid Email Address, must contain an '@' an a '.' ";
  26.     }
  27.     elseif ($userPassword != $userRepassword)
  28.     {
  29.         echo"Password Miss Match! pleaase re-enter";
  30.     }
  31.     else
  32.     {
  33.         require_once('dbconnection.php');
  34.     }
  35.     $addCustomer="INSERT INTO customer (customerFirstName, customerLastName, customerAddress, customerPhonenumber, customerEmailAddress)
  36.    VALUES ('$customerFirstName', '$customerLastName', '$customerAddress', '$customerPhonenumber', '$customerEmailAddress')";
  37.  
  38.     if(@mysql_query($addCustomer))
  39.     {
  40.         //If customer submits a user name.
  41.         if(isset($userName))
  42.         {
  43.             //Get user ID (customerID(FK))
  44.             $customerID=mysql_insert_id();
  45.             //Insert the user details.
  46.             $addUser="INSERT INTO user (userID, userName, userPassword, customerID)
  47.            VALUES (NULL, '$userName', '$userPassword', $customerID)";
  48.             $addResult=mysql_query($addUser);
  49.         }            
  50.         // Display first name and user name - Used to check if customer was added correctly.
  51.         echo "Cheers ".$customerFirstName." your user name is: ".$userName."<br>";  
  52.         echo("<p>Customer Added.</p>");
  53.     }    
  54.     else
  55.     {      
  56.         echo("<p>Error adding customer: </p>".mysql_error()."</p>");
  57.     }
  58.  
  59. ?>
  60. <html>
  61.     <body>
  62.         <a href="registration.html">Go back to registration form</a>
  63.         <br><br>
  64.         <a href="index.php">Go back to login form</a>  
  65.     </body>
  66. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement