Can some help me with the form on this page: http://riccipsych.com/referrals.php? The form fields are not being passed to the form handler: http://riccipsych.com/sendmail.php. I'm getting an email from my form with all the form labels but, the fields are blank.
Here's the code for each page:
referrals.php
<p><?php
$ipi = getenv("REMOTE_ADDR");
$httprefi = getenv ("HTTP_REFERER");
$httpagenti = getenv ("HTTP_USER_AGENT");
?>
<input type="hidden" name="ip" value="<?php echo $ipi ?>" />
<input type="hidden" name="httpref" value="<?php echo $httprefi ?>" />
<input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" /></p>
<form method="post" action="sendmail.php">
<h3>Client Information:</h3>
<label for="attn" class="label">Referral To:</label>
<select id="attn" name="select">
<option value="General">General</option>
<option value="Dr. Tammie Ricci, C.Psych.">Dr. Tammie Ricci, C.Psych.</option>
<option value="Dr. Paul Mendella, C.Psych.">Dr. Paul Mendella, C.Psych.</option>
<option value="Dr. Paul Roy, Psychiatrist">Dr. Paul Roy, Psychiatrist</option>
</select>
<br />
<label for="cname" class="label">Client Name:</label>
<input id="cname" type="text" name="textfield" maxlength="60">
<br />
<label for="caddress" class="label">Client Address:</label>
<input id="caddress" type="text" name="textfield" maxlength="60">
<br />
<label for="ccity" class="label">Client City:</label>
<input id="ccity" type="text" name="textfield" maxlength="50">
<br />
<label for="cprovince" class="label">Client Province:</label>
<select id="cprovince" name="select">
<option value="NFLD">NFLD </option>
<option value="NS">NS </option>
<option value="PEI">PEI </option>
<option value="NB">NB </option>
<option value="PQ">PQ </option>
<option value="ON">ONT </option>
<option value="MAN">MAN </option>
<option value="SASK">SASK </option>
<option value="ALTA">ALTA </option>
<option value="BC">BC </option>
<option value="YT">YT </option>
<option value="NWT">NWT </option>
<option value="NVT">NVT </option>
</select>
<br />
<label for="cpcode" class="label">Client Postal Code:</label>
<input id="cpcode" type="text" name="textfield" maxlength="7">
<br />
<label for="chphone" class="label">Client Home Phone:</label>
<input id="chphone" type="text" name="textfield" maxlength="15">
<br />
<label for="cwphone" class="label">Client Work Phone:</label>
<input id="cwphone" type="text" name="textfield" maxlength="15">
<br />
<label for="ccphone" class="label">Client Cell Phone:</label>
<input id="ccphone" type="text" name="textfield" maxlength="15">
<br />
<label for="cdob" class="label">Client Date of Birth</label>
<input id="cdob" type="text" name="textfield" maxlength="20">
<br />
<label for="chmessage" class="label">Can we leave a message at the client's home?</label>
<select id="chmessage" name="select">
<option value="Yes">Yes </option>
<option value="No">No </option>
</select>
<br />
<label for="cwmessage" class="label">Can we leave a message at the client's workplace?</label>
<select id="cwmessage" name="select">
<option value="Yes">Yes </option>
<option value="No">No </option>
</select>
<br />
<br />
<h3>Referral Information</h3>
<label for="rname" class="label">Referral Name:</label>
<input id="rname" type="text" name="textfield" maxlength="60">
<br />
<label for="raddress" class="label">Referral Address:</label>
<input id="raddress" type="text" name="textfield" maxlength="60">
<br />
<label for="rcity" class="label">Referral City:</label>
<input id="rcity" type="text" name="textfield" maxlength="50">
<br />
<label for="rprovince" class="label">Referral Province:</label>
<select id="rprovince" name="select">
<option value="NFLD">NFLD </option>
<option value="NS">NS </option>
<option value="PEI">PEI </option>
<option value="NB">NB </option>
<option value="PQ">PQ </option>
<option value="ON">ONT </option>
<option value="MAN">MAN </option>
<option value="SASK">SASK </option>
<option value="ALTA">ALTA </option>
<option value="BC">BC </option>
<option value="YT">YT </option>
<option value="NWT">NWT </option>
<option value="NVT">NVT </option>
</select>
<br />
<label for="rpcode" class="label">Referral Postal Code:</label>
<input id="rpcode" type="text" name="textfield" maxlength="7">
<br />
<label for="rwphone" class="label">Referral Work Phone:</label>
<input id="rwphone" type="text" name="textfield" maxlength="15">
<br />
<label for="remail" class="label">Referral E-Mail:</label>
<input id="remail" type="text" name="textfield" maxlength="80">
<br />
<label for="notes" class="label">Notes:</label>
<textarea id="notes" style="width: 300px; height: 150px;" name="textarea"></textarea>
<br />
<br />
<p><input type="submit" value="Send Form" /></p>
sendmail.php
<?php
if(!$remail == "" && (!strstr($remail,"#") || !strstr($remail,".")))
{
echo "<h2>Use Back - Enter valid e-mail</h2>\n";
$badinput = "<h2>Feedback was NOT submitted</h2>\n";
echo $badinput;
}
if(empty($rname) || empty($remail) || empty($cname )) {
echo "<h2>Use Back - fill in all fields</h2>\n";
}
$todayis = date("l, F j, Y, g:i a") ;
$attn = $attn ;
$subject = $attn;
$notes = stripcslashes($notes);
$message = " $todayis [EST] \n
Referral To: $attn \n
Client Name: $cname \n
Client Address: $caddress \n
Client City: $ccity \n
Client Province: $cprovince \n
Client Postal Code: $cpcode \n
Client Home Phone: $chphone \n
Client Work Phone: $cwphone \n
Client Cell Phone: $ccphone \n
Client Date of Birth: $cdob \n
Leave Message at Client's Home: $chmessage \n
Leave Message at Client's Workplace: $chmessage \n
Referral Name: $rname \n
Referral Address: $raddress \n
Referral City: $rcity \n
Referral Province: $rprovince \n
Referral Postal Code: $rpcode \n
Referral Work Phone: $rwphone \n
Referral Email: $remail \n
Notes: $notes \n
From: $rname ($remail)\n
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n
";
$from = "From: $remail\r\n";
mail("info#riccipsych.com", $subject, $message, $from);
?>
<h1>Thank You</h1>
<p>Thank you for submitting your referral. We will contact you shortly.</p>
It is still not working. I changed sendmail.php to sendeail.php and added:
<?php
$ip = $_POST['ip'];
$httpref = $_POST['httpref'];
$httpagent = $_POST['httpagent'];
$attn = $_POST['attn'];
$cname = $_POST['cname'];
$caddress = $_POST['caddress'];
$ccity = $_POST['ccity'];
$cprovince = $_POST['cprovince'];
$cpcode = $_POST['cpcode'];
$chphone = $_POST['chphone'];
$cwphone = $_POST['cwphone'];
$ccphone = $_POST['ccphone'];
$cdob = $_POST['cdob'];
$chmessage = $_POST['chmessage'];
$cwmessage = $_POST['cwmessage'];
$rname = $_POST['rname'];
$raddress = $_POST['raddress'];
$rcity = $_POST['rcity'];
$rprovince = $_POST['rprovince'];
$rpcode = $_POST['rpcode'];
$rwphone = $_POST['rwphone'];
$remail = $_POST['remail'];
$notes = $_POST['notes'];
if(!$remail == "" && (!strstr($remail,"#") || !strstr($remail,".")))
{
echo "<h2>Use Back - Enter valid e-mail</h2>\n";
$badinput = "<h2>Feedback was NOT submitted</h2>\n";
echo $badinput;
}
if(empty($rname) || empty($remail) || empty($cname )) {
echo "<h2>Use Back - fill in all fields</h2>\n";
}
$todayis = date("l, F j, Y, g:i a") ;
$attn = $attn ;
$subject = $attn;
$notes = stripcslashes($notes);
$message = " $todayis [EST] \n
Referral To: $attn \n
Client Name: $cname \n
Client Address: $caddress \n
Client City: $ccity \n
Client Province: $cprovince \n
Client Postal Code: $cpcode \n
Client Home Phone: $chphone \n
Client Work Phone: $cwphone \n
Client Cell Phone: $ccphone \n
Client Date of Birth: $cdob \n
Leave Message at Client's Home: $chmessage \n
Leave Message at Client's Workplace: $chmessage \n
Referral Name: $rname \n
Referral Address: $raddress \n
Referral City: $rcity \n
Referral Province: $rprovince \n
Referral Postal Code: $rpcode \n
Referral Work Phone: $rwphone \n
Referral Email: $remail \n
Notes: $notes \n
From: $rname ($remail)\n
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n
";
$from = "From: $remail\r\n";
mail("info#riccipsych.com", $subject, $message, $from);
?>
<h1>Thank You</h1>
<p>Thank you for submitting your referral. We will contact you shortly.</p>
You need to define your variables in sendmail.php with $_POST or $_REQUEST:
$remail = $_REQUEST['remail'];
To see what variables you have, you can also use the following code on sendmail.php
foreach($_REQUEST as $k => $v)
echo "$k = $v\n";
Related
This question already has answers here:
PHP code is not being executed, but the code shows in the browser source code
(35 answers)
Closed 4 years ago.
I'm still stuck on this PHP code. I'm trying to code it where the user inputs some information and the PHP code displays the information the user inputted it. Basically I'm trying to build a confirmation page so the user sees the information inputted before submitted it.
HTML
<DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>DormAngel Booking Form</title>
</head>
<body>
<form action="welcome.php" method="POST">
<fieldset>
<legend> Personal Details: </legend>
<label for="fname>"></label>
<input type="text" name="Name" id="fname" required autofocus placeholder="First Name" pattern="[a-zA-Z]{3,}" title="Please enter more than three letters">
<label for="lname>"></label>
<input type="text" name="Last Name" id="lname" required autofocus placeholder="Last Name" pattern="[a-zA-Z]{3,}" title="Please enter more than three letters">
<label for="email">Email: </label>
<input type="text" name="email" id="email" required placeholder="Your school email" pattern="[a-zA-Z]{3,}#[a-zA-Z]{3,}[.]{1}[a-zA-Z{2} title="Please enter a valid email address>
<label for="phone">Phone: </label>
<input type="tel" name="phone" id="phone" required placeholder="Please enter in your phone number">
<select name="country" required>
<option value=""> </option>
<option value="US">US</option>
<option value="UK">UK</option>
<option value="AUS">AUS</option>
</select>
</fieldset>
<br>
<fieldset>
<legend> Booking Details: </legend>
<input type="date" name="date" min="2018-10-07" max="2018-10-31">
<input type=time min=9:00 max=17:00 step=900>
<br>
<br>
<label for="dorm">Dormitory: </label>
<br>
<select name="dorm" required>Dormitory
<option value="Cypress">Cypress Hall</option>
</select>
<br>
<br>
<label for="floor">Floor: </label>
<br>
<select name="floor" required>Floor:
<option value=""></option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
</select>
<br>
<br>
<label for="roomnumber">Room Number: </label>
<br>
<select name="roomnumber">Room Number:
<option value=""></option>
<option value="22">22</option>
</select>
<br>
<br>
<label for="roomletter">Room Letter: </label>
<br>
<select name="roomletter" required="">Room Letter
<option value=""></option>
<option value="A">A</option>
<option value="B"> B</option>
</select>
<button type="submit">Submit</button>
</fieldset>
</form>
</body>
</html>
PHP
<html>
<head>
<title>Confirmation Page of Web Form</title>
</head>
<h1>Confirmation Page of Customer Info</h1>
<p>Thank you for submitting this form.</p>
<p>We have successfully received it.</p>
<p>Below is a summary of the information you provided.<br><br>
<?php
echo 'First Name: ' . $_POST ["Name"] . '<br>';
echo 'Last Name: ' . $_POST ["Last Name"] . '<br>';
echo 'Email Address: ' . $_POST ["email"] . '<br>';
echo 'Telephone Number: ' . $_POST ["phone"];
?>
</p>
</html>
What is wrong with my code?
You have forgotten the <body> tag in your html.
Replace the code to be this way.
<html>
<head>
<title>Confirmation Page of Web Form</title>
</head>
<h1>Confirmation Page of Customer Info</h1>
<p>Thank you for submitting this form.</p>
<p>We have successfully received it.</p>
<p>Below is a summary of the information you provided.<br><br>
<?php
echo 'First Name: ' . $_POST["Name"] . '<br>';
echo 'Last Name: ' . $_POST["Last Name"] . '<br>';
echo 'Email Address: ' . $_POST["email"] . '<br>';
echo 'Telephone Number: ' . $_POST["phone"];
?>
</p>
</html>
I'm working on contact form for my site, everything work good if i fill the inputs in English language but if i fill the inputs in arabic language i don't receive any emails, how i can fix this ?
this is my code :
HTML code :
<section class="body">
<form action="form.php" method="post" enctype="multipart/form-data">
<h1 class="title">Contact</h1>
<label></label>
<input name="d_name" required="required" placeholder="أسم المندوب">
<label></label>
<input name="d_phone" type="text" required="required" placeholder="رقم هاتف المندوب">
<label></label>
<input name="c_name" type="text" required="required" placeholder="أسم المشترك">
<label></label>
<input name="phonee" required="required" type="text" placeholder="رقم هاتف المشترك" />
<label></label>
<select class="dropdown-select" name="comp" required="">
<option disabled="disabled" selected="selected" value="">أختر الشركة</option>
<option value="جولان">جولان</option>
<option value="بارتنير">بارتنير</option>
<option value="بلفون">بلفون</option>
<option value="تيلزار 019">تيلزار 019</option>
</select>
<label></label>
<select name="type" required="">
<option disabled="disabled" selected="selected" value="">اختر نوع الرقم</option>
<option value="فاتورة">فاتورة</option>
<option value="كرت">كرت</option>
</select>
<label></label>
<input name="sim" required="required" type="text" placeholder="رقم الشريحة" />
<label></label>
<textarea name="message" cols="20" rows="5" required="required" placeholder="Message"></textarea>
<input id="cancel" name="cancel" value="Cancel" />
<input id="submit" name="submit" type="submit" value="Submit">
</form>
</section>
PHP code :
<?php
$name = $_POST['d_name'];
$phone = $_POST['d_phone'];
$cname = $_POST['c_name'];
$cphone = $_POST['phonee'];
$comp = $_POST['comp'];
$sim = $_POST['sim'];
$type = $_POST['type'];
$message = $_POST['message'];
$from = 'From:' . $_POST['d_name'];
$to = 'Noor_Phone#hotmail.com';
$subject = 'Email Inquiry';
$body = "Delegate Name: $name\n Delegate phone: $phone\n\n\n Customer Name: $cname\n Customer Phone: $cphone\n Line Type: $type\n Company: $comp\n Sim Number: $sim\n Message:\n $message";
?>
<?php
if ($_POST['submit']) {
if (mail ($to, $subject, $body, $from)) {
echo '<p>Thank you for your email!</p>';
} else {
echo '<p>Oops! An error occurred. Try sending your message again. </p>';
}
}
?>
Instead of using php built-in mail function, use phpmailer. This will solve your problem. Using this class you have the option to set charset:
$mail->CharSet = 'UTF-8';
For additional troubleshooting, you can
<meta charset="utf-8">
You also have the option to include charset attribute in the form tag:
<form action="form.php" method="post"
enctype="multipart/form-data" accept-charset="utf-8">
Or have a look at this old SO answer on sending arabic content in email.
Hope this may help.
Setting the Html Lang might help this situation try this
<html lang="ar">
Referenced from http://www.w3schools.com/tags/ref_language_codes.asp
thanks for helping ,this is the answer:
HTML Code:
<h1 class="title">Contact</h1>
<label></label>
<input name="d_name" required="required" placeholder="أسم المندوب">
<label></label>
<input name="d_phone" type="text" required="required" placeholder="رقم هاتف المندوب">
<label></label>
<input name="c_name" type="text" required="required" placeholder="أسم المشترك">
<label></label>
<input name="phonee" required="required" type="text" placeholder="رقم هاتف المشترك" />
<label></label>
<select class="dropdown-select" name="comp" required="">
<option disabled="disabled" selected="selected" value="">أختر الشركة</option>
<option value="جولان">جولان</option>
<option value="بارتنير">بارتنير</option>
<option value="بلفون">بلفون</option>
<option value="تيلزار 019">تيلزار 019</option>
</select>
<label></label>
<select name="type" required="">
<option disabled="disabled" selected="selected" value="">اختر نوع الرقم</option>
<option value="فاتورة">فاتورة</option>
<option value="كرت">كرت</option>
</select>
<label></label>
<input name="sim" required="required" type="text" placeholder="رقم الشريحة" />
<label></label>
<textarea name="message" cols="20" rows="5" required="required" placeholder="Message"></textarea>
<input id="cancel" name="cancel" value="Cancel" />
<input id="submit" name="submit" type="submit" value="Submit">
</form>
</section>
PHP Code:
<?php
$mail->CharSet = 'UTF-8';
$name = $_POST['d_name'];
$phone = $_POST['d_phone'];
$cname = $_POST['c_name'];
$cphone = $_POST['phonee'];
$comp = $_POST['comp'];
$sim = $_POST['sim'];
$type = $_POST['type'];
$message = $_POST['message'];
$formcontent="Delegate Name: $name\n Delegate phone: $phone\n\n\n Customer Name: $cname\n Customer Phone: $cphone\n Line Type: $type\n Company: $comp\n Sim Number: $sim\n Message:\n $message";
$recipient = "Noor_Phone#hotmail.com";
$subject = "Contact Form";
$mailheader = "From: admin#4uphone.co.il";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!" . " -" . "<a href='contact.html' style='text- decoration:none;color:#ff0099;'> Return Home</a>";
?>
I am a newbie to PHP, and I really don't know what I am doing wrong or even if what I have done is correct, but it seems working, however only the drop-down menus aren't fully working.
The $SelectThree and $SelectFour only shows the last selection... for example if you picked DropDown Option A and B... only B will show in the email... i.e:
Name: name
Number: number
Date: 10/06/2014
Select: DropdownA
Select2: DropdownA
Select3: Drop Down Option B
Select4: Drop Down Option B
Radio: female
Checkbox: OptionB
Switch: On
Email: example#example.com
Message: message
PHP:
<?php
session_start();
if ($_SERVER['REQUEST_METHOD'] == 'POST'){
ob_start();
if(isset(
$_REQUEST['name'],
$_REQUEST['email'],
$_REQUEST['message'],
$_REQUEST['number'],
$_REQUEST['date'],
$_REQUEST['select'],
$_REQUEST['selectTwo'],
$_REQUEST['selectThree'],
$_REQUEST['selectFour'],
$_REQUEST['radio'],
$_REQUEST['checkbox'],
$_REQUEST['switch'],
$_REQUEST['token'] )){
if($_SESSION['token'] != $_POST['token']){ $response = "0";
} else {
$_SESSION['token'] = "";
$name = $_REQUEST['name'];
$email = $_REQUEST['email'];
$message = $_REQUEST['message'];
$number = $_REQUEST['number'];
$date = $_REQUEST['date'];
$select = $_REQUEST['select'];
$selectTwo = $_REQUEST['selectTwo'];
$selectThree = $_REQUEST['selectThree'];
$selectFour = $_REQUEST['selectFour'];
$radio = $_REQUEST['radio'];
$checkbox = $_REQUEST['checkbox'];
$switch = $_REQUEST['switch'];
switch (true){
case !filter_var($email, FILTER_VALIDATE_EMAIL):
$response = "<p style='color:red'>Invalid Email Address!</p>";
break;
default:
$to = "support#loaidesign.co.uk";
$subject = "New Message From: $name";
$message = "Name: $name <br/>
Number: $number <br/>
Date: $date <br/>
Select: $select <br/>
Select2: $selectTwo <br/>
Select3: $selectThree <br/>
Select4: $selectFour <br/>
Radio: $radio <br/>
Checkbox: $checkbox <br/>
Switch: $switch <br/>
Email: $email <br/>
Message: $message";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
$headers .= 'From: '."support#loaidesign.co.uk" . "\r\n";
$headers .= 'Reply-To: '.$email . "\r\n";
$params = '-f support#loaidesign.co.uk';
$mailed = (mail($to, $subject, $message, $headers));
if( isset($_REQUEST['ajax'])){ $response = ($mailed) ? "1" : "0";
} else {
$response = ($mailed) ? "<h2>Success!</h2>" : "<h2>Error! There was a problem with sending.</h2>";
}
break;
}
echo $response;
}
} else {
echo "Error";
}
ob_flush();
die();
}
?>
Contact form HTML:
<!--Contact Form-->
<?php $token = md5(uniqid(rand(), TRUE)); $_SESSION['token'] = $token;?>
<form id="contactForm" class="validate" name="contactForm" action="contact.php" method="post">
<input name="token" type="hidden" value="<?php echo $token; ?>">
<input name="ajax" type="hidden" value="1">
<fieldset>
<p>Your Name</p>
<input name="name" class="name required fullname" autocomplete="off">
</fieldset>
<fieldset>
<p>Email Address</p>
<input name="email" type="email" class="email required" autocomplete="off">
</fieldset>
<fieldset>
<p>Message</p>
<textarea name="message" rows="5" class="required min3"></textarea>
</fieldset>
<fieldset>
<p>Phone Number</p>
<input name="number" class="hasIcon" autocomplete="off">
<i class="form-icon icon-phone"></i>
</fieldset>
<fieldset>
<p>Time</p>
<input name="time" class="mask-time hasIcon" autocomplete="off">
<i class="form-icon icon-clock"></i>
</fieldset>
<fieldset>
<p>Date</p>
<input name="date" class="required date calendar hasIcon" autocomplete="off">
<i class="form-icon icon-calendar"></i>
</fieldset>
<fieldset>
<p class="inline">Date Selected:</p>
<input class="selectedDate inline"></input>
</fieldset>
<fieldset>
<p>Dropdown Menu</p>
<select name="select" class="select required" data-placeholder="Choose an option">
<option value=""></option>
<option value="DropdownA">DropdownA</option>
<option value="DropdownB">DropdownB</option>
</select>
</fieldset>
<fieldset>
<p>Dropdown Menu - Searchable</p>
<select name="selectTwo" class="select-search" data-placeholder="Choose an option">
<option value=""></option>
<option value="DropdownA">DropdownA</option>
<option value="DropdownB">DropdownB</option>
</select>
</fieldset>
<fieldset>
<p>Multi Options Dropdown Menu</p>
<select name="selectThree" class="select multi-select" multiple="multiple" tabindex="-1" data-placeholder="Choose an option">
<option value=""></option>
<optgroup label="Section One">
<option>Drop Down Option A</option>
<option>Drop Down Option B</option>
</optgroup>
<optgroup label="Section Two">
<option>Drop Down Option A</option>
<option>Drop Down Option B</option>
<option>Drop Down Option C</option>
<option>Drop Down Option D</option>
</optgroup>
</select>
</fieldset>
<fieldset>
<p>Multi Options Dropdown Menu - Min 2 & Max 3</p>
<select name="selectFour" class="select multi-select" multiple="multiple" tabindex="-1" min="2" max="3">
<option value=""></option>
<option>Drop Down Option A</option>
<option>Drop Down Option B</option>
<option>Drop Down Option A</option>
<option>Drop Down Option B</option>
</select>
</fieldset>
<fieldset class="checkbox">
<p>Checkboxs:</p>
<label><input name="checkbox" type="checkbox" value="OptionA" class="required"><span class="checked-icon"><span></span></span><span>Option A</span></label>
<label><input name="checkbox" type="checkbox" value="OptionB" class="required"><span class="checked-icon"><span></span></span><span>Option B</span></label>
</fieldset>
<fieldset class="radio">
<p>Radios:</p>
<label><input name="radio" type="radio" value="male" class="required"><span class="checked-icon"><span></span></span><span>Male</span></label>
<label><input name="radio" type="radio" value="female" class="required"><span class="checked-icon"><span></span></span><span>Female</span></label>
</fieldset>
<fieldset class="switch">
<p>Switch:</p>
<label><input name="switch" type="checkbox" value="On"><span><span></span></span></label>
</fieldset>
<button id="submit" type="submit">Send</button>
</form>
To get it work, you should specify in your HTML not name="selectFour" but name="selectFour[]"
EDIT: PHP side, you can exploit the $_REQUEST['selectFour'] as an array.
EDIT: So maybe, you can use implode function http://php.net/manual/en/function.implode.php
Ok I try to get this every time but I can't I'm using xampp and thunderbird, so I tryed to make a email form so people can contact me but i have the code right but it won't send to my gmail what am I doing wrong. and need to make a activation php too so they can sign up for my website.
<form action="test1.php" method="POST">
<p>Name</p> <input type="text" name="name">
<p>Email</p> <input type="text" name="email">
<p>Phone</p> <input type="text" name="phone">
<p>Request Phone Call:</p>
Yes:<input type="checkbox" value="Yes" name="call"><br />
No:<input type="checkbox" value="No" name="call"><br />
<p>Website</p> <input type="text" name="website">
<p>Priority</p>
<select name="priority" size="1">
<option value="Low">Low</option>
<option value="Normal">Normal</option>
<option value="High">High</option>
<option value="Emergency">Emergency</option>
</select>
<br />
<p>Type</p>
<select name="type" size="1">
<option value="update">Website Update</option>
<option value="change">Information Change</option>
<option value="addition">Information Addition</option>
<option value="new">New Products</option>
</select>
<br />
<p>Message</p><textarea name="message" rows="6" cols="25"></textarea><br />
<input type="submit" value="Send"><input type="reset" value="Clear">
</form>
thats form.html and my php is test1.php
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$call = $_POST['call'];
$website = $_POST['website'];
$priority = $_POST['priority'];
$type = $_POST['type'];
$message = $_POST['message'];
$formcontent=" From: $name \n Phone: $phone \n Call Back: $call \n Website: $website \n Priority: $priority \n Type: $type \n Message: $message";
$recipient = "dstokesncstudio#gmail.com";
$subject = "Contact Form";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!" . " -" . "<a href='form.html' style='text- decoration:none;color:#ff0099;'> Return Home</a>";
?>
Are you hosting on a Linux or other Unix-like systems? If so, depending on where the server(s) where the page is hosted, you need to ensure that sendmail or postfix is actually running.
As root you can run 'mailq' (see man pages) to see if the message is being queued up but there is no daemon running that is processing it.
Also double-check your spam folder to see if it is getting tagged as such by gmail.
I am trying to add new items to a legacy sendeail.php form. However, when I add the new items to the php listing and the mail delivery, they aren't displaying at all in the email that is sent. At least the emails are going through... I know that I need to refine the radio and check box items, but NONE of the new items are showing. New items are all items after $attn in the code list immediately below. Any and all help is appreciated, thank you very much!
My PHP code is:
<?php
$ip = $_POST['ip'];
$httpref = $_POST['httpref'];
$httpagent = $_POST['httpagent'];
$visitor = $_POST['visitor'];
$visitormail = $_POST['visitormail'];
$notes = $_POST['notes'];
$attn = $_POST['attn'];
$phone = $_POST['phone'];
$interest = $_POST['interest'];
$budget = $_POST['budget'];
$budget = $_POST['day'];
$timeslot = $_POST['timeslot'];
if (eregi('http:', $notes)) {
die ("Do NOT try that! ! ");
}
if(!$visitormail == "" && (!strstr($visitormail,"#") || !strstr($visitormail,".")))
{
echo "<h2>Use Back - Enter valid e-mail</h2>\n";
$badinput = "<h2>Please complete all the fields.</h2>\n";
echo $badinput;
die ("Use the Back button on your browser...");
}
if(empty($visitor) || empty($visitormail) || empty($notes ) || empty($attn ) || empty($phone )) {
echo "<h2>Please click Back and fill in all fields.</h2>\n";
die ("Use the Back button on your browser... ");
}
$todayis = date("l, F j, Y, g:i a") ;
$attn = $attn ;
$subject = $attn;
$notes = stripcslashes($notes);
$message = " $todayis [EST] \n
Web Site Request About: $attn \n
From: $visitor ($visitormail)\n
Phone: $phone \n
Message: $notes \n
Interested In: $interest \n
Heating Budget: $budget \n
Time Availability: Days - $day \n
Time Availability: Morning or Afternoon - $timeslot \n
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n
";
$from = "From: $visitormail\r\n";
mail("XXXXX", $subject, $message, $from);
?>
And my HTML code is:
<?php
$ipi = getenv("REMOTE_ADDR");
$httprefi = getenv ("HTTP_REFERER");
$httpagenti = getenv ("HTTP_USER_AGENT");
?>
<input type="hidden" name="ip" value="<?php echo $ipi ?>" />
<input type="hidden" name="httpref" value="<?php echo $httprefi ?>" />
<input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" />
All fields are required.</p>
<p align="left">Your Name:
<input type="text" name="visitor" size="35" />
</p>
<p align="left">
Your Email:
<input type="text" name="visitormail" size="35" />
</p>
<p align="left">
<label for="Phone">Your Phone: </label>
<input type="text" name="Phone" id="Phone" size="35"/>
</span></p>
<p align="left">
About:
<select name="attn" size="1">
select name="interest" id="interest">
<option value="General Query">General question</option>
<option value="Plumbing Query">Plumbing</option>
<option value="Gasfitting Query">Gasfitting</option>
<option value="Central Heating Query">Central Heating</option>
<option value="Custom Work Query">Several options</option>
</select>
<br />
<p align="left">Your Home Heating Budget:
<select name="attn2" size="1">
select name="budget" id="budget">
<option value="Under 10000">$8000 to $10,0000</option>
<option value="10 to 12 Thousand">$10,000 to $12,000</option>
<option value="12 to 15 Thousand">$12,000 to $15,000</option>
<option value="+15000 Plus">$15,000 +</option>
</select>
<br />
<p align="left">Are you considering other forms of heating?
<input type="checkbox" name="Yes-OtherFormsHeating" id="Yes-OtherFormsHeating" />
<label for="Yes">Yes</label>
<input type="checkbox" name="No-OtherFormsHeating" id="No-OtherFormsHeating" />
<label for="No">No</label>
<br />
</p>
<p align="left">Please give us a few details about your home and requirements: <br />
<textarea name="notes" rows="6" cols="70"></textarea>
</p>
<p align="left">To give you a quote for gas central heating, we need to visit your home. What is a good day and time for us to come to you? Choose one option.</p>
<p align="left">
<input type="radio" name="day" id="day_M" value="M" />
<label for="M">M</label>
<input type="radio" name="day" id="day_T" value="T" />
<label for="T">T</label>
<input type="radio" name="day" id="day-W" value="W" />
<label for="W">W</label>
<input type="radio" name="day" id="day_Th" value="Th" />
<label for="Th">Th</label>
<input type="radio" name="day" id="day_F" value="F" />
<label for="F">F</label>
</p>
<p align="left">When is a good time on this day for us to come to you? Choose one or both.</p>
<p align="left">
<input type="checkbox" name="timeslot" id="8:30-12:30AM" />
<label for="8:30-12:30AM">8:30 - 12:30</label>
<input type="checkbox" name="timeslot" id="12:30-4" />
<label for="12:30-4">12:30 - 4:00</label>
</p>
First of all: always validate input (POST). You've got some basic validation already but read up on the security implications regarding POST data.
Array keys in php are case sensitive. $_POST['phone'] is not the same as $_POST['Phone'].
Your select tags are broken, take a look at the colouring in your posted html.
You have declared $budget twice, overwriting the intended data:
$budget = $_POST['budget'];
$budget = $_POST['day'];
checkboxes should be arrays when posted, change the name attribute to thename[] instead of just thename. Of course your php script must handle the resulting array after this change.