Results 1 to 3 of 3

Thread: Booking Script

  1. #1
    Join Date
    Feb 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Booking Script

    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

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Sorry for the late reply, but try the following:

    Code:
    <?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.
    Last edited by thetestingsite; 02-24-2007 at 04:31 PM. Reason: Code would not have worked properly, re-written code.

  3. #3
    Join Date
    Feb 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •