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

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.