0

Below is the PHP mailer code (part of it):

$message = '';
$message .= <<<TEXT

First Name:
{$_POST['name']}

Last Name:
{$_POST['lastname']}

Email:    
{$_POST['email']}

Phone:
{$_POST['phone']}

Accept:
{$_POST['checkbox']}

{$checkString}
TEXT;

Html form:

<form action="sendLid.php" method="POST">
    <img src="images/ajax.gif" id="ajaxPre" alt=""/>
    <input type="text" id="name" name="name" placeholder="שם פרטי" />
    <input type="text" id="lastname" name="lastname" placeholder="שם משפחה" />
    <input type="tel" id="phone" rel="טלפון"  name="phone" placeholder="טלפון"/>
    <input type="email" id="email" rel="מייל"  name="email" placeholder="מייל"/>
    <input type="submit" id="btn" value=""/>
    <input type="checkbox" checked="checked"  id="checkbox" name="checkbox" value=""/>
</form>

All works good. The problem is with the "Accept" line on the PHP file. Of course it will not send the value of the 'checkbox'. I tried to add if(isset) but I get an error, because I don't know how to insert the if statement with the <<< TEXT.

1 Answer 1

1
<input type="checkbox" checked="checked"  id="checkbox" name="checkbox" value=""/>

remove value tag from checkbox so you can check like below

$checkbox = (isset($_POST['checkbox']))?$_POST['checkbox']:'';

$message = '';
$message .= <<<TEXT

First Name:
{$_POST['name']}

Last Name:
{$_POST['lastname']}

Email:    
{$_POST['email']}

Phone:
{$_POST['phone']}

Accept:
{$checkbox}

{$checkString}
TEXT;
Sign up to request clarification or add additional context in comments.

2 Comments

Get nothing after Accept.
then enter any value for the checkbox

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.