gibigbig Posted June 28, 2007 Share Posted June 28, 2007 ok i have made a script that takes information from a form and adds it to a database. it then displays the data the that was placed into the form with the $_POST[''] function. however, i want it to read off the data that was placed into the form, add it to a database, then in another file ("process.php"), the data will be read STRAIGHT from the database and NOT from the POST function. can anyone help me, this is my code: <?php $con = mysql_connect("localhost","USERNAME","PASSWORD"); if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("DATABASE", $con);$sql="INSERT INTO registration (nickname, password, email) VALUES ('$_POST[nickname]','$_POST[password]','$_POST[email]')";if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } $nickname = "$_POST[nickname]"; $password ="$_POST[password]"; $email = "$_POST[email]"; echo $nickname; mysql_close($con) ?><p>Welcome to narutoking </p> <table width="611" border="1" cellspacing="0" cellpadding="0"> <tr> <td>username</td> <td>password</td> <td>email</td> </tr> <tr> <td><?php echo $username ?></td> <td><?php echo $password ?></td> <td><?php echo $email ?></td> </tr> </table> <p> </p> Quote Link to comment Share on other sites More sharing options...
kael.shipman Posted June 28, 2007 Share Posted June 28, 2007 First of all, clean up your code, man! Then put the resulting registration id into a session variable: <?php $con = mysql_connect("localhost","USERNAME","PASSWORD"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("DATABASE", $con); $sql="INSERT INTO registration (nickname, password, email) VALUES ('$_POST[nickname]','$_POST[password]','$_POST[email]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } else { $_SESSION['regID'] = mysql_insert_id($con); } ?> Then just query from the other page: <?php $info = @mysql_fetch_row(@mysql_query("select nickname, password, email from registration where regID = ".$_SESSION['regID'],$con)); $nickname = $info[0]; $password = $info[1]; $email = $info[2]; ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.