This is the code:
Main guestbook:
Thanks code:
here's the code which I created the TABLE with:
What's wrong? I'm a noob so please explain!
Last edited by catscratches on Thu Dec 28, 2006 6:57 pm; edited 1 time in total
Main guestbook:
| Code: |
| <html>
<head> <title>Guestbook</title> </head> <body> <b><u>Guestbook</b></u><br><br> Write post:<br> <form method="post" action="thanks_guest.php"> Name: <input type="text" name="name" value="" size="35"><br> E-mail: <input type="text" name="mail" value="" size="35"><br> Comment: <input type="text" name="comment" value="" size="500"><br> <input type="submit" name="submit" value="Post!"> </form><br><br> <? $con=mysql_connect('localhost','catscrat_guest',secret password which I won't tell :p); if (!$con) { die('Could not connect: ' . mysql_error()); } $db=mysql_select_db('catscrat_guestbook', $con); if (!$db) { die ("Can\'t use the database : " . mysql_error()); } $coms=mysql_query('SELECT * FROM post', $db); while ($row != mysql_fetch_array($coms)) { echo $row['name'] . '<br> ' . $row['mail'] . '<br>' . $row['comment'] or die (mysql_error()); } mysql_close($con); ?> </body> </html> |
Thanks code:
| Code: |
| <html>
<head> <title>Thanks!</title> </head> <body> <? $con=mysql_connect('localhost','catscrat_guest',secret password which I won't tell :p); if (!$con) { die('Could not connect: ' . mysql_error()); } $db=mysql_select_db('catscrat_guestbook', $con); if (!$db) { die ("Can\'t use the database : " . mysql_error()); } mysql_query('INSERT INTO post ("name","mail","comment") VALUES ("' . $_POST[name] . '","' . $_POST[mail] . '","' . $_POST[comment] . ')',$con); mysql_close($con); ?> <u><b>Thanks for your post!</u></b><br><br> <a href="guestbook.php">Back to Guestbook</a><br> <a href="index.php">Main</a> </body> </html> |
here's the code which I created the TABLE with:
| Code: |
| <?
$con=mysql_connect('localhost','catscrat_guest',secret password); if (!$con) { die('Could not connect: ' . mysql_error()); } $db=mysql_select_db('catscrat_guestbook', $con); if (!$db) { die ("Can\'t use the database : " . mysql_error()); } mysql_query('CREATE TABLE post(name VARCHAR(35), mail VARCHAR(35), comment VARCHAR(500))'); mysql_close($con); ?> |
What's wrong? I'm a noob so please explain!
Last edited by catscratches on Thu Dec 28, 2006 6:57 pm; edited 1 time in total
