shrimp Posted September 20, 2006 Share Posted September 20, 2006 hello,im nubi on php heheh.. and my st try is this guestbook http://sildeyna.trap17.net/guestbook.phpthe problem is when we input the name email n comment. it wont popup on the handler. and as the results it inputs nothing on the database. i dunno because of what. anyone help me pleasee :((( thank u so much Quote Link to comment Share on other sites More sharing options...
shrimp Posted September 20, 2006 Author Share Posted September 20, 2006 anyone can help ? anyway this is what i type on,this is the form[quote]<html><link href="style.css" rel="stylesheet" type="text/css" /><body><table width="400" border="0" align="center" cellpadding="3" cellspacing="0"><tr><td class="halo"><strong>Test Sign Guestbook </strong></td></tr></table><table width="400" border="0" align="center" cellpadding="3" cellspacing="0"><tr><td class="halo"><strong><a href="viewguestbook.php">View Guestbook</a> </strong></td></tr></table><form id="form2" name="form2" method="post" action="addguestbook.php"> <table width="500" border="0" align="center" cellpadding="0" cellspacing="0" class="halo"> <tr> <td width="147" class="halo">Name</td> <td width="353" class="halo"> : <label> <input name="name" type="text" id="name" /> </label> </td> </tr> <tr> <td class="halo">Email</td> <td class="halo"> : <input name="email" type="text" id="email" /> </td> </tr> <tr> <td class="halo">Comments</td> <td class="halo"> : <label> <textarea name="comment" cols="40" id="comment"></textarea> </label> </td> </tr> <tr> <td> </td> <td class="halo"> <label> <input type="submit" name="Submit" value="Submit" /> </label> </td> </tr> </table></form><p> </p></body></html>[/quote]this is the handler :[quote]<html><link href="style.css" rel="stylesheet" type="text/css" /><body><p> <?php$host="localhost"; // Host name$username="root"; // Mysql username$password=""; // Mysql password$db_name="guest"; // Database name$tbl_name="guestbook"; // Table nameecho "$name";// Connect to server and select database.mysql_connect("$host", "$username", "$password")or die("cannot connect server ");mysql_select_db("$db_name")or die("cannot select DB");$datetime=date("y-m-d h:i:s"); //date time$sql="INSERT INTO $tbl_name(name, email, comment, datetime)VALUES('$name', '$email', '$comment', '$datetime');";$result=mysql_query($sql);//check if query successfulif($result){echo "Successful";echo "<BR>";echo "<a href='viewguestbook.php'>View guestbook</a>"; // link to view guestbook page}else {echo "ERROR";}mysql_close();?></p></body></html>[/quote]anyone can help me with the error :( Quote Link to comment Share on other sites More sharing options...
redarrow Posted September 20, 2006 Share Posted September 20, 2006 fill in the xxx and then select the insert colum try ok.in your form put upercase POSTi also added the POST[''] and addslashes statement ok;[code]<html><link href="style.css" rel="stylesheet" type="text/css" /><body><p><?php$db=mysql_connect("xxlocalhostxx","xxusernamexx","xxpasswordxx");mysql_select_db("xxdatabasexx",$db);$name=addslashes($_POST['name']);$email=addslashes($_POST['email']);$comment=addslashes($_POST['comment']);$datetime=addslashes($_POST['datetime']);$datetime=date("y-m-d h:i:s"); //date timeif($_POST['submit']){$sql="INSERT INTO xxcolumnamexx(`name`, `email`, `comment`, `datetime`)VALUES('$name', '$email', '$comment', '$datetime');";$result=mysql_query($sql);}//check if query successfulif($result){echo "Successful";echo "<BR>";echo "<a href='viewguestbook.php'>View guestbook[/url]"; // link to view guestbook page}else {echo "ERROR";}mysql_close();?></p></body></html>[/code] Quote Link to comment Share on other sites More sharing options...
shrimp Posted September 20, 2006 Author Share Posted September 20, 2006 hi redarrow thanks for helping mebtw i did change the handler to this [quote]<html><link href="style.css" rel="stylesheet" type="text/css" /><body><p><?php$db=mysql_connect("localhost","root","")or die("GAK BISA KONEK");mysql_select_db("guest",$db);$name=addslashes($_POST['name']);$email=addslashes($_POST['email']);$comment=addslashes($_POST['comment']);$datetime=addslashes($_POST['datetime']);$datetime=date("y-m-d h:i:s"); //date timeif($_POST['submit']){$sql="INSERT INTO guestbook(`name`, `mail`, `comment`, `datetime`)VALUES('$name', '$email', '$comment', '$datetime');";$result=mysql_query($sql);}//check if query successfulif($result){echo "Successful";echo "<BR>";echo "<a href='viewguestbook.php'>View guestbook[/url]"; // link to view guestbook page}else {echo "ERROR";}mysql_close();?></p></body></html>[/quote]but its error. when i press submitbtw i dunno what u mean uppercase post. i did put post method. thanks a lot for the explanation mate. God Bless Quote Link to comment Share on other sites More sharing options...
redarrow Posted September 20, 2006 Share Posted September 20, 2006 post the errors please cheers.POST - upercasepost - lowercase<form id="form2" name="form2" method="post" action="addguestbook.php">to<form method="POST" action="addguestbook.php">make sure that the form inputs are correct as i only use html and you use xhtml so cheek ok.<input name="email" type="text" id="email" /> Quote Link to comment Share on other sites More sharing options...
shrimp Posted September 20, 2006 Author Share Posted September 20, 2006 its just says ERROR which is i tink at the last if else bro.. ::) Quote Link to comment Share on other sites More sharing options...
redarrow Posted September 20, 2006 Share Posted September 20, 2006 try this please cheers.[code]<html><link href="style.css" rel="stylesheet" type="text/css" /><body><p><?php$db=mysql_connect("localhost","root","")or die("GAK BISA KONEK");mysql_select_db("guest",$db);$name=addslashes($_POST['name']);$email=addslashes($_POST['email']);$comment=addslashes($_POST['comment']);$datetime=addslashes($_POST['datetime']);$datetime=date("y-m-d h:i:s"); //date timeif($_POST['submit']){$sql="INSERT INTO guestbook(`name`, `mail`, `comment`, `datetime`)VALUES('$name', '$email', '$comment', '$datetime');";$result=mysql_query($sql);echo"data inseted";exit;}else{echo "no data inserted";exit;}?></p></body></html>[/code] Quote Link to comment Share on other sites More sharing options...
shrimp Posted September 20, 2006 Author Share Posted September 20, 2006 oredi try bro but still. the msg is.. NO DATA INSERTED hehehethis is my ugly form[quote]<html><link href="style.css" rel="stylesheet" type="text/css" /><body><p><form method="POST" action="addguestbook1.php"> <table width="500" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="145" class="halo">Name</td> <td width="355" class="halo"> : <input name="name" type="text" id="name"> </td> </tr> <tr> <td class="halo">Email</td> <td class="halo"> : <input name="email" type="text" id="email"> </td> </tr> <tr> <td class="halo">Comments</td> <td class="halo"> : <textarea name="comment" cols="40" id="comment"></textarea> </td> </tr> <tr> <td> </td> <td class="halo"> <label> <input type="submit" name="Submit" value="submit" > </label> </td> </tr> </table></form> </p></body></html>[/quote]sorry trouble u bro Quote Link to comment Share on other sites More sharing options...
redarrow Posted September 20, 2006 Share Posted September 20, 2006 try this out[code]<html><link href="style.css" rel="stylesheet" type="text/css" /><body><table width="400" border="0" align="center" cellpadding="3" cellspacing="0"><tr><td class="halo"><strong>Test Sign Guestbook</strong></td></tr></table><table width="400" border="0" align="center" cellpadding="3" cellspacing="0"><tr><td class="halo"><strong><a href="viewguestbook.php">View Guestbook[/url] </strong></td></tr></table><form method="post" action="addguestbook.php"> <table width="500" border="0" align="center" cellpadding="0" cellspacing="0" class="halo"> <tr> <td width="147" class="halo">Name</td> <td width="353" class="halo"> : <label> <input name="name" type="text"> </label> </td> </tr> <tr> <td class="halo">Email</td> <td class="halo"> : <input name="email" type="text" > </td> </tr> <tr> <td class="halo">Comments</td> <td class="halo"> : <label> <textarea name="comment" cols="40" ></textarea> </label> </td> </tr> <tr> <td> </td> <td class="halo"> <label> <input type="submit" name="Submit" value="Submit" /> </label> </td> </tr> </table></form><p> </p></body></html>[/code] Quote Link to comment Share on other sites More sharing options...
redarrow Posted September 20, 2006 Share Posted September 20, 2006 try this ok i tested the form and works know so you now need to test the database as i have not got yours ok.once that done were also add some valadation .[code]<html><link href="style.css" rel="stylesheet" type="text/css" /><body><table width="400" border="0" align="center" cellpadding="3" cellspacing="0"><tr><td class="halo"><strong>Test Sign Guestbook</strong></td></tr></table><table width="400" border="0" align="center" cellpadding="3" cellspacing="0"><tr><td class="halo"><strong><a href="viewguestbook.php">View Guestbook[/url] </strong></td></tr></table><form method="post" action="addguestbook.php"> <table width="500" border="0" align="center" cellpadding="0" cellspacing="0" class="halo"> <tr> <td width="147" class="halo">Name</td> <td width="353" class="halo"> : <label> <input type="text" name="name"> </label> </td> </tr> <tr> <td class="halo">Email</td> <td class="halo"> : <input type="text" name="email" > </td> </tr> <tr> <td class="halo">Comments</td> <td class="halo"> : <label> <textarea name="comment" cols="40" ></textarea> </label> </td> </tr> <tr> <td> </td> <td class="halo"> <label> <input type="submit" name="Submit" value="Submit"> </label> </td> </tr> </table></form><p> </p></body></html>[/code][code]<html><link href="style.css" rel="stylesheet" type="text/css" /><body><p><?php$db=mysql_connect("localhost","root","")or die("GAK BISA KONEK");mysql_select_db("guest",$db);$name=addslashes($_POST['name']);$email=addslashes($_POST['email']);$comment=addslashes($_POST['comment']);$datetime=addslashes($_POST['datetime']);$datetime=date("y-m-d h:i:s"); //date timeif($_POST['submit']){$sql="INSERT INTO guestbook(`name`, `mail`, `comment`, `datetime`)VALUES('$name', '$email', '$comment', '$datetime')";$result=mysql_query($sql);echo"data inseted";exit;}else{echo "no data inserted";exit;}?></p></body></html>[/code] Quote Link to comment Share on other sites More sharing options...
redarrow Posted September 20, 2006 Share Posted September 20, 2006 afther all that look at your insert $query you got a extra ;should be "; Quote Link to comment Share on other sites More sharing options...
shrimp Posted September 20, 2006 Author Share Posted September 20, 2006 oredi fixed and try it out bro.. still no clue y this still no data insert. if u dun mind, below i zip my file n screenshot of phpmyadmin mysql table.. http://geocities.com/butter_punk/guestbook.zipDatabase name : testTable : guestbookusername : rootno password. Many thanks for the help n time bro.. Quote Link to comment Share on other sites More sharing options...
shrimp Posted September 21, 2006 Author Share Posted September 21, 2006 hello redarrow. do u hav im? if u dun mind :) Quote Link to comment Share on other sites More sharing options...
shrimp Posted September 21, 2006 Author Share Posted September 21, 2006 redarrow thanks. solve it oredi... the thing is just 'submit' need to changed to 'Submit' hiks.. hehehe THANKS A LOT BRO! :) Quote Link to comment 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.