Greeting. ( thanks in advance for any replies)
Here is what I am trying to do ...hope it makes sense.. i have a form that gets username and password from a member..I want to retrieve their member_id from the members table so I can add this member_id to a new table..
<?php
//validate username and password
if (empty($user_name) || empty($password))
// user never included username and password
{
echo "You have not included a username and password ..please try again ";
include ("dealer_sign_up.php");//spit the form back at them
exit;
}
else
{
//connect to database
$link = mysql_pconnect ("localhost","","");
if (!$link)
die ("Couldn't Connect to MySQL");
//print "you connected to the server<br> ";
//select database to use
$db = "tester";
mysql_select_db("$db") or die ("Couldn't Open $database<br> :".mysql_error() );
//print ("you connected to \"$db\" ..Give yourself the high five<br>");
//check to see if username and password match ....
$query = "select count(*) from members where
user_name = '$user_name' and
password = '$password'";
$result=mysql_query ($query);
if (!$result)
{
echo 'Cannot run query.';
exit;
}
$count =mysql_result ($result,0,0);
if ($count >0 )
{
// yippy the dude put in the right password and username
//now lets see if any thing else is empty
if (empty($company)|| empty($con_first_name)||empty($con_last_name)|| empty($state)||empty($city)|| empty($webpage))
// user never filled in all fields
{
echo "You have not filled in all the required fields ..please try again ";
include ("dealer_sign_up.php");//spit the form back at them
exit;
}
// things are cool lets insert the values into the database
//at this point i need to get the member_id from members table so I can insert it into dealers
//table and connect them
// at this point I need the member_id
//$username = "brutus";// this is an example of the user input
//$password = "963"//this is an example of the user input
$query = "select member_id from tester.memberswhere user_name ='brutus' and password = '963'";
$result = mysql_query($query);
if ($result)
echo mysql_affected_rows()." member id selected from the database.";
echo "$member_id";
if (!$result)
echo "Couldn't select member_id " .mysql_error();
exit;
$query ="INSERT INTO dealers (member_id,company,con_first_name,con_last_name,state,city,webpage)
VALUES ('$member_id','$company','$con_first_name','$con_last_name','$state','$city','$webpage')";
$result = mysql_query($query);
if ($result)
echo mysql_affected_rows()."dealers inserted into database.";
if (!$result)
echo "Couldnt insert values into database " .mysql_error();
exit;
}
else
{
echo "<center><B>The username and password combinations are not correct ..please try again</b></center><br><br>";
echo "<center><B>To have your password mailed to you click here !</b></center> ";
include ("dealer_sign_up.php");//spit the form back at them
exit;
}
}
?>
</body>
</html>
// hope this explains things ...
I appreciate your help and consideration
Thanks so much
phpmysqlrules