Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- //Includes.
- include("dbconnection.php");
- //Access database connection.
- //Get customer's contact details from form. Sends information to customer table
- $customerFirstName = $_POST['customerFirstName'];
- $customerLastName = $_POST['customerLastName'];
- $customerAddress = $_POST['customerAddress'];
- $customerPhonenumber = $_POST['customerPhonenumber'];
- $customerEmailAddress = $_POST['customerEmailAddress'];
- //Get customer's desired login details from form. Sends information to user table
- $userName = $_POST['userName'];
- $userPassword = $_POST['userPassword'];
- //Insert user data into user table.
- $addCustomer="INSERT INTO customer (customerFirstName, customerLastName, customerAddress, customerPhonenumber, customerEmailAddress)
- VALUES ('$customerFirstName', '$customerLastName', '$customerAddress', '$customerPhonenumber', '$customerEmailAddress')";
- if(@mysql_query($addCustomer))
- {
- //If customer submits a user name.
- if(isset($userName))
- {
- //Get user ID (customerID(FK))
- $customerID=mysql_insert_id();
- //Insert the user details.
- $addUser="INSERT INTO user (userID, userName, userPassword, customerID)
- VALUES (NULL, '$userName', '$userPassword', $customerID)";
- $addResult=mysql_query($addUser);
- }
- // Display first name and user name - Used to check if customer was added correctly.
- echo "Cheers ".$customerFirstName." your user name is: ".$userName."<br>";
- echo("<p>Customer Added.</p>");
- }
- else
- {
- echo("<p>Error adding customer: </p>".mysql_error()."</p>");
- }
- ?>
- <html>
- <body>
- <a href="index.html">GO BACK</a>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement