PHP form not passing values on POST - php

I have the below html form, which when the user clicks submit, it fires the php code in contactengine.php but the values are missing from the email I get and the .txt form that is generated.
<!------------------from start------------>
<form method="POST" action="contactengine.php" class="form-inline" >
<div class="form-group">
<label>Full Name*</label><br>
<input name="full_name" type="text" class="form-control" placeholder="Full Name" id="full_name" required>
</div>
<div class="form-group">
<label>Telephone *</label><br>
<input name="contact_tel" type="text" class="form-control" placeholder="Telephone" id="contact_tel" required>
</div>
<div class="form-group">
<label>Email *</label><br>
<input name="contact_email" type="email" class="form-control" placeholder="Email Address" id="contact_email" required>
</div>
<div class="form-group">
<label>Subject of Enquiry *</label><br>
<select name="sub_enquiry" class="form-control" id="sub_enquiry">
<option value="Assesments" >Assesments</option><option value="Services" >Services</option>
<option value="Inpections" >Inpections</option>
<option value="Other" >Other</option>
</select>
</div><br> <br>
<label>Your message *</label><br>
<textarea name="contact_msg" class="form-control" rows="5" id="contact_msg" required ></textarea> <br >
<br >
<button type="submit" class="btn btn-purple" ><span class="glyphicon glyphicon-envelope"></span> Submit</button>
</form>
<!----------------------php form------------------>
<?php
$to = "xxxx#gmail.com";
$Subject = "OFSUK.ORG";
$full_name = $_POST['full_name'];
$contact_email = $_POST['contact_email'];
$contact_tel = $_POST['contact_tel'];
$sub_enquiry = $_POST['sub_enquiry'];
$contact_msg = $_POST['contact_msg'];
// validation
$validationOK=true;
if (!$validationOK) {
header("location:/error.php");
exit;
}
// prepare email body text
$Body = "";
$Body .= "\n";
$Body .= "Name: ";
$Body .= $full_name;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $contact_email;
$Body .= "\n";
$Body .= "Telephone: ";
$Body .= $contact_tel;
$Body .= "\n";
$Body .= "Enquiry: ";
$Body .= $sub_enquiry;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $contact_msg;
$Body .= "\n";
// send email
$success = mail($to, $Subject, $Body);
$email_from = $full_name.'<'.$email_from.'>';
$myfile = fopen("emails.txt", "a") or die("Unable to open file!");
$txt = $Body;
fwrite($myfile, "\n". $txt);
fclose($myfile);
// redirect to success page
if ($success){
header("location:/");
}
else{
header("location:/contact-us.php");
}
?>
These two are stored in two locations but are working fine am just not getting any data.

Change <button type="submit" class="btn-purple"/>
To
<input type="submit" name="sbmt" class="btn-purple"/>
And then validate if sbmt has been set, if so print out the values

Try to use
pg_escape_string
like...
pg_escape_string($_POST['full_name']);
... to fix data passing problems.

Related

Form Submission code check

