I'm trying to complete a task. for which i need to print $message(specified below). But its not printing i don't know what seems to be the problem. i thanks for your help in advance... and i don't wanna do this echo $message thing in the html code..and one thing you should know that the values are printing before echo $message. the php variables have values in them before the echo $message, but these same variables print nothing when i echo $message.. it only prints
Customer Name:
Customer Email:
Customer Mobile:
Customer City:
Customer Billing Address:
<?php
if(isset($_POST['sub'])){
$name=$_POST['name'];
$email=$_POST['email'];
$mobile=$_POST['mobile'];
$city=$_POST['city'];
$bill_add=$_POST['message'];
echo $message="
<html><head> </head>
<body>
Customer Name: <?php echo $name; ?>
<br>
Customer Email: <?php echo $email; ?>
<br>
Customer Mobile: <?php echo $mobile; ?>
<br>
Customer City: <?php echo $city; ?>
<br>
Customer Billing Address: <?php echo .$bill_add; ?>
</body></html>";}
?>
HTML file:
<html>
<body>
<form id="contact_form" action="#" method="POST"
enctype="multipart/form-data" style=" padding-left: 121px;">
<div class="row">
<label for="name" style=" margin-left: 9px;">Your name:</label><br />
<input id="name" class="input" name="name" type="text" value=""
size="30" required/><br />
</div>
</br>
<div class="row">
<label for="email" style=" margin-left: 9px;">Your email:</label><br
/>
<input id="email" class="input" name="email" type="text" value=""
size="30" required/><br />
</div>
</br>
<div class="row">
<label for="email" style=" margin-left: 9px;">Mobile #:</label><br />
<input id="email" class="input" name="mobile" type="text" value=""
size="30" required/><br />
</div>
</br>
<div class="row">
<label for="email" style=" margin-left: 9px;">City:</label><br />
<input id="email" class="input" name="city" type="text" value=""
size="30" required/><br />
</div>
</br>
<div class="row">
<label for="message" style=" margin-left: 9px;">Shipping Address:
</label><br />
<textarea id="message" class="input" name="message" rows="7" cols="32"
required></textarea><br />
</div>
</br>
<div class="row">
<input name="sub" id="submit_button" type="submit" value="Order Proceed
Now" style="margin-top: 120px;background-color: green;padding:10px;
color:#FFF; "/>
</div>
</br>
</form>
</body>
</html>
change your $message to :
echo $message="
<html><head> </head>
<body>
Customer Name: $name
<br>
Customer Email: $email
<br>
Customer Mobile: $mobile
<br>
Customer City: $city
<br>
Customer Billing Address: $bill_add
</body></html>";}
?>
The problem was that you were using <?php echo into a <?php echo
Try:
<?php
if(isset($_POST['sub'])){
$name=$_POST['name'];
$email=$_POST['email'];
$mobile=$_POST['mobile'];
$city=$_POST['city'];
$bill_add=$_POST['message'];
echo "
<html><head> </head>
<body>
Customer Name: ".$name."
<br>
Customer Email: ".$email."
<br>
Customer Mobile: ".$mobile."
<br>
Customer City: ".$city."
<br>
Customer Billing Address: ".$bill_add."
</body></html>";}
?>
You cant use
so better use it like, Using concatenation in php solves your problem.
<?php
echo $message="
<html><head> </head>
<body>
Customer Name: ".$name."
<br>
Customer Email: ".$email."
<br>
Customer Mobile: ".$mobile."
<br>
Customer City: ".$city."
<br>
Customer Billing Address: ".$bill_add."
</body></html>";
?>
<?php echo $message="<html><head> </head><body>Customer Name: " . $name . " <br>Customer Email: " . $email . " <br>Customer Mobile: " . $mobile . " <br>Customer City: " . $city . "<br>Customer Billing Address: " . $bill_add . " </body></html>";?>
// we are using concatenation here ( . ) so we don't need to write and remove spaces.
Related
I am making a form for my customer to fill out when they order a product.
I am trying to make it so when they hit submit it emails the data to my email and it cc's them. The email will have styling in it. I can't figure out how to get it to put the data into the email. I am currently using PHPMailer.
Here is the php file
<?php
$FirstName = $_POST['First_Name'];
$LastName = $_POST['Last_Name'];
$Email = $_POST['Email'];
$Company = $_POST['Company'];
$dochtml = new DOMDocument();
require_once('PHPMailer/PHPMailerAutoload.php');
$mail = new PHPMailer();
$mail->isSMTP();
$mail->SetFrom('No-Reply#LDSVacuum.com');
$mail->Subject = 'Request';
$mail->AddAddress('Chase.Price#LDSVacuum.com');
$mail->AddCC($Email);
$strhtml = '
<div align="center">
<font face="arial" color="#336699" size="6">
Request
</font>
</div>
<div>
<font face="arial" color="#336699" size="5">
Customer Information
</font>
<p>
<label for="fname">
<font face="arial" color="#336699" size="4">
First Name:
</font>
</label>
<br />
<input type="text" name="fname" id="fname" size="50">
</p>
<p>
<label for="lname">
<font face="arial" color="#336699" size="4">
Last Name:
</font>
</label>
<br />
<input type="text" name="lname" id="lname" size="50">
</p>
<p>
<label for="email">
<font face="arial" color="#336699" size="4">
Email Address:
</font>
</label>
<br />
<input type="text" name="email" id="email" size="50">
</p>
<p>
<label for="company">
<font face="arial" color="#336699" size="4">
Company Name:
</font>
</label>
<br />
<input type="text" name="company" id="company"size="50">
</p>
</div>
';
$dochtml->loadHTML($strhtml);
$fname = $dochtml->getElementById('fname');
$fname->value=$FirstName;
$lname = $dochtml->getElementById('lname');
$lname->value=$LastName;
$email = $dochtml->getElementById('email');
$email->value=$Email;
$company = $dochtml->getElementById('company');
$company->value=$FirstName;
$mail->Body = $strhtml;
$mail->Send();
if(!$mail->Send()) {
echo 'Unknown Error has Occured. Please try again Later.';
echo 'Mailer error: ' . $mail->ErrorInfo;
}else {
echo 'Thank You, $FirstName . We have emailed your request to Info#LDSVacuum.com . Your email $Email has been cc to the email.';
}
?>
Here is the form
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form method="POST" name="contactform" autocomplete="off" id="nipplerequest" action="http://localhost/emailform.php">
<p>
<label for='First_Name' class="FG3" width="157">
<span class="red">
*
</span>
First Name:
</label>
<br />
<input type="text" name="First_Name" id="First_Name" class="FG2" size="50" placeholder="John">
<br />
<label for='Last_Name' class="FG3">
<span class="red">
*
</span>
Last Name:
</label>
<br />
<input type="text" name="Last_Name" class="FG2" size="50" placeholder="Johnson">
<br />
<label for='Email' class="FG3">
<span class="red">
*
</span>
Your Email Address:
</label>
<br />
<input type="text" name="Email" id="Email" class="FG2" size="50" placeholder="John_Johnson#company.com">
<br />
<label for='Company' class="FG3">
<span class="red">
*
</span>
Company Name:
</label>
<br />
<input type="text" name="Company" class="FG2" size="50" placeholder="Company Inc.">
<br />
</p>
</form>
<br />
<input type="Submit" value="Submit">
You are:
Creating a string of HTML
Creating a DOM from that string of HTML
Modifying that DOM by setting values
Emailing the original string of HTML and ignoring the DOM you generated
You need to convert the DOM back into HTML ($modified_html = $dochtml->saveHTML()) and send that instead of your original string.
The relevant form:
<script language="JavaScript" src="gen_validatorv4.js" type="text/javascript"></script>
<script src='https://www.google.com/recaptcha/api.js'></script>
<div id="contactform">
<div id="details">
<form method="POST" name="contactform" action="contact-form-handler.php">
<p>
<label for='name'>Full name *:</label><br>
<input type="text" name="name">
</p>
<p>
<label for='address'>Address *:</label><br>
<input type="text" name="address">
</p>
<p>
<label for='unit'>Unit:</label><br>
<input type="text" name="unit">
</p>
<p>
<label for='postal'>Postal code *:</label><br>
<input type="text" name="postal">
</p>
<p>
<label for='email'>Email:</label> <br>
<input type="text" name="email">
</p>
<p>
<label for='phone'>Telephone *:</label><br>
<input type="text" name="phone">
</p>
<p>
<label for='date'>Preferred pickup date* :</label> <br>
<input type="date" name="date">
</p>
<p>
<label for='time'>Preferred timeslot* :</label><br>
<span id="small">Please provide us with a 2 Hr time slot<br> (10% discount if we don't make it in time <strong>after we agreed</strong> on a timeslot</span><br>
<input type="text" name="time1"> to <input type="text" name="time2">
</p>
</div>
<div id="products">
<p><label for='itemsharp'>Items for sharpening:</label><br>
<textarea name="itemsharp"></textarea>
</p>
<p>
<label for='itemrepair'>Items for repair:</label><br>
<textarea name="itemrepair"></textarea>
</p>
<p>
<label for='comment'>Comment: </label><br>
<textarea name="comment"></textarea>
</p>
<div class="g-recaptcha" data-sitekey="[mysitekey]" data-theme="dark"></div>
<input class="button" type="submit" value="Submit"><br>
</form>
</div>
</div>
The php:
<?php
$errors = '';
$myemail = '[aperfectlyvalidemailadress]';//<-----Put Your email address here.
if(empty($_POST['name']) ||
empty($_POST['email']) ||
empty($_POST['address']) ||
empty($_POST['postal']) ||
empty($_POST['date']) ||
empty($_POST['time1']) ||
empty($_POST['time2']) ||
empty($_POST['phone']))
{
$errors .= "\n Error: fields with a * are required";
}
$name = $_POST['name'];
$email_address = $_POST['email'];
$address = $_POST['address'];
$postal = $_POST['postal'];
if(!empty($_POST['unit'])){
$unit = $_POST['unit'];
}
$phone = $_POST['phone'];
$date = $_POST['date'];
$time1 = $_POST['time1'];
$time2 = $_POST['time2'];
$itemsharp = $_POST['itemsharp'];
$itemrepair = $_POST['itemrepair'];
$comment = $_POST['comment'];
if (!preg_match(
"/^[_a-z0-9-]+(\.[_a-z0-9-]+)*#[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i",
$email_address))
{
$errors .= "\n Error: Please provide a valid email address";
}
$captcha;
if(isset($_POST['g-recaptcha-response'])){
$captcha=$_POST['g-recaptcha-response'];
}
if(!$captcha){
echo '<h2>Please check the captcha form.</h2>';
exit;
}
$secretKey = "[mysecretkeyisfilledinhere]";
$ip = $_SERVER['REMOTE_ADDR'];
$response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$secretKey."&response=".$captcha."&remoteip=".$ip);
$responseKeys = json_decode($response,true);
if(intval($responseKeys["success"]) !== 1) {
echo '<h2>You are spammer ! Get the #$%K out</h2>';
} else {
if( empty($errors))
{
$to = $myemail;
$email_subject = "Sharpening request: $name";
$email_body = "You have received a new sharpening request. ".
"From:\n Name: $name \n Email: $email_address \n Phone: $phone \n Address: $address $unit $postal \n \n Date: $date \n Between: $time1 and $time2 \n Items for sharpening: $itemsharp \n Items for repair: $itemrepair \n Comment: \n $comment ";
$headers = "From: request#sharpsteel.ca\n";
$headers .= "Reply-To: $email_address";
mail($to,$email_subject,$email_body,$headers);
//redirect to the 'thank you' page
header('Location: requestthankyou.html');
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Request failed</title>
</head>
<body>
<!-- This page is displayed only if there is some error -->
<?php
echo nl2br($errors);
?>
</body>
</html>
Most of this is cobbled together from various sources. My php is not that strong.
I tested it when I first created it, it worked fine.
Now the site is live and.... nothing. Any attempt to submit the form leads to the "please check the captcha" error page. I didn't change a thing, which is why I'm getting a touch frustrated.
I've obscured the email address and secret key here, for obvious reasons.
I have looked at other questions but they're either not relevant (using different and unfamiliar to me languages) or I simply don't understand for which I do apologise.
Any help would be much appreciated.
There were definite markup issues with the html form- there were div tags breaking the form.
The markup below appears identical but rest assured the prder of the form and div tags has changed to ensure the form is vald.
<script language="JavaScript" src="gen_validatorv4.js" type="text/javascript"></script>
<script src='https://www.google.com/recaptcha/api.js'></script>
<div id="contactform">
<form method="POST" name="contactform" action="contact-form-handler.php">
<div id="details">
<p>
<label for='name'>Full name *:</label>
<br>
<input type="text" name="name">
</p>
<p>
<label for='address'>Address *:</label>
<br>
<input type="text" name="address">
</p>
<p>
<label for='unit'>Unit:</label>
<br>
<input type="text" name="unit">
</p>
<p>
<label for='postal'>Postal code *:</label>
<br>
<input type="text" name="postal">
</p>
<p>
<label for='email'>Email:</label>
<br>
<input type="text" name="email">
</p>
<p>
<label for='phone'>Telephone *:</label>
<br>
<input type="text" name="phone">
</p>
<p>
<label for='date'>Preferred pickup date* :</label>
<br>
<input type="date" name="date">
</p>
<p>
<label for='time'>Preferred timeslot* :</label>
<br>
<span id="small">Please provide us with a 2 Hr time slot<br> (10% discount if we don't make it in time <strong>after we agreed</strong> on a timeslot</span>
<br>
<input type="text" name="time1"> to
<input type="text" name="time2">
</p>
</div>
<div id="products">
<p>
<label for='itemsharp'>Items for sharpening:</label>
<br>
<textarea name="itemsharp"></textarea>
</p>
<p>
<label for='itemrepair'>Items for repair:</label>
<br>
<textarea name="itemrepair"></textarea>
</p>
<p>
<label for='comment'>Comment: </label>
<br>
<textarea name="comment"></textarea>
</p>
<div class="g-recaptcha" data-sitekey="[mysitekey]" data-theme="dark"></div>
<input class="button" type="submit" value="Submit">
<br>
</div>
</form>
</div>
Problems (only after hitting submit)
The email is not displaying the html form or its results, it's only sending the number "1" in multiple emails
The form results are displaying on the next page (need to send to other page)
I have a form on my website and I wanted to send the results from that form to my email. However, I want the results to be in the same format that the form was in. So I'm not familiar with php and I researched how to send an email and I got that working. After looking at it I realized that it would be much easier to read the form information if it was in a form. I copied and pasted the html over to the php and put it all inside of the print tag. I went further and inserted readonly tags inside of the inputs on the form before I inserted placeholder tags to display the form results. The issue I'm having is that when I hit submit the form is displayed on the next page and the email I receive only has the number 1 inside of the email body...and I get several emails at once with the same message.
Extra:
1.The php code is below, I only put placeholders on the first three inputs because I just needed a couple inputs to test if the script worked.
2.The original html form(not below) has "name" tags so the results I enter are displaying when I hit submit.
3.If you read the code you only need to pay attention to the first three inputs, all the rest are there for a visual purpose. Later on I wanted to see how much of the form I could put inside of the email and how much styling as well.
<?php
$to = 'anyemail#email.com';
$subject = "New Mortgage Form ($name)";
$message = Print'
<form>
<div id="AppInfo">
<br>
<span style="text-decoration: underline; font-size: 1.2em;">Applicant Information</span> <br><br>
Name: <input type="text" title="name" placeholder="' .$_POST['name'] . '" readonly> <br> <br>
Address: <input type="text" title="address" placeholder="' .$_POST['address'] . '" readonly> <br> <br>
Rent/Own: <input type="text" title="rentown" placeholder="' .$_POST['rentown'] . '" readonly> <br><br>
How Long: <input type="text" title="length" readonly> <br><br>
Prior Address: <input type="text" title="prior" readonly> <br><br>
DOB: <input type="text" title="dob" readonly> <br><br>
Marital Status: <input type="text" title="marital" readonly> <br><br>
SSN: <input type="number" title="estValue" readonly> <br><br>
Home:<input type="tel" title="home" readonly> <br><br>
Cell: <input type="tel" title="cell" readonly> <br><br>
Employer: <input type="text" title="emp" readonly> <br><br>
Position: <input type="text" title="empPosition" readonly> <br><br>
Address: <input type="text" title="empAddress" readonly> <br><br>
Monthly Salary: <input type="number" title="empSalary" readonly> <br><br>
Date Hired: <input type="date" title="empHired" readonly> <br><br>
Commission, Overtime, Child Support, etc: <br>
    <input type="text" title="c.o.c.e" readonly> <br><br>
Wk <input type="number" title="work" readonly> <br><br>
Fax <input type="number" title="fax" readonly> <br><br>
Self Employed:   Yes<input type="checkbox" title="seYes" readonly>    No<input type="checkbox" title="seNo" readonly> <br><br>
How Long: <input type="text" title="seLength" readonly> <br><br>
</div>
<br><br><br>
<div id="MoDebt">
<span style="text-decoration: underline; font-size: 1.2em;">Monthly Debts</span>
     
<br><br>
Rent/Mortgage Payment: <input type="text" title="Rent or Mortgage Payment Amount Monthly"> <br> <br>
Car Payment: <input type="text" title="Car Payment Amount Monthly"> <br> <br>
Make/Model/Year: <input type="text" title="Make of car/Model of car/Year of car"> <br><br>
Student Loans: <input type="text" title="Student Loans Amount Monthly"> <br><br>
Credit Cards: <input type="text" title="Credit Cards Amount Monthly"> <br><br>
Child Support: <input type="text" title="Child Support Amount Monthly"> <br><br>
Other: <input type="text" title="Other Debt Amounts Monthly"> <br><br>
</div>';
// send email
mail($to, $subject, $message);
?>
Problem 1:
You are actually setting the $message variable to the result of the Print ''; call which always returns a 1, which will be sent as your message.
Second problem is due to the same print call too.
You should try this I mean :
<?php
$to = 'anyemail#email.com';
$subject = "New Mortgage Form ($name)";
$message = '
<form>
<div id="AppInfo">
<br>
<span style="text-decoration: underline; font-size: 1.2em;">Applicant Information</span> <br><br>
Name: <input type="text" title="name" placeholder="' .$_POST['name'] . '" readonly> <br> <br>
Address: <input type="text" title="address" placeholder="' .$_POST['address'] . '" readonly> <br> <br>
Rent/Own: <input type="text" title="rentown" placeholder="' .$_POST['rentown'] . '" readonly> <br><br>
How Long: <input type="text" title="length" readonly> <br><br>
Prior Address: <input type="text" title="prior" readonly> <br><br>
DOB: <input type="text" title="dob" readonly> <br><br>
Marital Status: <input type="text" title="marital" readonly> <br><br>
SSN: <input type="number" title="estValue" readonly> <br><br>
Home:<input type="tel" title="home" readonly> <br><br>
Cell: <input type="tel" title="cell" readonly> <br><br>
Employer: <input type="text" title="emp" readonly> <br><br>
Position: <input type="text" title="empPosition" readonly> <br><br>
Address: <input type="text" title="empAddress" readonly> <br><br>
Monthly Salary: <input type="number" title="empSalary" readonly> <br><br>
Date Hired: <input type="date" title="empHired" readonly> <br><br>
Commission, Overtime, Child Support, etc: <br>
    <input type="text" title="c.o.c.e" readonly> <br><br>
Wk <input type="number" title="work" readonly> <br><br>
Fax <input type="number" title="fax" readonly> <br><br>
Self Employed:   Yes<input type="checkbox" title="seYes" readonly>    No<input type="checkbox" title="seNo" readonly> <br><br>
How Long: <input type="text" title="seLength" readonly> <br><br>
</div>
<br><br><br>
<div id="MoDebt">
<span style="text-decoration: underline; font-size: 1.2em;">Monthly Debts</span>
     
<br><br>
Rent/Mortgage Payment: <input type="text" title="Rent or Mortgage Payment Amount Monthly"> <br> <br>
Car Payment: <input type="text" title="Car Payment Amount Monthly"> <br> <br>
Make/Model/Year: <input type="text" title="Make of car/Model of car/Year of car"> <br><br>
Student Loans: <input type="text" title="Student Loans Amount Monthly"> <br><br>
Credit Cards: <input type="text" title="Credit Cards Amount Monthly"> <br><br>
Child Support: <input type="text" title="Child Support Amount Monthly"> <br><br>
Other: <input type="text" title="Other Debt Amounts Monthly"> <br><br>
</div>';
// send email
mail($to, $subject, $message);
?>
You need set Content-type: text/html to header email. http://php.net/manual/en/function.mail.php
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'To: Mary <mary#example.com>, Kelly <kelly#example.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <birthday#example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive#example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck#example.com' . "\r\n";
mail($to,$subject,$message,$headers)
I am using a custom optin page with a form , While testing and in work,When I submit the form I get all the details on my email except the phone number , I do not see any problem with the codes , I tried diff things like changing the value and stuff but it did not work, Here is the form code
<div class="form fix ">
<p class="form-text">Fill This Out and See Your <br>Timeshare Report</p>
<form name="contactform" action="mail-script.php" method="POST">
<label for="fname">First Name:
<input type="text" name="fname" id="fname" />
</label><br>
<label for="lname">Last Name:
<input type="text" name="lname" id="lname" />
</label><br>
<label for="email">Email Address:
<input type="text" name="email" id="email" />
</label><br>
<label for="phone">Phone Number:
<input type="text" name="phone" id="phone" />
</label><br>
<label for="phone">Alternate Phone:
<input type="text" name="phone" id="aphone" />
</label><br>
<label for="resort">Resort Name:
<input type="text" name="resort" id="resort" />
</label><br>
<label for="amount">Amount Owed? $:
<input type="number" name="amount" id="amount" />
<p style="font-size: 12px !important;margin-top: -14px;padding-right: 30px;text-align:right;">
If Paid Off Leave Zero, Else Put Amount</p>
</label><br>
<div class="checkbox">
<div class="check-text fix">
<p>I'm Considering To</p>
</div>
<div class="check-one fix">
<input type="checkbox" name="call" id="" value="sell"/> Sell It <br>
<input type="checkbox" name="call" id="" value="buy"/> Buy It <br>
<input type="checkbox" name="call" id="" value="rent "/> Rent It
</div>
<div class="check-two fix">
<input type="checkbox" name="call" id="" value="cancel"/> Cancel Mortgage <br>
<input type="checkbox" name="call" id="" value="ownership"/> End Ownership <br>
<input type="checkbox" name="call" id="" value="give"/> Give It Back
</div>
</div>
<p class="captcha">
<img src="captcha_code_file.php?rand=<?php echo rand(); ?>" id='captchaimg' ><br>
<label for='message'>Enter the code above here :</label><br>
<input id="6_letters_code" name="6_letters_code" type="text"><br>
<small>Can't read the image? click <a href='javascript: refreshCaptcha();'>here</a> to refresh</small>
</p>
<input id="submit" type="submit" value="" />
<p class="submit-text">Ensure all fields are completed and correct, allowing you more benefits, while preventing abuse of our data.</p>
</form>
</div>
</div>
This is the mail script which sends me the email
<?php
/* Set e-mail recipient */
$myemail = "**MYEMAIL**";
/* Check all form inputs using check_input function */
$fname = check_input($_POST['fname'], "Enter your first name");
$lname = check_input($_POST['lname'], "Enter your last name");
$email = check_input($_POST['email']);
$phone = check_input($_POST['phone']);
$resort = check_input($_POST['resort']);
$amount = check_input($_POST['amount']);
$call = check_input($_POST['call']);
/* If e-mail is not valid show error message */
if (!preg_match("/([\w\-]+\#[\w\-]+\.[\w\-]+)/", $email))
{
show_error("E-mail address not valid");
}
/* If URL is not valid set $website to empty */
if (!preg_match("/^(https?:\/\/+[\w\-]+\.[\w\-]+)/i", $website))
{
$website = '';
}
/* Let's prepare the message for the e-mail */
$message = "Hello!
Your contact form has been submitted by:
First Name : $fname
Last Name : $lname
E-mail: $email
Phone : $phone
Resort: $resort
Amount: $amount
Call : $call
End of message
";
/* Send the message using mail() function */
mail($myemail, $subject, $message);
/* Redirect visitor to the thank you page */
header('Location: index.html');
exit();
/* Functions we used */
function check_input($data, $problem='')
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
if ($problem && strlen($data) == 0)
{
show_error($problem);
}
return $data;
}
function show_error($myError)
{
?>
if (strtolower($_POST['code']) != 'mycode') {die('Wrong access code');}
<html>
<body>
<b>Please correct the following error:</b><br />
<?php echo $myError; ?>
</body>
</html>
<?php
exit();
}
?>
Here is the online url of the page
http://timesharesgroup.com/sell/index.html
You have two form elements with the same name. The second one overwrites the first one and you never receive it. You also forget your alternate phone number in your PHP code.
<label for="phone">Phone Number:
<input type="text" name="phone" id="phone" />
</label><br>
<label for="phone">Alternate Phone:
<input type="text" name="altphone" id="aphone" />
</label><br>
Your PHP:
$phone = check_input($_POST['phone']);
$altphone = check_input($_POST['altphone']);
Phone : $phone
Alt Phone : $altphone
Resort: $resort
Your alternative phone number is overwriting your phone number:
<label for="phone">Phone Number:
<input type="text" name="phone" id="phone" />
</label><br>
<label for="phone">Alternate Phone:
<input type="text" name="phone" id="aphone" />
^^^^^ here
</label><br>
Changing the name for the alternative number should fix that.
so i finally got my feedback form to be working and sending emails to my email address but i have another problem. The content of the forms are not showing, don't know what is wrong. I'm new to php tho so i'm very sure its simple.. posted the code below
<?php
$name = $_POST ['name'];
$mail = $_POST ['mail'];
$number = $_POST ['number'];
$feedback = $_POST ['feedback'];
$to = 'ATotallyRandom#Email.net';
$subject = 'Feedback from atetaconsult.com';
$msg = "Your name: $name\n" .
" Your email: $email\n" .
" Feedback: $feedback\n";
mail ($to, $subject, $msg, 'From:' . $email);
echo ' thank you <br/>';
echo ' your name ' .$name .'<br/>';
echo ' Your email ' . $email .'<br/>';
echo ' Your feedback ' . $feedback . '<br/>';
?>
The HTML code for the form is below too
<form method="post" action="send.php">
<p class="head" style="font-style: italic; color: #fff; line-height: 24px; font-size: 19px; margin-bottom: 47px; margin-top: 20px; font-family: Lato, sans-serif;">
We’d love to hear from you. Interested in working together? Fill out the form below with some info about your project and I will get back to you as soon as I can. Please allow a couple days for me to respond.</p>
<div class="row form">
<input id="name" class="name" type="text" placeholder="Name">
<input id="mail" class="mail" type="text" placeholder="Email">
<input id="number" class="phone" type="text" placeholder="Phone">
</div>
<div class="span6 box box_r">
<textarea id="feedback" rows="6" class="span6" placeholder="Type a message here..."></textarea>
</div>
<div class="btn" style="margin-top:5px;">
<input type="submit" value="Send your message">
</div>
</form><div style="clear: both;"></div>
Here:
$msg = "Your name: $name\n" .
" Your email: $email\n" .
" Feedback: $feedback\n";
you are asking for the variable $email
but you have specified it as $mail at the top.
See: http://markpetherbridge.co.uk/StackOverflow/phpmail.php?name=Mark&mail=test#test.com&feedback=testfeedback
I have changed it to $email and the type to $_GET for demonstration purposes, but it seems to be working. Try that.
Here is the Full code for the file:
<?php
$name = $_GET ['name'];
$email = $_GET ['mail'];
$number = $_GET ['number'];
$feedback = $_GET ['feedback'];
$to = 'ATotallyRandom#Email.net';
$subject = 'Test from Mark P';
$msg = "Your name: $name\n";
$msg .= " Your email: $email\n";
$msg .= " Feedback: $feedback\n";
mail ($to, $subject, $msg, 'From:' . $email);
echo ' thank you <br/>';
echo ' your name ' .$name .'<br/>';
echo ' Your email ' . $email .'<br/>';
echo ' Your feedback ' . $feedback . '<br/>';
?>
<br /><br />
Here is the result from $msg: <br /><br />
<?php
echo $msg;
?>
You need to add name into your html:
<input name="name" id="name" class="name" type="text" placeholder="Name">
<input name="mail" id="mail" class="mail" type="text" placeholder="Email">
<input name="number" id="number" class="phone" type="text" placeholder="Phone">
Put all these code in between:
if($_POST){
// Your coding
}
Also show me the Javascript/Jquery coding you are using on contact form.
You haven't set a name value on the input.
Change in:
<form method="post" action="send.php">
<p class="head" style="font-style: italic; color: #fff; line-height: 24px; font-size: 19px; margin-bottom: 47px; margin-top: 20px; font-family: Lato, sans-serif;">
We’d love to hear from you. Interested in working together? Fill out the form below with some info about your project and I will get back to you as soon as I can. Please allow a couple days for me to respond.</p>
<div class="row form">
<input name="name" id="name" class="name" type="text" placeholder="Name">
<input name="mail" id="mail" class="mail" type="text" placeholder="Email">
<input name="number" id="number" class="phone" type="text" placeholder="Phone">
</div>
<div class="span6 box box_r">
<textarea name="feedback" id="feedback" rows="6" class="span6" placeholder="Type a message here..."></textarea>
</div>
<div class="btn" style="margin-top:5px;">
<input type="submit" value="Send your message">
</div>
</form><div style="clear: both;"></div>