Form processing cancel HELP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mcoelho123
Forum Commoner
Posts: 37
Joined: Tue Jun 06, 2006 6:27 am

Form processing cancel HELP

Post by mcoelho123 »

How can i do to cancel a form processing if a value is blank?
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

Dont call the function that process the form !
mcoelho123
Forum Commoner
Posts: 37
Joined: Tue Jun 06, 2006 6:27 am

Post by mcoelho123 »

i have this

<form action="include/mail.php" method="POST" name="Mail Send" id="sendmail">

how can i do?
GM
Forum Contributor
Posts: 365
Joined: Wed Apr 26, 2006 4:19 am
Location: Italy

Post by GM »

In mail.php just put something like:

Code: Select all

$fieldName = $_POST['fieldName'];

// if you are going to store $fieldName in a database, make sure you escape it here.

if($fieldName == "") {
 Die("The field can't be blank!");
}
...
You can also put some javascript on the client side, but don't rely on this as "validation" - javascript should be seen as something to save the user waiting for a round trip to the server.
Post Reply