The Contact page which has form submission, https://photos.app.goo.gl/GpbWvks2Y3SjwmX58 is not being executed. I tried various solutions from other questions that's already been asked but had no luck.
The .php file is in the Contacts folder along with the Contacts/index.html page.
Some expert help would be much appreciated.
Here's the Javascript on the HTML page.
<script type="text/javascript">document.getElementById('spc').value = '755fd9ccedf916b2cd08bb7be88691dd';</script>
<form name="enquiry" method="post" action="infosemantic-enquiryform1.php" class="form" id="form">
<p class="input_field">
<label class="field">First Name:</label>
<input name="name" type="text" class="name_box" id="name" value="" size="35">
</p>
<p class="input_field">
<label class="field">Last Name:</label>
<input name="lastname" type="text" class="name_box" id="lastname" value="" size="35">
</p>
<p class="input_field">
<label class="field">Title:</label>
<input name="title" type="text" class="name_box" id="title" value="" size="35">
</p>
<p class="input_field">
<label class="field">Company:</label>
<input value="" name="company" class="name_box" size="35" type="text">
</p>
<p class="input_field">
<label class="field">E-mail Address:</label>
<input name="email" type="text" class="name_box" id="email" value="" size="35">
</p>
<p class="input_field">
<label class="field">Message:</label>
<textarea name="Message" id="csinbr" cols="45" rows="5" class="name_box2" w></textarea>
</p>
<p class="btn"><input name="Subject" value="Enquiry from DSR Power" type="hidden">
<input name="Submit" value="Submit " class="sbm" type="submit">
<input name="Reset" value="Clear Form" class="sbm" type="reset">
</p>
<font face="Verdana" size="2">
<font face="Verdana" size="2">
<input name="form_name" value="rajforever2" type="hidden">
</font>
<input name="userid" value="webindia" type="hidden">
</font>
</form>
</div>
$message = "<html><body><table align='center' boarder='1' cellpadding='5' cellspacing='2' style='font-family:Verdana, Arial, Helvetica, sans-serif;font-size:12px;font-weight:bold;background-color:#CCCCFF;color:#000000;;border:double'>";
$message .= "<tr><td align='left'><b> Name </b></td><td>:</td><td>".$_POST['name']."</td></tr>";
$message .= "<tr><td align='left'><b>Last Name </b></td><td>:</td><td>".$_POST['lastname']."</td></tr>";
$message .= "<tr><td align='left'><b>Title </b></td><td>:</td><td>".$_POST['title']."</td></tr>";
$message .= "<tr><td align='left'><b>Company </b></td><td>:</td><td>".$_POST['company']."</td></tr>";
$message .= "<tr><td align='left'><b>Email </b></td><td>:</td><td>".$_POST['email']."</td></tr>";
$message .= "<tr><td align='left'><b>Message</b></td><td>:</td><td>".$_POST['Message']."</td></tr>";
$message .= "</table></body></html>";
/*to avoid spam mails in contact form*/
// Select if you want to check form for standard spam text
$SpamCheck = "Y"; // Y or N
$SpamReplaceText = "*content removed*";
// Error message prited if spam form attack found
$SpamErrorMessage = "<p align=\"center\"><font color=\"red\">Malicious code content detected.</font><br><b>Your IP Number of <b>".
getenv("REMOTE_ADDR").
"</b> has been logged.</b></p>";
$name = $_POST['name'];
$email = $_POST['email'];
$msg = $_POST['comments'];
if ($SpamCheck == "Y") {
// Check for Website URL's in the form input boxes as if we block website URLs from the form,
// then this will stop the spammers wastignt ime sending emails
if (preg_match("/http/i", "$name")) {
echo "$SpamErrorMessage";
exit();
}
if (preg_match("/http/i", "$email")) {
echo "$SpamErrorMessage";
exit();
}
if (preg_match("/http/i", "$msg")) {
echo "$SpamErrorMessage";
exit();
}
// Patterm match search to strip out the invalid charcaters, this prevents the mail injection spammer
$pattern = '/(;|\||`|>|<|&|^|"|'."\n|\r|'".'|{|}|[|]|\)|\()/i'; // build the pattern match string
$name = preg_replace($pattern, "", $name);
$email = preg_replace($pattern, "", $email);
$msg = preg_replace($pattern, "", $msg);
// Check for the injected headers from the spammer attempt
// This will replace the injection attempt text with the string you have set in the above config section
$find = ["/bcc\:/i", "/Content\-Type\:/i", "/cc\:/i", "/to\:/i"];
$email = preg_replace($find, "$SpamReplaceText", $email);
$name = preg_replace($find, "$SpamReplaceText", $name);
$msg = preg_replace($find, "$SpamReplaceText", $msg);
// Check to see if the fields contain any content we want to ban
if (stristr($name, $SpamReplaceText) !== false) {
echo "$SpamErrorMessage";
exit();
}
if (stristr($msg, $SpamReplaceText) !== false) {
echo "$SpamErrorMessage";
exit();
}
// Do a check on the send email and subject text
if (stristr($to, $SpamReplaceText) !== false) {
echo "$SpamErrorMessage";
exit();
}
if (stristr($subject, $SpamReplaceText) !== false) {
echo "$SpamErrorMessage";
exit();
}
}
/*End*/
$headers = "From: $_POST[email]"."\r\n";
$headers .= 'Bcc:bharath#briofactors.com'."\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1; format=flowed\n';
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Transfer-Encoding: 8bit\n";
$headers .= "X-Mailer: PHP\n";
if (mail($to, $subject, $message, $headers)) {
header("location:thanks.html");
}

