helpmeplease2 Posted April 10, 2007 Share Posted April 10, 2007 Why doesn't this work? Is it because the $php_self doesn't work with pages like www.example.com?p=vgrgr&gerr=S&video=name if($_POST['submityes']=="yes"){ $name=$_POST['name']; $comment=$_POST['comment']; $query="INSERT INTO comments (Name,Comment) VALUES ('$name','$comment')"; mysql_query($query) or die('Could not query: ' . mysql_error()); }else{ echo "<form name=\"commentsform\" action=\"$PHP_SELF\" method=\"post\"> <table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"> <tr><td>Name: </td><td><input type=\"text\" name=\"name\" size=\"30\"><br></td></tr> <tr><td>Comments: </td><td><textarea name=\"comment\" rows=\"6\" cols=\"40\" wrap=\"virtual\"></textarea></td></tr></table> <input type=\"hidden\" name=\"submityes\" value=\"yes\"> <input type=\"submit\" value=\"Add Comments\"></form>"; } Link to comment https://forums.phpfreaks.com/topic/46372-solved-my-form-isnt-working/ Share on other sites More sharing options...
helpmeplease2 Posted April 11, 2007 Author Share Posted April 11, 2007 Anyone? Link to comment https://forums.phpfreaks.com/topic/46372-solved-my-form-isnt-working/#findComment-226479 Share on other sites More sharing options...
tippy_102 Posted April 11, 2007 Share Posted April 11, 2007 I tested it and it worked for me.....didn't test the INSERT though. What error are you getting? Also, you should clean the data before adding it to the database: $name= mysql_real_escape_string( $name ); Link to comment https://forums.phpfreaks.com/topic/46372-solved-my-form-isnt-working/#findComment-226483 Share on other sites More sharing options...
helpmeplease2 Posted April 11, 2007 Author Share Posted April 11, 2007 No error, it just doesn't work. Link to comment https://forums.phpfreaks.com/topic/46372-solved-my-form-isnt-working/#findComment-226498 Share on other sites More sharing options...
tippy_102 Posted April 11, 2007 Share Posted April 11, 2007 What part doesn't work? Link to comment https://forums.phpfreaks.com/topic/46372-solved-my-form-isnt-working/#findComment-226501 Share on other sites More sharing options...
fenway Posted April 11, 2007 Share Posted April 11, 2007 Also, why not have the HTML as HTML, and the php variables as PHP? The way you have it set up defeats the purpose... Link to comment https://forums.phpfreaks.com/topic/46372-solved-my-form-isnt-working/#findComment-226697 Share on other sites More sharing options...
helpmeplease2 Posted April 11, 2007 Author Share Posted April 11, 2007 It doesn't add it to the database. Link to comment https://forums.phpfreaks.com/topic/46372-solved-my-form-isnt-working/#findComment-226813 Share on other sites More sharing options...
fenway Posted April 11, 2007 Share Posted April 11, 2007 Without an error? Link to comment https://forums.phpfreaks.com/topic/46372-solved-my-form-isnt-working/#findComment-227087 Share on other sites More sharing options...
helpmeplease2 Posted April 12, 2007 Author Share Posted April 12, 2007 Yup, no error. Link to comment https://forums.phpfreaks.com/topic/46372-solved-my-form-isnt-working/#findComment-227319 Share on other sites More sharing options...
rpadilla Posted April 12, 2007 Share Posted April 12, 2007 try inserting a marker in your insert statment, to make sure its really executed like mysql_query($query) or die('Could not query: ' . mysql_error()); echo 'my query was executed'; also try making some error codes, maybe error reporting is off. Link to comment https://forums.phpfreaks.com/topic/46372-solved-my-form-isnt-working/#findComment-227392 Share on other sites More sharing options...
fenway Posted April 12, 2007 Share Posted April 12, 2007 Then post the query string sent to mysql. Link to comment https://forums.phpfreaks.com/topic/46372-solved-my-form-isnt-working/#findComment-227508 Share on other sites More sharing options...
helpmeplease2 Posted April 12, 2007 Author Share Posted April 12, 2007 It turns out it was inserting it, but not everything I wanted. I modified the code, but its still not inserting the Game and Video. The $gtitle and $vtitle are from the url. if($_POST['submityes']=="yes"){ $gtitle=$_GET['game']; $vtitle=$_GET['video']; $result = mysql_query("SELECT * FROM videos WHERE GTitle='$gtitle' AND VTitle='$vtitle'") or die(mysql_error()); while($row = mysql_fetch_row( $result )) { $name=$_POST['name']; $game=$row['GTitle']; $video=$row['VTitle']; $comment=$_POST['comment']; $query="INSERT INTO comments (Name,Game,Video,Comment) VALUES ('$name','$game','$video','$comment')"; mysql_query($query) or die('Could not query: ' . mysql_error()); } }else{ echo "<form name=\"commentsform\" action=\"$PHP_SELF\" method=\"post\"> <table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"> <tr><td>Name: </td><td><input type=\"text\" name=\"name\" size=\"30\"><br></td></tr> <tr><td>Comments: </td><td><textarea name=\"comment\" rows=\"6\" cols=\"40\" wrap=\"virtual\"></textarea></td></tr></table> <input type=\"hidden\" name=\"submityes\" value=\"yes\"> <input type=\"submit\" value=\"Add Comments\"></form>"; } Link to comment https://forums.phpfreaks.com/topic/46372-solved-my-form-isnt-working/#findComment-227650 Share on other sites More sharing options...
fenway Posted April 12, 2007 Share Posted April 12, 2007 Sigh.... could you just post the echo of $query? I'm sure they're blank. Link to comment https://forums.phpfreaks.com/topic/46372-solved-my-form-isnt-working/#findComment-227652 Share on other sites More sharing options...
helpmeplease2 Posted April 12, 2007 Author Share Posted April 12, 2007 They are blank thats why I need your help. Link to comment https://forums.phpfreaks.com/topic/46372-solved-my-form-isnt-working/#findComment-227656 Share on other sites More sharing options...
fenway Posted April 12, 2007 Share Posted April 12, 2007 Well, print out the $row hash. Link to comment https://forums.phpfreaks.com/topic/46372-solved-my-form-isnt-working/#findComment-227961 Share on other sites More sharing options...
helpmeplease2 Posted April 12, 2007 Author Share Posted April 12, 2007 Arghhh I was trying to do it the hard way! I could've just put $name=$_POST['name']; $game=$_GET['game']; $video=$_GET['video']; $comment=$_POST['comment']; $query="INSERT INTO comments (Name,Game,Video,Comment) VALUES ('$name','$game','$video','$comment')"; mysql_query($query) or die('Could not query: ' . mysql_error()); That is working, thanks for the help! Link to comment https://forums.phpfreaks.com/topic/46372-solved-my-form-isnt-working/#findComment-228039 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.