Advertisement
Guest User

Untitled

a guest
May 14th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.69 KB | None | 0 0
  1. <?php
  2.     session_start();
  3.     //Includes.
  4.     include("../functions/dbconnection.php");  //Access database connection.
  5.      
  6.     //Get client's contact details from form.    
  7.              $firstName = $_POST['firstName'];
  8.              $lastName = $_POST['lastName'];
  9.              $address = $_POST['address'];
  10.              $phoneNumber = $_POST['phoneNumber'];
  11.              $emailAddress = $_POST['emailAddress'];
  12.              
  13.      //Get client's desired login details from form.        
  14.              $userName = $_POST['userName'];
  15.              $password = $_POST['password'];
  16.  
  17.     //Insert user data into user table.
  18.     $addClient="INSERT INTO client (firstName, lastName, address, phoneNumber, emailAddress)
  19.                VALUES ('$firstName', '$lastName', '$address', '$phoneNumber', '$emailAddress')";
  20.      
  21.     if(@mysql_query($addClient))
  22.     {
  23.         //If client submits a user name.
  24.         if(isset($userName))
  25.         {
  26.             //Get user ID (clientID(FK))
  27.             $clientID=mysql_insert_id();
  28.            
  29.             //Insert the user details.
  30.             $addUser="INSERT INTO users (userID, userName, password, clientID)
  31.                      VALUES (NULL, '$userName', '$password', $clientID)";
  32.             $addResult=mysql_query($addUser);
  33.         }
  34.        
  35.    
  36.        // Display first name and user name - Used to check if client was added correctly.
  37.         echo "Thank you ".$firstName." your user name is: ".$userName."<br>";  
  38.         echo("<p>Client Added.</p>");
  39.     }    
  40.     else
  41.     {
  42.         echo("<p>Error adding client: </p>".mysql_error()."</p>");
  43.     }
  44. ?>
  45. <html>
  46.     <body>
  47.         <a href="index.php">Login</a>
  48.     </body>
  49. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement