All I want to do is check whether or not strNewsTitle and strNewsCopy is empty. Seems easy 'nuff, right? However, the if statement below should run if the fields are empty, but it doesnt. I'll illustrate below.
Its a pretty simple setup, first a form (an abbreviated example) :
Code: Select all
<form action="add_proc.php" method="post">
<input type="text" name="strNewsTitle" size="35">
<textarea name="strNewsCopy" rows="10" cols="33">
<input type="submit" value="save">
</form>Code: Select all
<?
// cutting out the DB connection stuff
$strNewsTitle = $_POST['strNewsTitle'];
$strNewsCopy = $_POST['strNewsCopy'];
if ( $strNewsTitle == "" || $strNewsCopy == "" ) {
$_SESSION['sessionMessage'] = '<span class="error">Please fill in the title and copy fields.</span>';
header ("Location: addItem.php");
exit;
}
// lots of stuff to do if the fields arent empty
?>Code: Select all
if ( !$strNewsTitle || !$strNewsCopy ) {
$_SESSION['sessionMessage'] = '<span class="error">Please fill in the title and copy fields.</span>';
header ("Location: addItem.php");
exit;
}Code: Select all
if ( empty($strNewsTitle) || empty($strNewsCopy) ) {
$_SESSION['sessionMessage'] = '<span class="error">Please fill in the title and copy fields.</span>';
header ("Location: addItem.php");
exit;
}Thanks!