[SOLVED] What's the best way to check for an empty field and
Posted: Thu Jan 06, 2005 6:49 pm
Hi guys,
I'm trying to check if a field is empty when a form gets submitted. If it is, I want to stop the rest of the file processing and output an error message. What I have so far is:
Sadly, this doesn't seem to be working. I try to submit the form with nothing in the above field and it not only doesn't show an error message but the rest of the processing happens and I get the record added to the database.
What am I doing wrong? Is die() not the function to be using here? Is my method of checking the form field wrong? Am I completely barking up the wrong tree?
Any help would be greatly appreciated.
Cheers,
Seona.
I'm trying to check if a field is empty when a form gets submitted. If it is, I want to stop the rest of the file processing and output an error message. What I have so far is:
Code: Select all
<?php
import_request_variables('p', 'p_');
// if no title is entered, abort
if ($p_SectionName = "")
die("You must enter a Section Title.\nPlease go back and add a title");
?>What am I doing wrong? Is die() not the function to be using here? Is my method of checking the form field wrong? Am I completely barking up the wrong tree?
Any help would be greatly appreciated.
Cheers,
Seona.