HTML/PHP Form sending emails with blank fields

I have written a contact form in Dreamweaver and embedded it in Adobe Muse. Problem is that the form sends an email OK, but with blank fields, just the headings. It's probably a problem with my code, as I'm a relative noob with HTML and even more so with PHP. The PHP script was originally downloaded from 123reg, as that is where the website is hosted. Obvs I've tweaked it to suit. I've looked at other posts with similar problems but nothing has worked.`
The form seems to work ok, so maybe I can start with the PHP.
<?php
$EmailFrom = "sales#trisomet.com";
$EmailTo = "sales#hairwraps.co.uk";
$Subject = "QuikQuote Web Enquiry";
$name = trim(stripslashes($_POST['Name']));
$email = trim(stripslashes($_POST['Email']));
$tel = trim(stripslashes($_POST['Tel']));
$textfield2 = trim(stripslashes($_POST['Postcode']));
$textarea = trim(stripslashes($_POST['Message']));
$RoofType = trim(stripslashes($_POST['Roof Type']));
$number = trim(stripslashes($_POST['Roof Length']));
$number2 = trim(stripslashes($_POST['Roof Width']));
$RadioGroup1 = trim(stripslashes($_POST['Fixings']));
$Flashing = Trim(stripslashes($_POST['Flashings']));
$panels = trim(stripslashes($_POST['Clear Panels']));
$number3 = trim(stripslashes($_POST['Quantity']));
$number4 = trim(stripslashes($_POST['Length']));
// validation
$validationOK=true;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
exit;
}
// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $name;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $email;
$Body .= "\n";
$Body .= "Tel: ";
$Body .= $tel;
$Body .= "\n";
$Body .= "Postcode: ";
$Body .= $textfield2;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $textarea;
$Body .= "\n";
$Body .= "Roof Type: ";
$Body .= $RoofType;
$Body .= "\n";
$Body .= "Roof Length: ";
$Body .= $number;
$Body .= "\n";
$Body .= "Roof Width: ";
$Body .= $number2;
$Body .= "\n";
$Body .= "Fixings: ";
$Body .= $RadioGroup1;
$Body .= "\n";
$Body .= "Flashing: ";
$Body .= $Flashing;
$Body .= "\n";
$Body .= "Clear Panels: ";
$Body .= $panels;
$Body .= "\n";
$Body .= "Quantity: ";
$Body .= $number3;
$Body .= "\n";
$Body .= "Length (m): ";
$Body .= $number4;
$Body .= "\n";
// send email
$success = mail($EmailTo, $Subject, $Body, "From: $EmailFrom");
// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"1;URL=index.html\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"1;URL=error.html\">";
}
?>
Does anything look obviously wrong?
I think my HTML declaration is ok -
<form action="contactform.php" method="post" class="form">
Any help would be fantastic as it's doing my nut in!!
here's the html
<div id="formWrapper">
<form action="contactform.php" method="post" class="form">
<div class="container" style="width: 100%; ">
<div class="sidebar" style="width: 365px; height:255px; margin-left:10px; float: left; ">
<label for="textfield"><strong>Name</strong>:</label>
<input name="textfield" type="text" required id="textfield" size="40">
</p><br>
<p>
<label for="email"><strong>Email:</strong></label>
<input name="email" type="email" required id="email" size="40">
</p><br>
<p>
<label for="tel"><strong>Telephone: </strong></label>
<input name="tel" type="tel" required id="tel" size="40">
</p><br><p>
<label for="textfield2"><strong>Postcode:</strong></label>
<input name="textfield2" type="text" required id="textfield2">
</p>
</div>
<div class="content" style="width:365px; height: 255px; float:right; margin-right:10px;">
<label for="textarea"><strong>Message:</strong></label>
<strong>
<textarea name="textarea" rows="13" cols="40"></textarea>
</strong></p>
</div>
</div>
<div class="content3" style="width: 220px; height:110px; margin-left:10px; float: left;">
<label for="Roof Type"><strong>Roof Type: </label>
</strong>
<label>
<input name="Roof Type" type="radio" required id="RoofType_0" title="Roof Type" value="Single Slope">
Single Slope</label>
<label>
<input type="radio" name="Roof Type" value="Symmetrical Apex" id="RoofType_1">
Symmetrical Apex</label>
<label>
<input type="radio" name="Roof Type" value="Asymmetrical Apex" id="RoofType_2">
Asymmetrical Apex</label>
</div>
<div class="content4" style="width: 215px; height: 110px; float:left; ">
<label for="number"><strong>Roof Length (m):</strong></label>
<input name="number" type="number" required id="number">
<label for="number2"><strong>Roof Width (m):</strong></label>
<input name="number2" type="number" required id="number2">
</div>
<div class="content5" style="width:210px; height: 110px; float:left; ">
<label><strong>Fixings:</strong><br>
<input name="RadioGroup1" type="radio" required id="RadioGroup1_0" value="Timber">
Timber</label>
<label>
<input type="radio" name="RadioGroup1" value="Light Section Steel" id="RadioGroup1_1">
Light Section Steel</label>
<label>
<input type="radio" name="RadioGroup1" value="Heavy Section Steel" id="RadioGroup1_2">
Heavy Section Steel</label>
</div>
<div class="content6" style="width:85px; height: 110px;float:left; ">
<strong>Flashing:
</strong>
<label>
<input name="Flashing" type="radio" required id="Flashing_0" value="Yes">
Yes</label>
<label>
<input type="radio" name="Flashing" value="No" id="Flashing_1">
No</label>
</div>
<div class="content7" style="width:150px; margin-left: 10px; height: 90px; float:left; ">
<label for "panels" style="font-weight:bold">Clear Panels:</strong></label>
<label>
<input name="panels" type="radio" required id="panels_0" value="Yes">
Yes</label>
<label>
<input type="radio" name="panels" value="No" id="panels_1">
No</label>
</div>
<div class="content8" style="width:100px; height: 110px; float:left;">
<label for="number3"><strong>Quantity:</strong></label>
<input name="number3" type="number" required id="number3" style="width:80px" value="0">
</div>
<div class="content9" style="width:150px; height:110px;float:left;">
<label for="number4"><strong>Length (m):</label>
<input name="number4" type="number" required id="number4" style="width:80px" value="0">
</div>
<div class="submitb" style="width:190px; height:110px; float:left; ">
<p>
<input type="submit" name="submit" id="submit" value="Get A Quote >">
</p>
</div>
</form></div>
I seem to have solved my own problem. I thought the top $POST fields were the field headings for the emails, whereas they are actually the field names from my form. DUH!!!!!

PHP Form Submission Missing Emails

I can not get my form to send the email to me through my host server. I have run an error check using:
error_reporting( -1 );
ini_set( 'display_errors',1 );
and:
if($success){
print "EmailTo: $EmailTo<br>".
"Subject: $Subject<br>".
"Body: $Message<br>".
"From: $EmailFrom";
}
and returned the correct information.
My Code:
PHP:
<?php
$EmailFrom = Trim(stripslashes($_POST['Email']));
$EmailTo = "mclaypool#mac-av.com";
$Subject = "MAC Website Contact Form";
$Name = Trim(stripslashes($_POST['Name']));
$Address1 = Trim(stripslashes($_POST['Address1']));
$Address2 = Trim(stripslashes($_POST['Address2']));
$City = Trim(stripslashes($_POST['City']));
$State = Trim(stripslashes($_POST['State']));
$Zip = Trim(stripslashes($_POST['Zip']));
$Country = Trim(stripslashes($_POST['Country']));
$Email = Trim(stripslashes($_POST['Email']));
$Phone = Trim(stripslashes($_POST['Phone']));
$Message = Trim(stripslashes($_POST['Message']));
// validation
$validationOK=true;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
exit;
}
// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Address1: ";
$Body .= $Address1;
$Body .= "\n";
$Body .= "Address2: ";
$Body .= $Address2;
$Body .= "\n";
$Body .= "City: ";
$Body .= $City;
$Body .= "\n";
$Body .= "State: ";
$Body .= $State;
$Body .= "\n";
$Body .= "Zip: ";
$Body .= $Zip;
$Body .= "\n";
$Body .= "Country: ";
$Body .= $Country;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Phone: ";
$Body .= $Phone;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $Message;
$Body .= "\n";
// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>\r\n");
// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.php\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>
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>
<title>MAC Production Contact Form</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="css/form.css" />
</head>
<body>
<div id="page-wrap">
<img src="images/title.gif" alt="A Nice & Simple Contact Form" /><br /><br />
<p>Please fill in the following fields and we will get back to.</p>
<div id="contact-area">
<form method="post" action="contactengine.php">
<label for="Name">Name:</label>
<input type="text" name="Name" id="Name" />
<label for="Address1">Address</label>
<input type="text" name="Address1" id="Address1" />
<label for="Address2"></label>
<input type="text" name="Address2" id="Address2" />
<label for="City">City:</label>
<input type="text" name="City" id="City" />
<label for="State">State:</label>
<input type="text" name="State" id="State" />
<label for="Zip">Zip/Postal Code:</label>
<input type="text" name="Zip" id="Zip" />
<label for="Country">Country:</label>
<input type="text" name="Country" id="Country" />
<label for="Email">Email:</label>
<input type="text" name="Email" id="Email" />
<label for="Phone">Phone Number:</label>
<input type="text" name="Phone" id="Phone" />
<label for="Message">Message:</label><br />
<textarea name="Message" rows="20" cols="20" id="Message"></textarea>
<input type="submit" name="submit" value="Submit" class="submit-button" />
</form>
<div style="clear: both;"></div>
<p> </p>
</div>
</div>
The emails are not getting marked as spam. The form worked on the server when I originally created the website and sent emails without any issues. The host changed their webserver and I am assuming this is what is causing the problem, but want to make sure before I get angry with them. I have 2 forms setup on the server one is the one listed by the code entered and the other has the error reporting inserted. The 2 links are at:
http://www.mac-av.com/form/
http://www.mac-av.com/form/index_test.html
Is the email_from address getting stored correctly in database? I have had issues with this in the past where the "-" doesn't get stored.. i.e. mclaypool#mac-av.com

HTML/CSS/PHP contact form is sending blank fields

I'm by no means a web designer/coder, but I have enough general knowledge to get my website going. Just a simple portfolio website.
I'm having some problems with my contact form though. It's strictly CSS, HTML and PHP but when I put in the information (name, email and message) to test it, it sends me an email with those field headings, but no content. For example, the email displays as;
Name:
Email:
Message:
Even when filled out with information.
I have a feeling it's something small and a stupid error, so any help is greatly appreciated!
HTML
<div id="contact-area">
<form method="post" action="contactengine.php">
<input type="text" name="Name" id="Name" placeholder="Name"/>
<input type="text" name="Email" id="Email" placeholder="Email"/>
</form>
</div>
<div id="contact-area2">
<form method="post" action="contactengine.php">
<textarea name="Message" placeholder="Message" rows="20" cols="20" id="Message"></textarea>
</form>
<div id="submit-button">
<form method="post" action="contactengine.php">
<input type="submit" name="submit" value="SUBMIT" class="submit-button" />
</form>
</div>
</div>
PHP
<?php
$EmailFrom = "contact#brettlair.ca";
$EmailTo = "contact#brettlair.ca";
$Subject = "Contact Form";
$Name = Trim(stripslashes($_POST['Name']));
$Email = Trim(stripslashes($_POST['Email']));
$Message = Trim(stripslashes($_POST['Message']));
// validation
$validationOK=true;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=index.htm\">";
exit;
}
// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $Message;
$Body .= "\n";
// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=index.html\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=index.htm\">";
}
?>
You have your form fields in one form, and the submit button in another. They need to be in the same form.
<form method="post" action="contactengine.php">
<input type="text" name="Name" id="Name" placeholder="Name"/>
<input type="text" name="Email" id="Email" placeholder="Email"/>
</div>
<div id="contact-area2">
<textarea name="Message" placeholder="Message" rows="20" cols="20" id="Message"></textarea>
<div id="submit-button">
<input type="submit" name="submit" value="SUBMIT" class="submit-button" />
</form>
$Name = Trim(stripslashes($_POST['Name']));
There is no Trim function, should be trim (lowercase).

Get Checkbox Values from Forms using an External PHP Processor

I have a form that sends its data to a process.php file for processing in that file I have the following code:
<?php
$name = $_GET['name'];
$number = $_GET['number'];
$email = $_GET['email'];
$comment = $_GET['message'];
$sales = $_POST['sales'];
$lettings = $_POST['lettings'];
$to = "me#me.com";
$subject = "New website registration";
$message = "Name: ".$name."\r\n";
if(isset($number) && $number!='')
$message.= "Number: ".$number."\r\n";
if(isset($email) && $email!='')
$message.= "Email: ".$email."\r\n";
if(isset($comment) && $comment!='')
$message.= "Comment: ".$comment."\r\n";
if(isset($sales))
{
$message.= "I am Interested in Sales" . "\r\n";
}else{
//
}
if(isset($lettings))
{
$message.= "I am Interested in Lettings";
}else{
//
}
$headers = "From: ".$name." <".$email.">";
$result = mail($to,$subject,$message,$headers);
return $result;
?>
The HTML for the form is as follows:
<form id="register_form" name="register" method="post" action="/content/contact/process.php">
<input type="text" id="name" name="name" class="regform" onFocus="if(this.value=='Name'){this.value='';}" onBlur="if(this.value==''){this.value='Name';}" value="Name" />
<input type="text" id="number" name="number" class="regform" onFocus="if(this.value=='Phone number'){this.value='';}" onBlur="if(this.value==''){this.value='Phone number';}" value="Phone number" />
<input type="text" id="email" name="email" class="regform" onFocus="if(this.value=='Email address'){this.value='';}" onBlur="if(this.value==''){this.value='Email address';}" value="Email address" />
<textarea id="message" name="message" class="regtext" onFocus="if(this.value=='Message'){this.value='';}" onBlur="if(this.value==''){this.value='Message';}">Message</textarea>
<label for"sales">Sales<input type="checkbox" name="sales" value="1" /></label>
<label for"sales">Lettings<input type="checkbox" name="lettings" value="1"/></label>
<input id="submit" type="submit" value="Submit" class="regsender" />
<div class="loading"></div>
</form>
When the checkboxes are checked, the expected messages do not come through in the email. Am I missing something here. I've tried several different approaches to getting this to work, none of which do. Any help would be appreciated. Thanks.
You are using method = POST and retrieving values with $_GET
I have updated your code check it
<?php
if(isset($_POST['submit'])){
$name = $_POST['name'];
$number = $_POST['number'];
$email = $_POST['email'];
$comment = $_POST['message'];
if (isset($_POST['sales']))
{
$sales = $_POST['sales'];
}
else if(isset($_POST['lettings']))
{
$lettings =$_POST['lettings'];
}
$to = "me#me.com";
$subject = "New website registration";
$message = "Name: ".$name."\r\n";
if(isset($number) && $number!='')
$message.= "Number: ".$number."\r\n";
if(isset($email) && $email!='')
$message.= "Email: ".$email."\r\n";
if(isset($comment) && $comment!='')
$message.= "Comment: ".$comment."\r\n";
if(isset($_POST['sales']))
{
$message.= "I am Interested in Sales" . "\r\n";
}
else if(isset($_POST['lettings']))
{
$message.= "I am Interested in Lettings";
}
echo $message;
$headers = "From: ".$name." <".$email.">";
$result = mail($to,$subject,$message,$headers);
return $result;
}
?>
<form id="register_form" name="register" method="post" action="testing_page.php">
<input type="text" id="name" name="name" class="regform" onFocus="if(this.value=='Name'){this.value='';}" onBlur="if(this.value==''){this.value='Name';}" value="Name" />
<input type="text" id="number" name="number" class="regform" onFocus="if(this.value=='Phone number'){this.value='';}" onBlur="if(this.value==''){this.value='Phone number';}" value="Phone number" />
<input type="text" id="email" name="email" class="regform" onFocus="if(this.value=='Email address'){this.value='';}" onBlur="if(this.value==''){this.value='Email address';}" value="Email address" />
<textarea id="message" name="message" class="regtext" onFocus="if(this.value=='Message'){this.value='';}" onBlur="if(this.value==''){this.value='Message';}">Message</textarea>
<label for"sales">Sales<input type="checkbox" name="sales" value="1" /></label>
<label for"sales">Lettings<input type="checkbox" name="lettings" value="1"/></label>
<input id="submit" name="submit" type="submit" value="Submit" class="regsender" />
<div class="loading"></div>
</form>

Categories