This may help you. //createenrty.php <script language="javascript"> function funsubmit() { .............. return true/false based on input checks } <form.. onsubmit='return funsubmit()' .............. action=nextpage.php> ............... <input type=submit name=submit value="Sign dammit"> </form>
//nextpage.php do your db transactions here -Murugesan ----- Original Message ----- From: "Stephen Tiano" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, September 08, 2003 3:05 PM Subject: [PHP] Problem Coding a Tutorial > I found a new book for again starting out to learn PHP/MySQL Web App > programming. I've begun exercises toward that end. > > So far I've opened MySQL--I'm on a Macintosh PowerBook, so that's > UNIX--as root and created a database I called guest_recorder. Then I > GRANTed ALL to a new user (me) with a password. I then quit MySQL. > > Next I opened MySQL again as the new user I created, did a USE > guest_recorder and then created my first table guest_info. The table had > five columns: name, location, email, url, and comments. When I did a > DESCRIBE guest_info, it properly displayed the columns. > > Then I typed "dbconnect.php": > > <?php > mysql_connect("localhost", "--------", "-------") or > die ("Could not connect to database"); > mysql_select_db("guest_recorder") or > die ("Could not select database"); > ?> > > followed by "create_entry.php": > > <html> > <head> > <title>Create Entry</title> > </head> > <body> > > <?php > include("dbconnect.php"); > > if ($submit == "Sign!") > { > $query = "insert into guest_info > (name,location,email,url,comments) values > <'$name', '$location', '$email', '$url', '$comments')" > ; > mysql_query($query) or die (mysql_error()); > ?> > <h2>Thanks!</h2> > <h2><a href="view.php">View My Guest Book!</a></h2> > <?php > } > else > { > include("sign.php"); > } > ?> > > and "sign.php": > > When I open "create_entry.php" in my browser, the form and its five > fields appear correctly, and I fill them out. I then hit the "Sign, > dammit!" button. > > I was expecting the "Thanks!" and "View My Guest Book!" messages, but > instead am greeted with the same form with its five blank fields so's I > can type in info for name, location, email, url, and comments. > > When I go to view the table named "guest_info" in the database named > "guest_recorder" using SELECT * FROM guest_info, I'm told "Empty set". > > If the form's info isn't making it to the table, I'm thinking I need > $_POST statements--as in $_POST["name"], $_POST["location"], > etc.--somewhere to get each field's info into the table. But where do I > put those lines and in which file: "create_entry.php" or "sign.php"? > > Thank you. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php