Hello Stephen,

You say "then hit the "Sign, dammit!" button", and in your script you
have "...if ($submit == "Sign!")...".
Obviously, the problem is that "else" block is executed instead of
"if". It's better to use some other variable to check whether the form
is filled or not, something like
"...if(strlen($_REQUEST["comments"])>0)..."
Also, the problem may be caused by register_globals turned off...

ST> I found a new book for again starting out to learn PHP/MySQL Web App 
ST> programming. I've begun exercises toward that end.

ST> So far I've opened MySQL--I'm on a Macintosh PowerBook, so that's 
ST> UNIX--as root and created a database I called guest_recorder. Then I 
ST> GRANTed ALL to a new user (me) with a password. I then quit MySQL.

ST> Next I opened MySQL again as the new user I created, did a USE 
ST> guest_recorder and then created my first table guest_info. The table had 
ST> five columns: name, location, email, url, and comments. When I did a 
ST> DESCRIBE guest_info, it properly displayed the columns.

ST> Then I typed "dbconnect.php":

ST> <?php
ST> mysql_connect("localhost", "--------", "-------") or
ST> die ("Could not connect to database");
ST> mysql_select_db("guest_recorder") or
ST> die ("Could not select database");
?>>

ST> followed by "create_entry.php":

ST> <html>
ST> <head>
ST> <title>Create Entry</title>
ST> </head>
ST> <body>

ST> <?php
ST> include("dbconnect.php");

ST> if ($submit == "Sign!")
ST> {
ST> $query = "insert into guest_info
ST> (name,location,email,url,comments) values
ST> <'$name', '$location', '$email', '$url', '$comments')"
ST> ;
ST> mysql_query($query) or die (mysql_error());
?>>
ST> <h2>Thanks!</h2>
ST> <h2><a href="view.php">View My Guest Book!</a></h2>
ST> <?php
ST> }
ST> else
ST> {
ST> include("sign.php");
ST> }
?>>

ST> and "sign.php":

ST> When I open "create_entry.php" in my browser, the form and its five 
ST> fields appear correctly, and I fill them out. I then hit the "Sign, 
ST> dammit!" button.

ST> I was expecting the "Thanks!" and "View My Guest Book!" messages, but 
ST> instead am greeted with the same form with its five blank fields so's I 
ST> can type in info for name, location, email, url, and comments.

ST> When I go to view the table named "guest_info" in the database named 
ST> "guest_recorder" using SELECT * FROM guest_info, I'm told "Empty set".

ST> If the form's info isn't making it to the table, I'm thinking I need 
ST> $_POST statements--as in $_POST["name"], $_POST["location"], 
ST> etc.--somewhere to get each field's info into the table. But where do I 
ST> put those lines and in which file: "create_entry.php" or "sign.php"?

ST> Thank you.



-- 
Best regards,
 MuToGeN                            mailto:[EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to