Form with an insert and select statements.

From: Date: Mon, 14 Feb 2000 00:15:48 +0000
Subject: Form with an insert and select statements.
Groups: php.version4 
Request: Send a blank email to php-version4+get-10230@lists.php.net to get a copy of this message
Hi Working on a submit form that needs to be able to insert values into a table and then immediately pull out the id No that would be associated with this insertion. Id No is to be printed on screen Id No in this case=ref No. For e.g. part of the php script: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>Untitled</title> </head> <body> <? /* this script will handle the variables passed from the moreinfo.html file */ PRINT "<CENTER>"; PRINT "Hello, $name."; PRINT "<BR><BR>"; PRINT "Thank you for your interest.<BR><BR>"; PRINT "We will send information to $email, and have noted that you like $preference."; PRINT "</CENTER>"; ?> <? mail("$email", "Your request for information", "$namenThank you for your interest!nWe sell fresh corn daily over the Internet!Place your order at http://www.buycorn.com,and receive a free package of $preference!"); mail("ry@sve.com","Visitor request for info.","$name requested for information.nThe email address is $email. n The visitor prefers $preference."); ?> <?/* this script will handle the variables passed from the moreinfo.html file *//* declare some relevant variables */ $hostname = "localhost"; $username = " "; $password = " "; $dbName = " "; /* MySQL table created to store the data */ $userstable = "information"; /* the site administrator's email address */ $adminaddress = "ry@sve.com"; /* make connection to database */ MYSQL_CONNECT($hostname,$username,$password) OR DIE("Unable to connect to database"); @mysql_select_db("$dbName") or die("Unable to select database"); PRINT "<CENTER>";PRINT "Hello, $name.";PRINT "<BR><BR>"; PRINT "Thank you for your interest.<BR><BR>"; PRINT "We will send information to $email, and have noted that you like $preference"; PRINT "</CENTER><BR><BR>"; /* Send relevant emails */ mail("$email", "Your request for information", "$name\nThank you for your interest!\nWe sell fresh corn daily over the Internet!Place your order at http://www.buycorn.com,and receive a free package of $preference!");mail("$adminaddress","Visitor request for info."," $name requested for information.\n The email address is $email. \n The Photo $photo \n The visitor prefers $preference."); /* Insert information into table */ $result = mysql_query ("INSERT INTO $userstable (name, email, preference ) VALUES ('$name', '$email', '$preference' ) "); $result = mysql_query select ref from information where (name = '$name'); if ($row = mysql_fetch_array($result)) { do { print $row["ref"]; print (" "); print (" "); } while($row = mysql_fetch_array($result)); } else {print "Sorry, no records were found!";} PRINT "Your information has also been inserted into our database, for future reference."; PRINT "Your Ref : $ref"; /* Close the database connection */ MYSQL_CLOSE(); ?> </body> </html> Please can anyone help thankyou abbs1@x-stream.co.uk

« previous php.version4 (#10230) next »