validating a form<

liunx

Guest
i have a script in php that i use to collect info for a form and just want to know how i can validate the terms variable - so if if they dont tick it the form wont proceed and prompt the user to answer that question.....here is the script i use

<?php
$message = "name = {$_POST['name']}\n";
$message = "address = {$_POST['address']}\n";
$message = "city = {$_POST['city']}\n";
$message = "state = {$_POST['state']}\n";
$message = "postcode = {$_POST['postcode']}\n";
$message = "telephone = {$_POST['telephone']}\n";
$message = "telephone2 = {$_POST['telephone2']}\n";
$message = "email = {$_POST['email']}\n";
$message = "day = {$_POST['day']}\n";
$message = "number = {$_POST['number']}\n";
$message = "month = {$_POST['month']}\n";
$message = "year = {$_POST['year']}\n";
$message = "type = {$_POST['type']}\n";
$message = "other = {$_POST['other']}\n";
$message = "venuename = {$_POST['venuename']}\n";
$message = "contact = {$_POST['contact']}\n";
$message = "venueaddress = {$_POST['venueaddress']}\n";
$message = "bookingtime = {$_POST['bookingtime']}\n";
$message = "package = {$_POST['package']}\n";
$message = "Agreedfee = {$_POST['Agreedfee']}\n";
$message = "specialinstructions = {$_POST['specialinstructions']}\n";
$message = "terms = {$_POST['terms']}\n";


mail ( "[email protected]", "djs-ALIVE function form results", "Name = $name\n address = $address\n city = $city\n state = $state\n postcode = $postcode\n telephone = $telephone\n telephone 2 = $telephone2\n email = $email\n Function day = $day\n day of month = $number\n month = $month\n year = $year\n Type of function = $type\n other = $other\n Name of Venue is = $venuename\n Manager or contact = $contact\n Venue address and Phone number = $venueaddress\n Booking times = $bookingtime\n Which package to you require = $package\n Agreed fee = $Agreedfee\n Special Instructions = $specialinstructions\n terms and Conditions = $terms\n" , "From: $email") ;

header( "Location: <!-- m --><a class="postlink" href="http://www.djs-alive.com.au/thankyou.htm">http://www.djs-alive.com.au/thankyou.htm</a><!-- m -->" );

?>why have all the $message = stuff? it is doing nothing. you don't even use it.

to check for a variable you use aif statement.

if(!$_POST['terms']){
// show code to tell them to answer the question.
} else {
// do the mailing here
}
 
Back
Top