I've tried everything here but I can't get my script to do the right stuff if the value of one of my fields is null...could anyone take a peek please?
I have this so script
<?php
//THIS IS WHERE WE VERIFY THE POST HAS THE RIGHT INFORMATION IN IT AND ADD TO DB
session_start();
require '/scripts/maindbconnect.php';
$title=(string)$_POST['title'];
$posting=(string)$_POST['posting'];
$msg='';
$status="OK";
$createdate=date("m/d/y H:i:s", time());
/*var_dump($title);
var_dump($posting);
exit;*/
if(!isset($title) && strlen($title)>3){
$status="NOTOK";
$msg='Must have a title for every post!!! <br/> PLEASE TRY AGAIN';
}
if(!isset($posting) && strlen($posting)>3){
$status="NOTOK";
$msg='Posting my have a body or there will be nothing to read <br/> PLEASE TRY AGAIN';
}
$myid=$_SESSION['userid'];
$posting=str_
replace("\n", '<br />', $posting);
//var_dump($_SESSION['userid']);
//var_dump($_SESSION[userid]);
//var_dump($myqry);
if($status<>"OK"){
echo "<font face='Verdana' size='2' color=red>$msg</font><br><input type='button' value='Retry' onclick='history.go(-1)'>";
}else{ // if all validations are passed.
mysql_query("INSERT INTO posts (createdate, userid, title, body, views, active) VALUES('".$createdate. "'," .$myid. ", '" .$title. "', '" .$posting. "', 0, 1)") or die(mysql_error());
header ('location: http://www.iwictu.com/viewmyposts.php');
}
?>
I added the strlen piece figuring it might help but if I go to post a blank post it accepts it..
If anyone could point me in the right direction here that would be greatly appreciated!! Thanks in advance!!

New Topic/Question
Reply




MultiQuote






|