runnerjp Posted November 10, 2008 Share Posted November 10, 2008 for soem reaosn my form validation is not working... iv ran a few tests and its just passing the blank field as acceptable... <?php if (isset($_POST['submit'])) { $name = $puser; $yourpost = $_POST['yourpost']; if ($yourPost == "" || strlen($yourPost) < 1) { $errMsgPost = "Error: You did not type in a post."; //no post entered } else { $thedate = date("U"); //get unix timestamp $displaytime = time(); //we now strip HTML injections $subject = strip_tags($subject); $name = strip_tags($name); //This is where the bbcode come in. $message = new BBCode; $message->selection = $yourpost; $message->parseCode(); // set to 1 if you want to disable bbcode $message->parseEmoticons(); $yourpost = $message->parsed; $insertpost = "INSERT INTO `forumtutorial_posts` (`author`,`forum`,`title`,`post`,`showtime`,`realtime`,`lastposter`,`parentid`) values('$name','$forum','$subject','$yourpost','$thedate','$thedate','$name','$forumpostid')"; mysql_query($insertpost) or die("Could not insert post"); //insert post var_dump($insertpost); mysql_query($insertpost) or die("Could not insert post"); //insert post $updatepost = "UPDATE `forumtutorial_posts` SET `numreplies`=`numreplies`+'1', `lastposter`='$name', `lastrepliedto`='$thedate' WHERE `postid`='$forumpostid'"; mysql_query($updatepost) or die("Could not update post"); $updatep = "UPDATE `users` SET `post_count`=`post_count`+'1', last_post=$thedate WHERE `Username`='$name'"; mysql_query($updatep) or die("Could not update post"); //header("Location: index.php?page=message&forum=$forum&id=$forumpostid&pagenum=last"); } } else { if ($gettopic3['forumlock'] == 0) { ?></span> <span style="color:red;"><?php echo $errMsgPost; ?></span> but its just apssing it :S can any1 see why.,.. Link to comment https://forums.phpfreaks.com/topic/132119-validation-not-working/ Share on other sites More sharing options...
haku Posted November 10, 2008 Share Posted November 10, 2008 $yourpost != $yourPost. Link to comment https://forums.phpfreaks.com/topic/132119-validation-not-working/#findComment-686596 Share on other sites More sharing options...
runnerjp Posted November 10, 2008 Author Share Posted November 10, 2008 didnt see that.... chnaged it to $yourpost = $_POST['yourpost']; if ($yourpost == "" || strlen($yourpost) < 1) { $errMsgPost = "Error: You did not type in a post."; //no post entered } but still puts it through string(186) "INSERT INTO `forumtutorial_posts` (`author`,`forum`,`title`,`post`,`showtime`,`realtime`,`lastposter`,`parentid`) values('Admin','General','',' ','1226320947','1226320947','Admin','373')" Link to comment https://forums.phpfreaks.com/topic/132119-validation-not-working/#findComment-686599 Share on other sites More sharing options...
IndyTechNerd Posted November 10, 2008 Share Posted November 10, 2008 Try putting an exit(); after you set $errMsgPost to kick it out of the script. Or, try something like this.. if ($yourPost == "" || strlen($yourPost) < 1) { $errMsgPost = "Error: You did not type in a post."; //no post entered $errLvl = 1; }else{ $errLvl = 0; } // SNIP if($errLvl < 1){ mysql_query($insertpost) or die("Could not insert post"); //insert post $updatepost = "UPDATE `forumtutorial_posts` SET `numreplies`=`numreplies`+'1', `lastposter`='$name', `lastrepliedto`='$thedate' WHERE `postid`='$forumpostid'"; mysql_query($updatepost) or die("Could not update post"); $updatep = "UPDATE `users` SET `post_count`=`post_count`+'1', last_post=$thedate WHERE `Username`='$name'"; mysql_query($updatep) or die("Could not update post"); //header("Location: index.php?page=message&forum=$forum&id=$forumpostid&pagenum=last"); } // end errLvl check } Link to comment https://forums.phpfreaks.com/topic/132119-validation-not-working/#findComment-686638 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.