Log in

View Full Version : Booking Script



asonda
02-21-2007, 05:30 PM
Hello,

I have a script that collects all data thats entered into a form and then it sends it to an e-mail address.

It's done this way as my webhost has a shared secure server, where all pages are mirrored as HTTPS://,

the only problem I have is, I need to only validate one "Radio" button, in order for the customer to Accept Terms and Conditions.

In this script I downloaded, It only seems to give the option to either validate all, or none at all,

I made the actual form up in frontpage, however, frontpage extensions aren't installed on the secure server.

So how can I alter the below script, to validate the last option on my form.

<?php

// Simple Form Script
// Copyright (C) 2005 Eric Zhang
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// Please send bugs/questions to erkzh@yahoo.com.

//--------------------------Set these paramaters--------------------------


$subject = 'Booking Submission'; // Subject of email sent to you.
$emailadd = 'blah@blah blah.co.uk'; // Your email address. This is where the form information will be sent.
$url = 'http://www.urlinhere.co.uk'; // Where to redirect after form is processed.
$req = '0'; // Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty.

// --------------------------Do not edit below this line--------------------------
$text = "Results from form:\n\n";
$space = ' ';
$line = '
';
foreach ($_POST as $key => $value)
{
if ($req == '1')
{
if ($value == '')
{echo "$key is empty";die;}
}
$j = strlen($key);
if ($j >= 20)
{echo "Name of form element $key cannot be longer than 20 characters";die;}
$j = 20 - $j;
for ($i = 1; $i <= $j; $i++)
{$space .= ' ';}
$value = str_replace('\n', "$line", $value);
$conc = "{$key}:$space{$value}$line";
$text .= $conc;
$space = ' ';
}
mail($emailadd, $subject, $text, 'From: '.$emailadd.'');
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
?>

Best Regards
Jamie

thetestingsite
02-24-2007, 03:46 AM
Sorry for the late reply, but try the following:



<?php

// Simple Form Script
// Copyright (C) 2005 Eric Zhang
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// Please send bugs/questions to erkzh@yahoo.com.

//--------------------------Set these paramaters--------------------------


$subject = 'Booking Submission'; // Subject of email sent to you.
$emailadd = 'blah@blah blah.co.uk'; // Your email address. This is where the form information will be sent.
$url = 'http://www.urlinhere.co.uk'; // Where to redirect after form is processed.

$reqField = "RadioButtonName"; //the name of the field that is required.

// --------------------------Do not edit below this line--------------------------
$text = "Results from form:\n\n";
$space = ' ';
$line = '
';
foreach ($_POST as $key => $value)
{

if ($key == $reqField) {

if ($value == "") {
echo $reqField.' must be checked/selected!';
die;
}
}

$j = strlen($key);
if ($j >= 20)
{echo "Name of form element $key cannot be longer than 20 characters";die;}
$j = 20 - $j;
for ($i = 1; $i <= $j; $i++)
{$space .= ' ';}
$value = str_replace('\n', "$line", $value);
$conc = "{$key}:$space{$value}$line";
$text .= $conc;
$space = ' ';
}
mail($emailadd, $subject, $text, 'From: '.$emailadd.'');
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
?>


Simply change the name in red to the readio button/checkbox that you want selected. Hope this helps.

asonda
02-28-2007, 07:47 PM
Hey,

Thanks for the reply, I'll keep that one in mind,

I really had to get that done straight away as it was for a customer, it normally wouldn't be a poblem, but as this customer is on mates rates I had to use a cheap hosting company.

In the end, I added a Javascript that would check everything 'onSubmit' before the form info got sent to the script on the server!

Thank You

Jamie