/    Sign up×
Community /Pin to ProfileBookmark

form validate

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 = $namen address = $addressn city = $cityn state = $staten postcode = $postcoden telephone = $telephonen telephone 2 = $telephone2n email = $emailn Function day = $dayn day of month = $numbern month = $monthn year = $yearn Type of function = $typen other = $othern Name of Venue is = $venuenamen Manager or contact = $contactn Venue address and Phone number = $venueaddressn Booking times = $bookingtimen Which package to you require = $packagen Agreed fee = $Agreedfeen Special Instructions = $specialinstructionsn terms and Conditions = $termsn” , “From: $email”) ;

header( “Location: [url]http://www.djs-alive.com.au/thankyou.htm[/url]” );

?>

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@ShrineDesignsMay 24.2004 — try this:&lt;?php
if($_POST)
{
$message = "";

<i> </i>foreach($_POST as $key =&gt; $value)
<i> </i>{
<i> </i> if(empty($value))
<i> </i> {
<i> </i> exit("Error: $key is empty!n");
<i> </i> }
<i> </i> $message .= "{$key} = {$value}n";
<i> </i>}
<i> </i>if(mail("[email protected]", "djs-ALIVE function form results", $message, "From: $email"))
<i> </i>{
<i> </i> echo "Message sent!n";
<i> </i>}
<i> </i>else
<i> </i>{
<i> </i> echo "Error: Unable to send email!n";
<i> </i>}
}
?&gt;
×

Success!

Help @tane spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...