runnerjp Posted November 8, 2008 Share Posted November 8, 2008 humm i cant figure out where im off wrong.. <input type="checkbox" name="email" /> elseif (isset($_POST['submit'])) { $thePost = $_POST['yourpost']; $theSubject = $_POST['subject']; if ($thePost == "" || $thePost == null) { $errMsgPost = "Error: You did not type in a post."; //no post entered } elseif ($theSubject == "" || $theSubject == null) { $errMsgSubject = "Error: You did not enter a subject."; //no subject entered } else { if (isset($_POST['email'])) { $insertpost = "INSERT INTO forumtutorial_posts(emailreply) values('1')"; } //we now strip HTML injections $theSubject = strip_tags($theSubject); $thePost = strip_tags($thePost); $insertpost = "INSERT INTO forumtutorial_posts(forum,author,title,post,showtime,realtime,lastrepliedto,lastposter) values('$forum','$username','$theSubject','$thePost','$thedate','$thedate','$thedate','$username')"; mysql_query($insertpost) or die("Could not insert post"); //insert post $updatepost = "UPDATE `users` SET `post_count`=`post_count`+'1' WHERE `Username`='$username'"; mysql_query($updatepost) or die("Could not update post"); header("Location: http://www.runningprofiles.com/members/index.php?page=forum&forum=$forum"); exit; } } ?> always records 0 Quote Link to comment Share on other sites More sharing options...
bobbinsbro Posted November 8, 2008 Share Posted November 8, 2008 well, you never actually save the emailreply = 1 into the database... Quote Link to comment Share on other sites More sharing options...
Yesideez Posted November 8, 2008 Share Posted November 8, 2008 I'm sure there's a space missing, try this: $insertpost = "INSERT INTO forumtutorial_posts (emailreply) values('1')"; Quote Link to comment Share on other sites More sharing options...
runnerjp Posted November 8, 2008 Author Share Posted November 8, 2008 nope that didnt do it... its strange :S.. emailreply is the correct name Quote Link to comment Share on other sites More sharing options...
bobbinsbro Posted November 8, 2008 Share Posted November 8, 2008 once again, you don't actually send the email value to the DB via a query. you set the query here: $insertpost = "INSERT INTO forumtutorial_posts(emailreply) values('1')"; then you overwrite $insertpost here: $insertpost = "INSERT INTO forumtutorial_posts(forum,author,title,post,showtime,realtime,lastrepliedto,lastposter) values('$forum','$username','$theSubject','$thePost','$thedate','$thedate','$thedate','$username')"; and only call mysql_query here: mysql_query($insertpost) or die("Could not insert post"); //insert post so you never actually insert the emailreply = 1 into the forumtutorial_posts table. Quote Link to comment Share on other sites More sharing options...
Yesideez Posted November 8, 2008 Share Posted November 8, 2008 That could be it! Quote Link to comment Share on other sites More sharing options...
runnerjp Posted November 8, 2008 Author Share Posted November 8, 2008 ah ok well how would u go about it? Quote Link to comment Share on other sites More sharing options...
Yesideez Posted November 8, 2008 Share Posted November 8, 2008 Maybe call it instead of assigning the call to a variable? Quote Link to comment Share on other sites More sharing options...
bobbinsbro Posted November 8, 2008 Share Posted November 8, 2008 like this (i hope it's not buggy): <?php elseif (isset($_POST['submit'])) { $thePost = $_POST['yourpost']; $theSubject = $_POST['subject']; if ($thePost == "" || $thePost == null) { $errMsgPost = "Error: You did not type in a post."; //no post entered } elseif ($theSubject == "" || $theSubject == null) { $errMsgSubject = "Error: You did not enter a subject."; //no subject entered } else { //we now strip HTML injections $theSubject = strip_tags($theSubject); $thePost = strip_tags($thePost); $insertpost = "INSERT INTO forumtutorial_posts(forum,author,title,post,showtime,realtime,lastrepliedto,lastposter"; if (isset($_POST['email'])) { $insertpost .= ",emailreply"; //if the checkbox isset, add emailreply to the column list } $insertpost .= ") values('$forum','$username','$theSubject','$thePost','$thedate','$thedate','$thedate','$username'"; if (isset($_POST['email'])) { $insertpost .= ",'1'"; //if checkbox isset add '1' to the value list } $insertpost .= ")"; mysql_query($insertpost) or die("Could not insert post"); //insert post $updatepost = "UPDATE `users` SET `post_count`=`post_count`+'1' WHERE `Username`='$username'"; mysql_query($updatepost) or die("Could not update post"); header("Location: http://www.runningprofiles.com/members/index.php?page=forum&forum=$forum"); exit; } } ?> Quote Link to comment Share on other sites More sharing options...
runnerjp Posted November 8, 2008 Author Share Posted November 8, 2008 what i ended up doing is runnign code like this <?php if (isset($_POST['email'])) { $theSubject = strip_tags($theSubject); $thePost = strip_tags($thePost); $insertpost = "INSERT INTO forumtutorial_posts(forum,author,title,post,showtime,realtime,lastrepliedto,lastposter,emailreply) values('$forum','$username','$theSubject','$thePost','$thedate','$thedate','$thedate','$username','1')"; mysql_query($insertpost) or die("Could not insert post"); //insert post $updatepost = "UPDATE `users` SET `post_count`=`post_count`+'1' WHERE `Username`='$username'"; mysql_query($updatepost) or die("Could not update post"); header("Location: http://www.runningprofiles.com/members/index.php?page=forum&forum=$forum"); exit; } else { //we now strip HTML injections $theSubject = strip_tags($theSubject); $thePost = strip_tags($thePost); $insertpost = "INSERT INTO forumtutorial_posts(forum,author,title,post,showtime,realtime,lastrepliedto,lastposter) values('$forum','$username','$theSubject','$thePost','$thedate','$thedate','$thedate','$username')"; mysql_query($insertpost) or die("Could not insert post"); //insert post $updatepost = "UPDATE `users` SET `post_count`=`post_count`+'1' WHERE `Username`='$username'"; mysql_query($updatepost) or die("Could not update post"); header("Location: http://www.runningprofiles.com/members/index.php?page=forum&forum=$forum"); exit; } } }?> 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.