query 2 tables at once
Posted: Mon Oct 09, 2006 9:51 pm
is there a way that i can do a query for 2 diffrent tables? i have register code and i need to have info go to 2 diffrent tables.
here is the code that i am using:
here is the code that i am using:
Code: Select all
<?PHP
if ($customer && $pass) {
$dbh=mysql_connect ("localhost", "homtek_dclamp", "password") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("homtek_homtek");
$result = mysql_query ("SELECT * FROM customer_login WHERE username = '".$customer."'");
if (mysql_num_rows($result) == 0) {
$result = mysql_query ("INSERT INTO customer_login (username, password, email, last_name, first_name) VALUES ('".$customer."', PASSWORD('".$pass."'), '".$email."', '".$last."', '".$first."')");
if ($result) {
$logged_in_customer = $customer;
session_register("logged_in_customer");
echo "The customer, ".$customer.", has been added.<BR><BR>";
echo "<A HREF='main.php'>Click here to proceed to the main page.</A><BR><BR>";
echo "You Will Be Redirected In 2 Seconds.<br>";
echo "<META HTTP-EQUIV='refresh' content='2;URL=http://www.homtek.net/admin/main.php'>";
echo "<A HREF='logout.php'>Click here to log out.</A>";
exit;
} else {
echo "<font color=red>Sorry, an error has occured, please contact technical support.</font>";
exit;
}
} else {
echo "<font color=red>Sorry, that username has been taken. Please try another.</font><BR>";
}
} else if ($customer || $pass) {
echo "<font color=red>Please fill in both fields.</font>";
}
?>
<FORM METHOD=POST ACTION="register_customer.php">
First Name:<br>
<INPUT NAME="first" TYPE=TEXT MAXLENGTH=10 SIZE=10><br><br>
Last Name:<br>
<INPUT NAME="last" TYPE=TEXT MAXLENGTH=10 SIZE=10><br><br>
Email Address:<br>
<INPUT NAME="email" TYPE=TEXT MAXLENGTH= SIZE=10><br><br>
Username:<br>
<INPUT NAME="customer" TYPE=TEXT MAXLENGTH=30 SIZE=10><BR><br>
Password:<br>
<INPUT NAME="pass" TYPE=TEXT MAXLENGTH=10 SIZE=10><br><br>
<BR>
<INPUT TYPE=SUBMIT VALUE="Register">
</FORM>