buknoii Posted March 14, 2008 Share Posted March 14, 2008 greetings! I installed XAMPP on my computer and when i tried creating a php script to view the database it shows the result perfectly. But when I tried creating a simple guestbook program it keeps showing the same error message "WRONG" below are the codes of my program SIGNUP.PHP <form method="post" action="signup_db.php"> Name : <input type="text" name="frm_name"><br> E-mail : <input type="text" name="frm_email"><br> Tel No : <input type="text" name="frm_telno"><br> Message : <input type="text" name="frm_message"><br> <input type="submit" name="frm_submit" value="POST GUESTBOOK"> SIGNUP_DB.PHP <?php include("dbconnect.php"); if ($frm_submit=="POST GUESTBOOK") { $query = " insert into gb_entry (gb_name,gb_email,gb_telno,gb_message) values ('".mysql_real_escape_string($frm_name)."','". mysql_real_escape_string($frm_email)."','". mysql_real_escape_string($frm_telno)."','". mysql_real_escape_string($frm_message)."')" ; mysql_query($query) or die(mysql_error()); ?> <h2>entry added</h2> <?php } else { echo "WRONG"; } ?> dbconnect.php <?php mysql_connect("127.0.0.1","root","november") or die("query=$query\nerror=".mysql_error()); mysql_select_db("guestbook") or die ("could not select database"); ?> any help would be appreciated thanks! Link to comment https://forums.phpfreaks.com/topic/96127-simple-guestbook-problem/ Share on other sites More sharing options...
derrick1123 Posted March 14, 2008 Share Posted March 14, 2008 signup_db.php: <?php include("dbconnect.php"); if ($_POST['frm_submit']=="POST GUESTBOOK") { $query = " insert into gb_entry (gb_name,gb_email,gb_telno,gb_message) values ('".mysql_real_escape_string($frm_name)."','". mysql_real_escape_string($frm_email)."','". mysql_real_escape_string($frm_telno)."','". mysql_real_escape_string($frm_message)."')" ; mysql_query($query) or die(mysql_error()); echo "<h2>entry added</h2>"; } else { echo "WRONG"; } ?> Link to comment https://forums.phpfreaks.com/topic/96127-simple-guestbook-problem/#findComment-492095 Share on other sites More sharing options...
buknoii Posted March 14, 2008 Author Share Posted March 14, 2008 thank you very much with your help Link to comment https://forums.phpfreaks.com/topic/96127-simple-guestbook-problem/#findComment-492274 Share on other sites More sharing options...
derrick1123 Posted March 14, 2008 Share Posted March 14, 2008 Re: Simple GUESTBOOK problem « Reply #1 on: Today at 06:16:55 AM » Now thats what I call a "in the morning" post. lol ________ I am glad it worked out for you. ^.^ Link to comment https://forums.phpfreaks.com/topic/96127-simple-guestbook-problem/#findComment-492486 Share on other sites More sharing options...
buknoii Posted March 16, 2008 Author Share Posted March 16, 2008 hi! thanks for your help! but when i tried inserting the code that your recommended it works well with firefox but not in IE and everytime it works and i view the tables, the fields are empty. Link to comment https://forums.phpfreaks.com/topic/96127-simple-guestbook-problem/#findComment-493153 Share on other sites More sharing options...
june_c21 Posted March 16, 2008 Share Posted March 16, 2008 try this php code <?php $host = "localhost"; $user = "root"; $password = ""; $dbase = "guestbook"; $dblink = mysql_connect($host,$user,$password); mysql_select_db($dbase,$dblink); $query = "INSERT INTO guestbook_example (name, comment) VALUES ('$name','$comment')"; $result1 = mysql_query($query, $dblink); ?> html code <form name="form1" method="post" action=""> <p>Name <input type="text" name="name"> </p> <p>Comment <label> <input type="text" name="comment"> </label> </p> </form> Link to comment https://forums.phpfreaks.com/topic/96127-simple-guestbook-problem/#findComment-493176 Share on other sites More sharing options...
derrick1123 Posted March 16, 2008 Share Posted March 16, 2008 hi! thanks for your help! but when i tried inserting the code that your recommended it works well with firefox but not in IE and everytime it works and i view the tables, the fields are empty. My bad, I don't ever test in IE. Its good someone checks >.< Link to comment https://forums.phpfreaks.com/topic/96127-simple-guestbook-problem/#findComment-493180 Share on other sites More sharing options...
buknoii Posted March 18, 2008 Author Share Posted March 18, 2008 Jun and Derrick thanks for the help! what i did is i incorporated both of your codes and it worked perfectly. <?php include("dbconnect.php"); $xname = $_POST['frm_name']; $email = $_POST['frm_email']; $telno = $_POST['frm_telno']; $message = $_POST['frm_telno']; $frm_submit = $_POST['frm_submit']; if ($_POST['frm_submit']=="POST GUESTBOOK") { $query = " insert into gb_entry (gb_name,gb_email,gb_telno,gb_message) values ('".mysql_real_escape_string($xname)."','". mysql_real_escape_string($email)."','". mysql_real_escape_string($telno)."','". mysql_real_escape_string($message)."')" ; mysql_query($query) or die(mysql_error()); echo "<h2>entry added</h2>"; } else { echo "WRONG"; } ?> thanks guys! Link to comment https://forums.phpfreaks.com/topic/96127-simple-guestbook-problem/#findComment-494548 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.