HTML/PHP Email forms not functioning as wanted - php

I am doing a contact us form into my website, and i am now stuck.
Here's the PHP code:
#Receive user input
$Name = $_POST['Name'];
$Email = $_POST['Email'];
$Message = $_POST['Message'];
$palvelu = $_POST['palvelu'];
#Filter user input
function filter_email_header($form_field) {
return preg_replace('/[nr|!/<>^$%*&]+/','',$form_field);
}
$Email = filter_email_header($Email);
#Send email
$headers = "From: $Email\r\n";
$sent = mail('user#example.com', 'Yhteydenotto Pyyntö: ', $Message, $headers);
#Thank user or notify them of a problem
if ($sent) {
?><html>
<head>
<title>Kiitos yhteydenotosta!</title>
</head>
<body>
<h1>Kiitos yhteydenotosta!</h1>
<p>Olemme sinuun yhteydessä mahdollisimman nopeasti!</p>
</body>
</html>
<?php
} else {
?><html>
<head>
<title>Jokin meni vikaan!</title>
</head>
<body>
<h1>Jokin meni vikaan!</h1>
<p>Emme pystyneet lähettämään viestiä?</p>
</body>
</html>
<?php
}
?>
And here's the html code of the form:
<div class="col-lg-5 d-flex align-items-stretch">
<div class="bg-white">
<div class="w-100 heading-title bg-primary text-center">
<h2 class="mb-0">Ota meihin yhteyttä!</h2>
</div>
<form action="email.php" method="post" class="appointment bg-white p-4 p-md-5">
<div class="row">
<div class="col-md-12">
<div class="form-group">
<div class="form-field">
<div class="select-wrap">
<div class="icon"><span class="fa fa-chevron-down"></span></div>
<select name="palvelu" id="" class="form-control">
<option value="">Valitse palvelu</option>
<option value="">Sammaleen poisto</option>
<option value="">Katon pinnoitus</option>
<option value="">Tiilikaton huolto</option>
<option value="">Vuosihuolto</option>
</select>
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<input type="text" id="Name" name="Name" placeholder="Nimi" class="form-control">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<input type="Email" id="Email" name="Email" placeholder="Sähköposti" class="form-control">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<div class="input-wrap">
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<div class="input-wrap">
</div>
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<textarea id="Message" name="Message" class="form-control" placeholder="Viesti" rows="6" maxlength="3000"></textarea>
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<input type="submit" value="Lähetä viesti" class="btn btn-primary py-3 px-4">
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
So that's in finnish but i have this list where you can select what job you want to discuss "palvelut" and then the basic form. What it should do is to send an email with "who sent it" "the job they want" and the basic form stuff "name" "email" and the "message". But now it only seems to send an blank email with only the "yhteydenotto pyyntö" it means like "a new question". Could someone help me? What am i doing wrong...

Solution Here!!!
* Your filter_email_header is contain Problem so we use Default FILTER_SANITIZE_EMAIL filter.
Remove code
#Filter user input
function filter_email_header($form_field) {
return preg_replace('/[nr|!/<>^$%*&]+/','',$form_field);
}
$Email = filter_email_header($Email);
Replace the Fix
// Remove all illegal characters from email
$email = filter_var($email, FILTER_SANITIZE_EMAIL);
*Your Form select option not present value so whatare the value select empty value to shown email form
<select name="palvelu" id="palvelu" class="form-control">
<option value="Valitse palvelu">Valitse palvelu</option>
<option value="Sammaleen poisto">Sammaleen poisto</option>
<option value="Katon pinnoitus">Katon pinnoitus</option>
<option value="Tiilikaton huolto">Tiilikaton huolto</option>
<option value="Vuosihuolto">Vuosihuolto</option>
</select>

Related

PHP - html form sent to gmail account

I never used PHP before, but I need to set up an HTML form from to be sent from my website to my gmail account. Checked some tutorials and came up with this code. But for some reason it is not working. When I hit submit it goes to a "Page Not Found
Looks like you've followed a broken link or entered a URL that doesn't exist on this site." Not sure what am I doing wrong.
I have my HTML document, and I have my PHP document. Saved together.
<form action="contact.php" method="POST" name="form">
<div class="row">
<div class="col-12 col-md-6">
<div class="contact-form">
<label for="name">Please enter your name:</label>
<input name="name" type="text" class="form-control" placeholder="Harry Potter">
</div>
</div>
<div class="col-12 col-md-6">
<div class="contact-form">
<label for="mail">Your email address:</label>
<input name="mail" type="email" class="form-control" placeholder="harry#potter.com">
</div>
</div>
</div>
<div class="row">
<div class="col-12">
<div class="contact-form">
<label for="message">How can I help you?</label>
<textarea name="message" class="form-control" id="form-text" cols="30" rows="10" placeholder="Let's do some magic"></textarea>
</div>
</div>
</div>
<div id="submit" class="text-center">
<button name="submit" type="submit" class="btn mt-5 mx-auto">Submit</button>
</div>
</form>
<?php
if(isset($_POST["submit"])) {
$name=$_POST["name"];
$mailFrom=$_POST["mail"];
$message=$_POST["message"];
$mailTo = "myaddress#gmail.com";
$subject = "Form from my website";
$headers = "From: ".$mailFrom;
$txt = "You have received an e-mail from ".$name."\n\n".$message;
if(mail($mailTo, $subject, $txt, $headers)) {
echo "<h1>I recieved your email! Will be in touch with you soon.</h1>";
}
else{
echo "<h1>Something went wrong! Try again.</h1>";
}
header("Location: https://www.whatever.com");
}
?>

My Google recaptcha verification is not working

I am using this code to work recaptcha services. But it tells me you are a bot.
I tried php server side integration but it does not work.
Here is html
<form id="contact-form" name="contact-form" action="submithr.php" method="POST">
<!--Grid row-->
<div class="row">
<div class="col-md-8">
<div class="md-form mb-0">
<label for="subject" class="">Subject</label>
<input type="text" id="subject" name="subject" class="form-control" required>
</div>
</div>
<!--Grid column-->
<div class="col-md-4">
<div class="md-form mb-0">
<label for="category" class="">Select Category</label>
<select type="text" id="category" name="category" class="form-control">
<option value="1">Suggestion</option>
<option value="2">Claim</option>
<option value="3">Help</option>
</select>
</div>
</div>
<!--Grid column-->
</div>
<!--Grid row-->
<!--Grid row-->
<div class="row">
<!--Grid column-->
<div class="col-md-12">
<div class="md-form">
<label for="message">Your message</label>
<textarea type="text" id="message" name="message" rows="2" class="form-control md-textarea" required></textarea>
</div>
</div>
</div>
<!--Grid row-->
<br>
<div class="g-recaptcha" data-sitekey="---My site key---"></div>
<br>
<div class="text-center text-md-left">
<a class="btn btn-primary" onclick="document.getElementById('contact-form').submit();">Send</a>
</div>
</form>
And here is php code
<?php
$subject = $_POST['subject'];
$category = $_POST['category'];
$message = $_POST['message'];
$secretKey = "---My Secret Key---";
$responseKey = $_POST['g-recaptcha-response'];
$userIP = $_SERVER['REMOTE_ADDR'];
$url = "https://www.google.com/recaptcha/api/siteverify?secret=$secretKey&response=$responseKey&remoteip=$userIP";
$response = file_get_contents($url);
$response = json_decode($response);
if ($response->success) {
echo "<script> alert('Thank you For Posting Suggestion')</script>";
}
else{
echo "<script> alert('It looks like you are bot.Try Again')</script>";
}
?>
If check box is checked correctly it should alert me that i checked it correctly But even if i check it correctly it always alert me you are a bot.
Set this file in your html page containinig the form
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
Then set the google div box before your submission button
<div class="g-recaptcha" data-sitekey="Your recaptcha site key here"></div>
here is the php code
<?php
$subject = $_POST['subject'];
$category = $_POST['category'];
$message = $_POST['message'];
// Ensure that recaptchabox is not empty
if(isset($_POST['g-recaptcha-response']) && !empty($_POST['g-recaptcha-response'])){
$secretKey = 'Your_reCAPTCHA_Secret_Key_goes here';
// send request and Verify the reCAPTCHA via g_recaptcha_response post parameter.
$verifyRequest = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret='.$secretKey.'&response='.$_POST['g-recaptcha-response']);
$result = json_decode($verifyRequest);
// Check if captcha enterd is valid
if($result->success){
// send your form data and update database
echo "<script> alert('Thank you For Posting Suggestion')</script>";
}else{
echo "<script> alert('Faizan You are bot. hahaha....')</script>";
}
}else{
echo "Recaptcha box cannot be empty";
}
?>

