Jump to content

validation not working


runnerjp

Recommended Posts

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

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')"

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
                    
                        }

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.