Jump to content

ElricLives

New Members
  • Posts

    2
  • Joined

  • Last visited

ElricLives's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I forgot to check if it worked (which it did). Thanks a lot for the help
  2. Hi. I'm trying to add a Customer registration page, where the customers name and address are stored in separate tables, and I'm having issues. This is the insert_ac.php page, where all the error messages direct me to line 21 and 23 (Undefined index: HouseNumberName and Undefined index: CityTown respectively) Just in case it's not too obvious, PHP isn't my strong suit. <?php $host=''; // Host name $username=''; // Mysql username $password=''; // Mysql password $db_name='comp 5130'; // Database name $tbl_client='client'; // 1st Table name $tbl_location= 'location'; //2nd table name // Connect to server and select database. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // Get values from form $cid=['ID']; $lid=['ID']; $firstname=$_POST['FirstName']; $lastname=$_POST['LastName']; $email=$_POST['EmailAddress']; $cnumber=$_POST['ContactNumber']; $house=$_POST['HouseNumberName']; $street=$_POST['StreetName']; $city=$_POST['CityTown']; $postcode=$_POST['PostCode']; // Insert data into client $sql ="INSERT INTO $tbl_client(ID, FirstName, LastName, EmailAddress, ContactNumber) VALUES('', '{$firstname}', '{$lastname}', '{$email}', '{$cnumber}')"; echo $sql; $result = mysql_query($sql); if (!$result) { die('Invalid query: ' . mysql_error());} // Insert Data Into location $sql2 ="Insert Into $tbl_location(ID, HouseNumberName, StreetName, CityTown, PostCode) Values ('', '$house', '$street', '$city', '$postcode')"; echo $sql2; $result2 = mysql_query($sql2); if (!$result2) { die('Invalid query: ' . mysql_error());} // if successfully insert data into client, displays message if($result) { echo "sucessful customer add"; echo "<BR>"; echo "<a href= 'insert.php'>Back To Main Page</a>"; } else { echo "That can't be good, Customer Error..."; } // if successfully insert data into location, displays message if($result2) { echo "sucessful address"; echo "<BR>"; echo "<a href= 'insert.php'>Back To Main Page</a>"; } else { echo "That can't be good, Address Fail..."; } ?> <?php // close connection mysql_close(); ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.