SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist
    Join Date
    Feb 2005
    Posts
    452
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help returning values from a checkbox to email

    Hi, I have a page http://www.athene-hairandbeauty.co.uk/appointment.html with a number of checkboxes. What I need to do is allow the user to check the boxes and when submit is clicked the data is sent to an email address. How can I achieve this have done it before with textboxes etc., but with the checkboxes no data is passed. Think I need an array in my php, any ideas how I can achieve this. The following is code to what I used when using textboxes, hope someone can point me in the right direction. Cheers guys.

    <?
    $option = $_POST["SalonVsPrices_Key"];
    $email = $_POST["email"];
    $message = $_POST["message"];
    $date = date ("j m Y hh:mm", strtotime("now"));
    $message = $_POST["message"];
    $message = <<<EOF
    Enquiry from $name \r\n
    Email address: $email\r\n
    Made on $date\r\n
    who left the following message: \r\n
    $message

    EOF;

    $to = "enquiries@exploitation.org.uk"; // To email address
    $subject = "Enquiry from Athene Hair and Beauty Contact Page";
    $headers = 'From: $to'. "\r\n" .
    'Reply-To: $to' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();





    if(mail($to, $subject, $message, $headers))
    {
    header("Location: ContactResponse.html");
    exit;
    }
    else
    {
    echo "error in mail";
    };";

  2. #2
    SitePoint Addict
    Join Date
    Apr 2004
    Location
    Belgian in Mexico
    Posts
    307
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Checkbox data is passed only if it is checked, so you have to use something like
    PHP Code:
    $checkbox_value = isset($_POST['checkbox_name']) ? true false
    and then take action depending on the value.

    Hope that helps,

    MichaŽl
    MichaŽl Niessen
    http://assemblysys.com
    (Countries/states/cities with latitude & longitude,
    weathercodes & topical databases)


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
  •