PHP mailer form data verification isn't working

NOTE: the mail function itself works fine, I have a hosted site with mail configured professionally. Mail is sent via this script, but my simple empty field handler never catches empty fields. I'm sure this is something super obvious, but I'm very new to php and the logic of my script seems sound. The code follows:
edit: I've left the form call within the php script in case someone finds issue with the bootstrap form itself. The redirect is temporary until I can get better form error handling going.
<body>
<!-- jQuery and bootstrap -->
<script src="https://code.jquery.com/jquery.js"></script>
<script src="../js/bootstrap.min.js"></script>
<script src="../js/counter.js"></script>
<div class="jumbotron-fluid" id="primary">
<?php
if (isset($_POST['submit'])) {
$from = 'Web_Form_Contact';
$to = 'example#example.com';
$subject = 'Job_Contact';
$c_type = $_POST["c_type"];
if (empty($_POST["c_name"])) {
$errName = 'Info missing: Name';
} else {
$c_name = $_POST["c_name"];
}
if (empty($_POST["c_email"] )) {
$errEmail = 'Please enter a valid email address';
} else {
$c_email = $_POST["c_email"];
}
if (empty($_POST["co_name"])) {
$errCoName = 'Info missing: Company Name';
} else {
$co_name = $_POST["co_name"];
}
if (empty($_POST["j_desc"])) {
$errjDesc = 'Info missing: Job Description';
} else {
$j_desc = $_POST["j_desc"];
}
$body = "From: $c_name\n E-Mail: $c_email\n Type: $c_type\n CoName: $co_name\n Description\n $j_desc";
if (empty($errName && $errEmail && $errCoName && $errjDesc)) {
if (mail ($to, $subject, $body, $from)) {
$result='<div class="alert alert-success">Thank You! I will be in touch\n This page will redirect in 5 seconds.</div>';
} else {
$result='<div class="alert alert-danger">Sorry there was an error sending your message. Please try again later</div>';
}
} else {
echo "$errName\n $errEmail\n $errCoName\n $errjDesc";
}
}
echo "$result";
?>
<div class="container">
<form class="form-horizontal" role="form" method="post" action="php/info.php"
<div class="row">
<div class="col-xs-10 col-sm-6 col-md-6 col-lg-offset-2 col-md-offset-2">
<<h2>Contact Me! <small></small></h2>
<form>
<div class="form-group row">
<label for="clientEmail" class="col-sm-2 form-control-label">Email</label>
<div class="col-sm-10">
<input type="email" name="c_email"class="form-control" id="clientEmail" placeholder="Email" >
</div>
</div>
<div class="form-group row">
<label for="clientName" class="col-sm-2 form-control-label">Name</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="c_name" id="clientName" placeholder="Your Name" >
</div>
</div>
<div class="form-group row">
<label class="col-sm-2">Contact Type</label>
<div class="col-sm-10">
<div class="radio">
<label>
<input type="radio" name="c_type" id="gridRadios1" value="recruiter" checked>
I am a recruiter, and do not work directly for the company hiring.
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="c_type" id="gridRadios2" value="employee">
I work for the company in question, and wish to discuss an open position.
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="c_type" id="gridRadios3" value="other" >
Other
</label>
</div>
</div>
</div>
<div class="form-group row">
<label for="coName" class="col-sm-2 form-control-label">Company Name</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="co_name" id="coName" placeholder="Company Name" >
</div>
</div>
<!-- Job Description Text Box -->
<div class="form-group row">
<label for="Job Description ">Job Description: (1100 character max!)</label>
<div class="col-sm-10 col-lg-offset-2 col-md-offset-2 col-xl-offset-2 col-sm-offset-2" >
<div class="form-group">
<textarea class="form-control" rows="5" name="j_desc" id="jobDesc" placeholder="Job Description" ></textarea>
<p class="counter">1100</p>
</div>
</div>
</div>
<div class="form-group row">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" id="send" name="submit" value="Send"class="btn btn-secondary">Submit</button>
</div>
</div>
<div class="form-group">
<div class="col-sm-10 col-sm-offset-2">
<?php echo $result; ?>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<!--redirect script -->
<script>
function redirect(page) {
setTimeout(function () {
window.location.href = page;
}, 5000);
}
//sends to homepage
redirect("../index.html");
</script>
You need to have an empty check for each variable:
if (empty($errName) && empty($errEmail) && empty($errCoName) && empty($errjDesc)) {
You can also set an email flag at the beginning to true, and if you hit any of the errors, you can set it to false. Then when you're ready to email, check to see if that email flag is still true.

PHP form error only present in Internet Explorer

I am working on a PHP form for bootstrap my site. (http://camp.impactak.com/signup.html) This form works perfectly in every browser EXCEPT internet explorer. It comes up with and error:
"Please correct the following error:
YOUR NAME
Hit back button and try again."
I put code in the PHP that should have eliminated an error message if some of the blanks are not filled. However, it still sends an error (only in IE)
PHP:
<?php
/* Set e-mail recipient */
$myemail = "erinpavek#gmail.com";
/* Check all form inputs using check_input function */
$name = check_input($_POST['inputName'], "Your Name");
$address = check_input($_POST['inputAddress'], "Street, PO Box, company");
$address2 = check_input($_POST['inputAddress2'], "Apt, Unit, Suite");
$village = check_input($_POST['inputVillage'], "Your Village");
$state = check_input($_POST['inputState'], "State, Providence, Region");
$zip = check_input($_POST['inputZip'], "Your Zip");
$tel = check_input($_POST['inputTel'], "Your Phone");
$email = check_input($_POST['inputEmail'], "Your E-mail Address");
$pname = check_input($_POST['inputParent'], "Parent/Guardian Name");
$subject = check_input($_POST['inputSubject'], "Message Subject");
$message = check_input($_POST['inputMessage'], "Your Message");
$select = check_input($_POST['inputSelect'], "Certified");
$select2 = check_input($_POST['inputSelect2'], "NonCertified");
/* If e-mail is not valid show error message */
if (!preg_match("/([\w\-]+\#[\w\-]+\.[\w\-]+)/", $email))
{
show_error("Invalid e-mail address");
}
/* Let's prepare the message for the e-mail */
$subject = "Someone has sent you a message";
$message = "
Someone has sent you a message using your contac form:
Name: $name
Address: $address
Address2: $address2
Village: $village
State: $state
Zip: $zip
Cell: $tel
Email: $email
Parent/Guardian: $pname
Certified: $select
NonCertified: $select2
Subject: $subject
Message:
$message
";
/* Send the message using mail() function */
mail($myemail, $subject, $message);
/* Redirect visitor to the thank you page */
header('Location: http://www.camp.impactak.com');
exit();
/* Functions we used */
function check_input($data)
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>
HTML:
<form name="contactform" method="post" action="mailer.php" class="form-horizontal" role="form">
<div class="panel-body">
<form name="contactform" method="post" action="http://wedding-space.net/01_admin_resources/blog/contact_form/mailer.php" class="form-horizontal" role="form">
<div class="form-group">
<label for="inputName" class="col-lg-3 control-label">Full Name</label>
<div class="col-lg-9">
<input type="text" class="form-control" id="inputName" name="inputName" placeholder="First and Last Name">
</div>
</div>
<div class="form-group">
<label for="inputAddress" class="col-lg-3 control-label">Address1</label>
<div class="col-lg-9">
<input type="text" class="form-control" id="inputAddress" name="inputAddress" placeholder="Street">
</div>
</div>
<div class="form-group">
<label for="inputAddress2" class="col-lg-3 control-label">Address2</label>
<div class="col-lg-9">
<input type="text" class="form-control" id="inputAddress2" name="inputAddress2" placeholder="Apt, Unit, Building">
</div>
</div>
<div class="form-group">
<label for="inputVillage" class="col-lg-4 control-label">Village</label>
<div class="col-lg-8">
<input type="text" class="form-control" id="inputVillage" name="inputVillage" placeholder="Village">
</div>
</div>
<div class="form-group">
<label for="inputState" class="col-lg-4 control-label">State</label>
<div class="col-lg-8">
<input type="text" class="form-control" id="inputState" name="inputState" placeholder="State">
</div>
</div>
<div class="form-group">
<label for="inputZip" class="col-lg-4 control-label">Zip Code</label>
<div class="col-lg-8">
<input type="text" class="form-control" id="inputZip" name="inputZip" placeholder="Zip">
</div>
</div>
<div class="form-group">
<label for="inputEmail" class="col-lg-3 control-label">Email</label>
<div class="col-lg-9">
<input type="text" class="form-control" id="inputEmail" name="inputEmail" placeholder="Your Email">
</div>
</div>
<div class="form-group">
<label for="inputParent" class="col-lg-3 control-label">Parent/Guardian</label>
<div class="col-lg-9">
<input type="text" class="form-control" id="inputParent" name="inputParent" placeholder="Parent/Guardian Name">
</div>
</div>
<h5>Each student much choose one class from the either the Certified or Non-Certified class list: </h5>
<select class="form-control" id="inputSelect" name="inputSelect">
<option value="none">Certified Classes</option>
<option value="DriversEd">Drivers Ed. (get license, village youth only)</option>
<option value="NSTC">NSTC- (Seniors or 2014 graduates)</option>
<option value="LifeGuard">Life Guard Training</option>
<option value="ArcticSurvival">Arctic Survival Certification</option>
</select>
<br>
<select class="form-control" id="inputSelect2" name="inputSelect2">
<option value="none">Non-Certified Classes</option>
<option value="cook">Cooking</option>
<option value="Art">Arts from the Earth/Crafts</option>
<option value="poetry">Creative Writing/Poetry</option>
<option value="guitar">Guitar Lessons</option>
<option value="engineering">Science and Engineering</option>
<option value="drama">Drama/Acting</option>
<option value="taeKwonDo">Tae Kwon Do</option>
<option value="sodHouse">Sod House Design</option>
<option value="SkinSewing">Skin Sewing</option>
<option value="DrumDance">Drum Dancing</option>
<option value="Aviation">Aviation</option>
<option value="Rap">Rap/Hip-Hop Class</option>
</select>
<br>
</form>
<div class="form-group">
<div class="col-lg-offset-2 col-lg-10">
<button type="submit" class="btn btn-default">
Sign Up
</button>
</div>
</div>
</form>
</div>
</div>
The answer was staring us in the face.
You put a form in a form.
That is not allowed.
you cant have forms submit forms.
Please readjust your markup accordingly to not have forms in Forms, they can be siblings though. Problem solved.
You have:
<form><form></form></form>
You need to either remove the inner form, or separate it out:
<form></form>
or
<form></form>
<form></form>

Implode Issue On PHP Form

In spite of the fact that I'll probably look like a complete idiot, I'm going to post my entire files to see what I'm doing wrong.
I have form built into the page like so:
<form method="post" class="form-horizontal" id="final_form" action="send_mail.php">
<h2>Search for your dream home<br />
and save now!</h2>
<legend>Which Areas are you interested in?</legend>
<div class="areas row-fluid" style="text-align:left !important;">
<div class='span5' style='margin-left:0px !important;'>
<label>
<input type="checkbox" name="arrayValue[]" id="area[0]" value="Sparks" style='margin-top:-5px !important;'> Sparks</label>
</div>
<div class='span5' style='margin-left:0px !important;'>
<label >
<input type="checkbox" name="arrayValue[]" id="area[1]" value="Stead" style='margin-top:-5px !important;'> Stead</label>
</div>
<div class='span5' style='margin-left:0px !important;'>
<label>
<input type="checkbox" name="arrayValue[]" id="area[2]" value="North Reno" style='margin-top:-5px !important;'> North Reno</label>
</div>
<div class='span5' style='margin-left:0px !important;'>
<label >
<input type="checkbox" name="arrayValue[]" id="area[3]" value="South Reno" style='margin-top:-5px !important;'> South Reno</label>
</div>
<div class='span5' style='margin-left:0px !important;'>
<label >
<input type="checkbox" name="arrayValue[]" id="area[4]" value="Double Diamond" style='margin-top:-5px !important;'> Double Diamond</label>
</div>
</div>
<input type="button" onclick="jQuery('#myModal').modal('show')" value="CONTINUE" />
</div>
</div>
</div>
<!--banner area end-->
<!--content area 1 start-->
<div id="content1">
<div class="content1_in"> <span>
<h2 style="line-height:40px;font-size:40px;padding-bottom:10px">Some Content</h2>
<p style="line-height:30px;font-size:22px;text-align: left">Some Content!</p>
</span>
<div class="img">
<img src="image" alt="" />
</div>
</div>
</div>
<!--content area 1 end-->
<!--content area 1 start-->
<div id="content2">
<div class="content2_in"> <span>
</span>
<div class="img">
<img src="http://f14.co/realtor/assets/images/ipad-img.png" alt="" />
<div class="key"></div>
</div>
</div>
</div>
<!--content area 1 end-->
<!--content area 3 start-->
<div id="content3">
<div class="content3_in">
<div class="img">
<img src="image" alt=""
/>
</div>
<div class="free"></div>
</div>
</div>
<!--content area 3 end-->
<div id="footer">
<div class="footer_in">
This Website Is Brought To You By: Ken Holden</div>
</div>
<!-- Modal -->
<div id="myModal" class="modal hide fade modal-survey" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">x</button>
<h3 id="myModalLabel" class="survey_title">What type of home are you looking for?</h3>
</div>
<input type="hidden" name="template" id="template" value="Buyers" />
<div class="modal-body">
<div id="lead_info_1">
<div class="input select">
<div class=""></div>
<div class="span-4 step-2-dropdown append-bottom control-group">
<select class="span3 required" name="minPrice" id="minPrice">
<option value="">Price</option>
<option value='$50,000 - $150000'>$50,000 - $150000</option><option value='$150,000 -
$300,000'>$150,000 - $300,000</option><option value='$300,000 - $400,000'>
$300,000 - $400,000</option><option value='$400,000 +'>$400,000 +</option>
</select>
</div>
</div>
<div class="input select">
<div class=""></div>
<div class="span-4 step-2-dropdown append-bottom control-group">
<select class="span3 required" name="minBedrooms" id="minBedrooms">
<option value="">Bedrooms</option>
<option value='1-2'>1-2</option><option value='2-4'>2-4</option><option value='4+'>4+
</option> </select>
</div>
</div>
<div class="input select">
<div class=""></div>
<div class="span-4 step-2-dropdown append-bottom control-group">
<select class="span3 required" name="minBathrooms" id="minBathrooms">
<option value="">Bathrooms</option>
<option value='1-2'>1-2</option><option value='2-4'>2-4</option><option value='4+'>4+
</option> </select>
</div>
</div>
<div class="input select">
<div class=""></div>
<div class="span-8 step-2-dropdown2 append-bottom control-group">
<select class="span3 required" name="realtor" id="realtor">
<option value="">Currently Working With a Realtor</option>
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
</div>
</div>
<div class="input select">
<div class=""></div>
<div class="span-8 step-2-dropdown2 append-bottom control-group">
<select class="span3 required" name="move" id="move">
<option value="">When Do You Plan On Moving?</option>
<option value="30-90 days">30-90 days</option>
<option value="90-120 days">90-120 days</option>
<option value="I'm just looking">I'm just looking</option>
</select>
</div>
</div>
<!--<img src="http://localcommissionsystem.com/assets/app/images/SearchDealsLikeThis.png" />-->
</div>
<div id="lead_info_2" style="display:none">
<center>
</center>
</div>
<div id="lead_info_3" style="display:none">
<textarea class="" id="wantedArea" name="wantedArea" style="display:none;"></textarea>
<div class="control-group">
<label class="control-label" for="fname">First Name</label>
<div class="controls">
<input class="required" type="text" id="fname" name="fname" placeholder="First Name" />
</div>
</div>
<div class="control-group">
<label class="control-label" for="email">Email</label>
<div class="controls">
<input class="required" type="text" id="email" name="email" placeholder="Valid Email Required" />
</div>
</div>
<div class="control-group">
<label class="control-label" for="phone">Cell Phone</label>
<div class="controls">
<input class="required" type="text" id="phone" name="phone" placeholder="Cell Phone" />
</div>
</div>
</div>
</div>
Here is the php
<?php
$webmaster_email = "email#email.com";
$webmaster_email2 = "email#email.com";
$fname = $_REQUEST['fname'];
$email = $_REQUEST['email'];
$phone = $_REQUEST['phone'];
$minBedrooms = $_REQUEST['minBedrooms'];
$minBathrooms = $_REQUEST['minBathrooms'];
$minPrice = $_REQUEST['minPrice'];
$move = $_REQUEST['move'];
$realtor = $_REQUEST['realtor'];
if( !empty($_REQUEST) && is_array($arrayValue) ) {
$arrayValue = array();
$areas = implode("," , $_REQUEST['arrayValue']);
}
$emailfrom = $_REQUEST['email'];
$headers = 'From: '.$emailfrom."\r\n".
$email_to = "test#gmail.com, ";
/* This bit sets the URLs of the supporting pages.
If you change the names of any of the pages, you will need to change the values here.
*/
$feedback_page = "index.html";
$thankyou_page = "thankyou.html";
/*
The following function checks for email injection.
Specifically, it checks for carriage returns - typically used by spammers to inject a CC
list.
*/
function isInjected($str) {
$injections = array('(\n+)',
'(\r+)',
'(\t+)',
'(%0A+)',
'(%0D+)',
'(%08+)',
'(%09+)'
);
$inject = join('|', $injections);
$inject = "/$inject/i";
if(preg_match($inject,$str)) {
return true;
}
else {
return false;
}
}
// If the user tries to access this script directly, redirect them to the feedback
form,
if (!isset($_REQUEST['email'])) {
header( "Location: $feedback_page" );
}
// If email injection is detected, redirect to the error page.
elseif ( isInjected($email) ) {
header( "Location: $error_page" );
}
// If we passed all previous tests, send the email then redirect to the thank you page.
else {
mail( $email_to, "You Have a New Lead",
"Name: $fname\nEmail: $email\nPhone: $phone\nMinBedrooms: $minBedrooms\nMinPrice:
$minPrice\nMove Date: $move\nRealtor: $realtor\nAreas: $areas", $headers );
}
echo "<script>window.location = 'thankyou.html'</script>";
?>
My checkboxes are not returning any values. Does anyone know why? I've worked to make things correct and I think I've got the array set up right thanks to the help of another question, but I think I'm asking the wrong question in my other post.
Your $arrayValue is not defined before the first if statement which is why the is_array($arrayValue) does not succeed. Please try:
if( !empty($_REQUEST['arrayValue'])) {
$arrayValue = array();
$areas = implode("," , $_REQUEST['arrayValue']);
}
In your HTML this should be the name:
<input type="checkbox" name="arrayValue" id="area[4]" value="Double Diamond" style='margin-top:-5px !important;'> Double Diamond</label>
In your PHP
if( !empty($_REQUEST) && is_array($arrayValue) )
{
$arrayValue = array();
$arrayValue[] = $_REQUEST['arrayValue'];
}
$areas = implode(",",$arrayValue);
put it in the array first then implode it as a string.
just check by printing php global variable $_REQUEST on your php. You can do it by writing print_r($_REQUEST); if it does not shows anything or black array, make use of $_POST instead of $_REQUEST at each place in php file. Hope it will solve your problem.

Categories