Advertisement
Guest User

Untitled

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