Advertisement
Guest User

Untitled

a guest
May 14th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.30 KB | None | 0 0
  1.  <?php
  2. session_start();
  3.  
  4.         //Includes.
  5.  
  6.         include("dbconnection.php");  
  7.         //Access database connection.
  8.  
  9.           //Get customer's contact details from form. Sends information to customer table
  10.    
  11.                    $customerFirstName = $_POST['customerFirstName'];
  12.  
  13.                    $customerLastName = $_POST['customerLastName'];
  14.  
  15.                    $customerAddress = $_POST['customerAddress'];
  16.  
  17.                    $customerPhonenumber = $_POST['customerPhonenumber'];
  18.  
  19.                    $customerEmailAddress = $_POST['customerEmailAddress'];
  20.  
  21.            //Get customer's desired login details from form. Sends information to user table      
  22.  
  23.                    $userName = $_POST['userName'];
  24.  
  25.                    $userPassword = $_POST['userPassword'];
  26.  
  27.           //Insert user data into user table.
  28.  
  29.           $addCustomer="INSERT INTO customer (customerFirstName, customerLastName, customerAddress, customerPhonenumber, customerEmailAddress)
  30.  
  31.                     VALUES ('$customerFirstName', '$customerLastName', '$customerAddress', '$customerPhonenumber', '$customerEmailAddress')";
  32.  
  33.            
  34.  
  35.           if(@mysql_query($addCustomer))
  36.  
  37.           {
  38.  
  39.               //If customer submits a user name.
  40.  
  41.               if(isset($userName))
  42.  
  43.               {
  44.  
  45.                   //Get user ID (customerID(FK))
  46.  
  47.                   $customerID=mysql_insert_id();
  48.  
  49.                  
  50.  
  51.                  //Insert the user details.
  52.  
  53.                   $addUser="INSERT INTO user (userID, userName, userPassword, customerID)
  54.  
  55.                           VALUES (NULL, '$userName', '$userPassword', $customerID)";
  56.  
  57.                   $addResult=mysql_query($addUser);
  58.  
  59.               }
  60.  
  61.              
  62.  
  63.          
  64.  
  65.              // Display first name and user name - Used to check if customer was added correctly.
  66.  
  67.               echo "Cheers ".$customerFirstName." your user name is: ".$userName."<br>";  
  68.  
  69.               echo("<p>Customer Added.</p>");
  70.  
  71.           }    
  72.  
  73.           else
  74.  
  75.           {
  76.  
  77.               echo("<p>Error adding customer: </p>".mysql_error()."</p>");
  78.  
  79.           }
  80. ?>
  81.         <html>
  82.  
  83.           <body>
  84.  
  85.               <a href="index.html">GO BACK</a>
  86.  
  87.           </body>
  88.  
  89.       </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement