indianlibra Posted March 28, 2007 Share Posted March 28, 2007 I created the guestbook's table in my database all things looks perfectly ok, but i don't know where's the problem this script is not completed but its enough to insert the values in the table i don't have any idea where i maked mistake i wasted my 2 hour just for searching the its problem can u find the it <?php require($_SERVER["DOCUMENT_ROOT"]."/config/db_config.php"); $connection = @mysql_connect($db_host, $db_user, $db_password) or die("error connecting"); mysql_select_db($db_name, $connection); $name = $_POST["txt_name"]; $len = strlen($name); //only write to database if there's a name if($len>0) { $email = $_POST["txt_email"]; $comment = $_POST["txt_comment"]; $date = time(); $query = "INSERT INTO guestbook (autoID, name, email, comment, date_auto) VALUES(NULL, '$name', '$email', '$comment', '$date')"; mysql_query($query, $connection) or die(mysql_error()); } ?> <html> <head> <title>Gestbook</title> </head> <body> <center> <form action="<?php echo $_SERVER[php_SELF]; ?>" method="POST"> <font face="arial" size="1"> Name: <input type="text" name="txt_name">; Email: <input type="text" name="txt_email"><br><br> Comment: <br> <textarea style="width: 75%" rows="10" name="txt_comment"></textarea> <center><input type="submit" value="Submit"></center> </font> </form> </center> </body> </html> Image 1 Image 2 Image 3 Image 4 Image 5 Quote Link to comment https://forums.phpfreaks.com/topic/44664-problem-in-php-guestbook/ Share on other sites More sharing options...
virtuexru Posted March 28, 2007 Share Posted March 28, 2007 Try <form action="" .. I usually do that, it just reloads the page and runs the script in the header. Of course then you'll have to do if() to find out whether or not the fields have been filled out to decide whether or not to put things into the DB. Quote Link to comment https://forums.phpfreaks.com/topic/44664-problem-in-php-guestbook/#findComment-216874 Share on other sites More sharing options...
papaface Posted March 28, 2007 Share Posted March 28, 2007 First of all: $connection = @mysql_connect should be: $connection = mysql_connect and <form action="<?php echo $_SERVER[php_SELF]; ?>" should be: <form action="<?php echo $_SERVER['PHP_SELF']; ?>" Quote Link to comment https://forums.phpfreaks.com/topic/44664-problem-in-php-guestbook/#findComment-216875 Share on other sites More sharing options...
Lumio Posted March 28, 2007 Share Posted March 28, 2007 make <form action="<?php echo $_SERVER[php_SELF]; ?>" method="POST"> to <form action="" method="POST"> Quote Link to comment https://forums.phpfreaks.com/topic/44664-problem-in-php-guestbook/#findComment-216876 Share on other sites More sharing options...
papaface Posted March 28, 2007 Share Posted March 28, 2007 make <form action="<?php echo $_SERVER[php_SELF]; ?>" method="POST"> to <form action="" method="POST"> Thats not a good way to do it. Use the way I suggested for the form action. Quote Link to comment https://forums.phpfreaks.com/topic/44664-problem-in-php-guestbook/#findComment-216877 Share on other sites More sharing options...
indianlibra Posted March 28, 2007 Author Share Posted March 28, 2007 First of all: $connection = @mysql_connect should be: $connection = mysql_connect and <form action="<?php echo $_SERVER[php_SELF]; ?>" should be: <form action="<?php echo $_SERVER['PHP_SELF']; ?>" it worked i can't believe i wasted my time on this silly mistake i just want to slap myself buy thanks papaface Quote Link to comment https://forums.phpfreaks.com/topic/44664-problem-in-php-guestbook/#findComment-216894 Share on other sites More sharing options...
Trium918 Posted March 28, 2007 Share Posted March 28, 2007 How does the output looks? Quote Link to comment https://forums.phpfreaks.com/topic/44664-problem-in-php-guestbook/#findComment-216898 Share on other sites More sharing options...
indianlibra Posted March 28, 2007 Author Share Posted March 28, 2007 How does the output looks? are you trying to ask about the output in browser or in table well i didn't completed the script yet So i can only show you the output in the database table After entering the values in the guestbook's fields it automatically stores in the table Data In Table Quote Link to comment https://forums.phpfreaks.com/topic/44664-problem-in-php-guestbook/#findComment-216903 Share on other sites More sharing options...
Trium918 Posted March 28, 2007 Share Posted March 28, 2007 In the browse. Quote Link to comment https://forums.phpfreaks.com/topic/44664-problem-in-php-guestbook/#findComment-216908 Share on other sites More sharing options...
indianlibra Posted March 28, 2007 Author Share Posted March 28, 2007 for that u have to wait B'coz i didn't complete my script yet Quote Link to comment https://forums.phpfreaks.com/topic/44664-problem-in-php-guestbook/#findComment-216912 Share on other sites More sharing options...
indianlibra Posted March 28, 2007 Author Share Posted March 28, 2007 here's my complete guestbook Quote Link to comment https://forums.phpfreaks.com/topic/44664-problem-in-php-guestbook/#findComment-216968 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.