Hi all,
with the script below can any one see why the value of $user is always
something like
MjpwZXRlcmg6YWNhYjQ4M2IzMThjMmNiMzk2NDE3NmEyODFkNzBiZTk6MTA6OjA6MDowOjE6OjQw
OTY=
instead of the value inserted in the form, everything else works as it's
suposed to with in the script/form.
<?
if ($submit)
{
$aDBlink = @mysql_connect( "localhost", "root");
if ( !empty( $aDBlink) )
{
if ( mysql_select_db( "test", $aDBlink ) == True )
{
// insert name into table 3
$aSQL = "INSERT INTO table3 ( name ) VALUES ( '$name' )";
$aQResult = mysql_query( $aSQL, $aDBlink );
if ( $aQResult == True)
{
echo mysql_insert_id();
echo ("<BR>");
// insert insertuser_name into table2
$aSQL1 = "INSERT INTO table2 ( user_name, nameid) VALUES ( '$user',
LAST_INSERT_ID() )";
$aQResult1 = mysql_query( $aSQL1 );
if ( $aQResult1 == True)
{
// show resulting id number from table2
echo mysql_insert_id();
echo ("<BR>");
//add username id to table1
$aSQL2 = "INSERT INTO table1 (userid) VALUES ( LAST_INSERT_ID() ) ";
$aQResult2 = mysql_query( $aSQL2 );
if ( $aQResult2 == True )
{
// show table1 id to check all is ok
echo mysql_insert_id();
echo ("<BR>");
// show inputted data in full from the 3 tables
$sql = "SELECT id, user_name, name FROM table1, table2, table3 WHERE ('id =
table1.id') AND ('table1.userid = table2.id') AND ('table2.nameid =
table3.id')";
$result=mysql_query( $sql );
echo ("your id is $id");
echo ("<BR>");
echo ("your name is $name");
echo ("<BR>");
echo ("your user name is<br> $user");
}
else {
// show sql error for table1
echo mysql_error();
}
}
else {
// show sql error for table2
echo mysql_error();
}
}
else
{
show sql error for table3
echo mysql_error();
}
}
else
{
// custom error message for not being able to select the db
print("unable to select DB<br>");
}
}
else
{
// error message for not connecting to mysql
print("unable to connect to DB<br>");
}
}
?>
<html>
<head>
<title>Untitled</title>
</head>
<body>
<form name="foo" action="test.php" method="post">
Name: <input type="text" name="name"><Br>
User Name: <input type="text" name="user"><BR>
<input type="submit" name="submit" value="submit">
</form>
</body>
</html>
Cheers
Peter
"the only dumb question is the one that wasn't asked"
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php