0

I create a form which use the check box to get the info from user, but don't know how to write it in php for send to my mail, did any one can help me?

my html:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>

<body>
<form action="checkbox-form.php" method="post">
    Do you need wheelchair access?
    <input type="checkbox" name="formWheelchair" value="Yes" />
 <input type="submit" name="formSubmit" value="Submit" />
</form>
</body>
</html>

Below is the php i wrote which cannot working:

<?php
if(isset($_POST['email'])) {

    // EDIT THE 2 LINES BELOW AS REQUIRED
    $email_to = "imac2011@launad.com";
    $email_subject = "Your email subject line";
    }

    if(isset($_POST['formWheelchair']) && 
    $_POST['formWheelchair'] == 'Yes') 
    {
       echo"Need wheelchair access.";
    }
    else
    {
        echo"Do not need wheelchair access.";
    }
        $email_message = "Form details below.\n\n";

        function clean_string($string) {
        $bad = array("content-type","bcc:","to:","cc:","href");
        return str_replace($bad,"",$string);
        }

    $email_message .= "Yes ".clean_string($formWheelchair)."\n";


// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers); 
?>

<!-- include your own success html here -->

Thank you for contacting us. We will be in touch with you very soon.

<?

?>

Edited by mike_2000_17: Fixed formatting

2
Contributors
2
Replies
5
Views
6 Years
Discussion Span
Last Post by shuipint
0

The only thing I see in the code you posted was that you aren't setting $email_from to anything. I seem to be missing obvious stuff tonight, though, so that might not be the problem.

David

edit: I don't see $formWheelchair being set anywhere either.

Edited by dietdew12z: n/a

0

I can't see the result of the check box i choose from the email. so this php code got a big problem.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.