I was told my client's quote form has not been generating very many emails. I have learned that although the form brings you to a confirmation page, the information never reaches the recipient.
I have altered the code so it goes to my office email for testing purposes. If I post code for the form elements below, would someone be able to spot what the problem might be?
Thank you very much!
Link to the quote page is http://autoglass-plus.com/quote.php
First is the form itself:
<form id="quoteForm" name="form" action="form/index.php" method="post">
<fieldset>
<p> <strong>Contact Information:</strong><br />
</p>
<div>
<label for="firstname">First Name:<br />
</label>
<input type="text" size="30" name="firstname" class="txt" id="firstname" />
</div>
<div>
<label for="lastname">Last Name:<br />
</label>
<input type="text" size="30" name="lastname" class="txt" id="lastname" />
</div>
<div>
<label for="address">Address:<br />
</label>
<input type="text" size="30" name="address" class="txt" id="address" />
</div>
<div>
<label for="city">City:<br />
</label>
<input type="text" size="30" name="city" class="txt" id="city" />
</div>
<div>
<label for="state">State:<br />
</label>
<input type="text" size="30" name="state" class="txt" id="state" />
</div>
<div>
<label for="zip">Zip:<br />
</label>
<input type="text" size="30" name="zip" class="txt" id="zip" />
</div>
<div>
<label for="label">Phone:<br />
</label>
<input type="text" size="30" name="phone" class="txt" id="label" />
</div>
<div>
<label for="email">Email:<br />
</label>
<input type="text" size="30" name="email" class="txt" id="email" />
</div>
<p><br />
<b>Insurace Information</b></p>
<p><i>Auto Glass Plus in an Approved Insurance Vendor. Insurance claims require additional information that we will request when we contact you for your quote.</i></p>
<br />
<div>
<input type="checkbox" name="insurance" value="yes" />
Check here if this is an insurance claim.<br />
<label for="year">Insurance Provider:<br />
</label>
<input type="text" size="30" name="provider" class="txt" id="provider" />
</div>
<p><br />
<b>Vehicle Information:</b><br />
</p>
<div>
<label for="year">Vehicle Year :<br />
</label>
<input type="text" size="30" name="year" class="txt" id="year" />
</div>
<div>
<label for="make">Make: </label>
<br />
<input type="text" size="30" name="make" class="txt" id="make" />
</div>
<div>
<label for="model">Model:</label>
<br />
<input type="text" size="30" name="model" class="txt" id="model" />
</div>
<div>
<label for="body">Body Type:<br />
</label>
<select name="body" id="body">
<option>Select One</option>
<option value="2 Door Hatchback">2 Door Hatchback</option>
<option value="4 Door Hatchback">4 Door Hatchback</option>
<option value="2 Door Sedan">2 Door Sedan</option>
<option value="4 Door Sedan">4 Door Sedan</option>
<option value="Station Wagon">Station Wagon</option>
<option value="Van">Van</option>
<option value="Sport Utility">Sport Utility</option>
<option value="Pickup Truck">Pickup Truck</option>
<option value="Other Truck">Other Truck</option>
<option value="Recreational Vehicle">Recreational Vehicle</option>
<option value="Other">Other</option>
</select>
</div>
<p><b><br />
Glass in Need of Repair:</b><br />
</p>
<div>
<input type="checkbox" name="repairs" value="Windshield" />
Windshield<br />
<input type="checkbox" name="repairs" value="Back Glass" />
Back Glass<br />
<input type="checkbox" name="repairs" value="Driver’s Side Window" />
Side Window*<br />
<input type="checkbox" name="repairs" value="Chip Repair" />
Chip Repair<br />
<input type="checkbox" name="repairs" value="Other" />
Other </div>
<p><strong>*Important:</strong> For side glass, please indicate the specific window that needs replacement <i>(e.g. passenger side rear door or driver side vent glass)</i>, and any tinting color preference in the <strong>Describe Damage </strong> field.</p>
<p><br />
<b>Describe Damage</b></p>
<div>
<textarea rows="6" name="damage" id="damage" cols="37" class="txt"></textarea>
</div>
<input type="hidden" name="thanks" value="../thanks.php" />
<input type="hidden" name="required_fields" value="firstname, lastname, email, phone" />
<input type="hidden" name="html_template" value="testform.tpl.html" />
<input type="hidden" name="mail_template" value="testmail.tpl.txt" />
<div class="submit">
<center>
<input type="submit" value="Submit Form" name="Submit" id="Submit" />
</center>
</div>
</fieldset>
</form>
Then it sends to a file named index.php inside the "form" folder:
<?php
$script_root = './';
$referring_server = 'www.wmsgroup.com, wmsgroup.com, scripts';
$allow_empty_referer = 'yes'; // (yes, no)
$language = 'en'; // (see folder 'languages')
$ip_banlist = '';
$ip_address_count = '0';
$ip_address_duration = '48';
$show_limit_errors = 'yes'; // (yes, no)
$log_messages = 'no'; // (yes, no)
$text_wrap = '65';
$show_error_messages = 'yes';
$attachment = 'no'; // (yes, no)
$attachment_files = 'jpg, gif,png, zip, txt, pdf, doc, ppt, tif, bmp, mdb, xls, txt';
$attachment_size = 100000;
$path['logfile'] = $script_root . 'logfile/logfile.txt';
$path['upload'] = $script_root . 'upload/'; // chmod 777 upload
$path['templates'] = $script_root . 'templates/';
$file['default_html'] = 'testform.tpl.html';
$file['default_mail'] = 'testmail.tpl.txt';
/*****************************************************
** Add further words, text, variables and stuff
** that you want to appear in the templates here.
** The values are displayed in the HTML output and
** the e-mail.
*****************************************************/
$add_text = array(
'txt_additional' => 'Additional', // {txt_additional}
'txt_more' => 'More' // {txt_more}
);
/*****************************************************
** Do not edit below this line - Ende der Einstellungen
*****************************************************/
/*****************************************************
** Send safety signal to included files
*****************************************************/
define('IN_SCRIPT', 'true');
/*****************************************************
** Load formmail script code
*****************************************************/
include($script_root . 'inc/formmail.inc.php')
?>
There is also formail.inc.php, testform.tpl.php, testform.tpl.text and then the confirmation page, thanks.php
I want to know how these all work together and what the problem could be.
Your form appears to be using the GentleSource.com Form Mail package. I suggest starting from scratch with a fresh download of their source zip or tar.gz files in a subdirectory. Then run through their installation instructions, test it. Then get it customized in the way your prior form worked.
This is in response to your question "how these all work together".
The user enters information on quote.php page. When the page is submitted, it is sent to form/index.php for processing. This file does some checks and formats the information entered two ways, one way for html email using the template testform.tpl.php and a second way for text email using the form testform.tpl.text. The information is then passed to formmail.inc.php which sends the email and then to thanks.php which displays the response to the user.
What the problem could be? Look at the formmail.inc.php file and make sure that it is properly configured for your server and php installation.
You should make sure that the e-mail addresses in the mail template mail.tpl.txt have the correct format. E-mail addresses should be in angle brackets:
From: <visitor#example.com>
If you're using the fields firstname and lastname, they need to be in quotes:
From: "{firstname} {lastname}" <vistor#example.com>
Other possibilities, why the script won't send e-mails: Windows server with no MTA. Mails get caught by a spam filter somewhere on the way.
You should test if the server can even send e-mails:
<?php
mail('your-email#example.com', 'Test-Subject', 'Test-Message');
?>
Related
I am making a basic new customer database with mysql and php. I would like when people click on the radio button"different mailing address" for another couple of input fields to appear for the mailing address. Im not quite sure how to handle this with inputs and not variables. Is there a way to do an if statement here is my html form code below
<form method="POST" action="insert.php">
<fieldset>
<legend>New Customer data</legend>
<label>Complete Below</label>
<div class="controls controls-row">
<input class="span4" name="firstname" type="text" placeholder="First name">
<input class="span3" name="lastname" type="text" placeholder="Last Name">
<input class="span3" name="phone" type="text" placeholder="Phone">
</div>
<div class="controls controls-row">
<input class="span4" name="address" type="text" placeholder="Address">
<input class="span2" name="city" type="text" placeholder="City">
<input class="span1" name="state" type="text" placeholder="State">
</div>
<div class="controls controls-row">
<input class="span4" name="zip" type="text" placeholder="Zip Code">
<input class="span2" name="email" type="text" placeholder="Email">
<input class="span2" name="ccemail" type="text" placeholder="cc email">
</div>
<span class="help-block">When is the customers due date monthly</span>
<label class="radio">
<input type="radio" name="duedate" id="optionsRadios1" value="1" checked>
1st of the month</label>
<label class="radio">
<input type="radio" name="duedate" id="optionsRadios2" value="15">
15th of the month
</label>
<span class="help-block">Mailing address</span>
<label class="radio">
<input type="radio" name="mailingaddress" id="optionsRadios3" value="1" checked>
Check if mailing address is the same as the service address
</label>
<label class="radio">
<input type="radio" name="mailingaddress" id="optionsRadios4" value="0">
Check if mailing address is different
</label>
<button type="submit" class="btn btn-primary">Submit</button>
</fieldset>
</form>
Using jQuery, have two inputs that are initially hidden. Once the user checks the box, '$.show()' on those two inputs. Id have a div containing two inputs, and just show or hide the div depending on whether the box is checked or not
you can try this.
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" >
</script>
<script>
$(document).ready(function(){
$("#checkme").on('change',function(){
if($("#checkme").is(":checked")){
$("input#myemail").fadeIn();
}else{
$("input#myemail").fadeOut();
}
});
});
</script>
</head>
<body>
show: <input type="checkbox" id="checkme" /><br />
<input type="text" id="myemail" hidden />
</body>
</html>
I'm totally new to php and I am trying to dynamically change the form displayed when the user makes a choice on a drop down list. I can get the drop down list to show but it does not display anything when I submit.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<title>Forms</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<?php
If (!isset($_GET['userChoice']))
{ //open the if block to write the html to the screen
?>
<h1>Show your html option form</h1>
<form method="GET" action="thirdtry.php" name="userChoice">
<select size="1" id="choice" name="choice">
<option selected="selected">Choose which form you would like</option>
<option value="feedback">Feedback Form </option>
<option value="help">Help Request Form</option>
</select>
<input type="submit">
</form>
<?php
}//close the if block
else{ //show feedback
if($_GET['userChoice']=="feedback")
{
?>
<h1>Show the feedback form</h1>
<form id="fb" name="fb" method="post" >
<fieldset>
<label>First Name:
<br />
<input type="text" name="fName" id="fName" />
</label>
<br />
<label>Last Name:
<br />
<input type="text" name="lName" id="lName" />
</label>
<br />
<label>Street Address:
<br />
<input type="text" name="address" id="address" />
</label>
<br />
<label>City
<br />
<input type="text" name="city" id="city" />
</label>
<br />
<label>State
<br />
<input type="text" name="state" id="state" />
</label>
<br />
<label>Postcode
<br />
<input type="text" name="postcode" id="postcode" />
</label>
<br />
<label>Country
<br />
<input type="text" name="country" id="country" />
</label>
<br />
<label>Email Address:
<br />
<input type="text" name="FromAddress" id="FromAddress" />
</label>
<br />
<label>Your message:
<br />
<textarea name="message" rows="7" cols="30"></textarea> <br />
</label>
<div>How many stars would you give this site? <br />
(We love 5 stars!)<br />
<input type="radio" name="rating" value="1" />1<br />
<input type="radio" name="rating" value="2" />2<br />
<input type="radio" name="rating" value="3" />3<br />
<input type="radio" name="rating" value="4" />4<br />
<input type="radio" name="rating" value="5" />5<br />
</div>
<br />
<input type="submit" />
<input type="reset" />
</fieldset>
</form>
<?php
}
else
{//must be help form
?>
<h1>Show the help form</h1>
<form id="help" method="post" >
<fieldset>
<label>First Name:
<br />
<input type="text" name="fNameHelp" id="fNameHelp" />
</label>
<br />
<label>Last Name:
<br />
<input type="text" name="lNameHelp" id="lNameHelp" />
</label>
<br />
<label>Street Address:
<br />
<input type="text" name="addressHelp" id="addressHelp" />
</label>
<br />
<label>City
<br />
<input type="text" name="cityHelp" id="cityHelp" />
</label>
<br />
<label>State
<br />
<input type="text" name="stateHelp" id="stateHelp" />
</label>
<br />
<label>Postcode
<br />
<input type="text" name="postcodeHelp" id="postcodeHelp" />
</label>
<br />
<label>Country
<br />
<input type="text" name="countryHelp" id="countryHelp" />
</label>
<br />
<label>Email Address:
<br />
<input type="text" name="FromAddress" />
</label>
<br />
<label>Your message:
<br />
<textarea name="messageHelp" rows="7" cols="30"> </textarea> <br />
</label>
<div>How Would you like to be contacted?<br />
(Choose all that apply) <br />
<input type="checkbox" name="ckemail" id="ckemail" value="email" onclick="return validateHelpForm()"/>email<br />
<input type="checkbox" name="cktelephone" id="cktelephone" value="telephone" onclick="return validateHelpForm()"/>telephone<br />
</div>
<br />
<input type="submit" />
<input type="reset" />
</fieldset>
</form>
<?php
}//close the if block
}
?>
</body>
</html>
You're checking for the wrong variable:
If (!isset($_GET['userChoice']))
should be
If (!isset($_GET['choice']))
Also, why are you capitalizing If? (That won't cause an issue - it's just weird ;)
Well first off, do you want the page to refresh, or would you like it to change dynamically without a refresh, using Javascript. From your brief description, I am thinking you want the change to happen without a refresh.
And being a "novice", I would advise you use Jquery as your Framework as opposed to full blown javascript. Here is what I think you're trying to accomplish.
Since PHP is a server-side programming language, you can't dynamically change a webpage without a refresh. Javascript and Jquery are client-side, so many things can happen in your browser without the need or a refresh.
LINK: Here is the example I just created.
////////jquery/javascript///////
$('#changeme').change(function(){
var value = $('#changeme').val();
if(value == 1){
$('#dis1').show();
$('#dis2').hide();
}
else if(value == 2){
$('#dis1').hide();
$('#dis2').show();
}
else{
$('#dis1').hide();
$('#dis2').hide();
}
});
////////HTML///////
<select id="changeme">
<option value=""></option>
<option value="1">1</option>
<option value="2">2</option>
</select>
<div style="display:none;" id="dis1">Displaying 1</div>
<div style="display:none;" id="dis2">Displaying 2</div>
I've got a simple one-page form, the kind I've written dozens of times, but this behavior is totally new to me. At first, it was submitting on page-load, thus redirecting automatically to the next page in the series. I'm still not sure how I got that to stop, but now it's not doing anything at all when you hit "submit". The page simply sits there.
I've tried stripping out the error-checking scripts, the show/hide script, even jquery itself, then taking the form down to just one input. I tried getting rid of the redirect and just having it output a simple line, then vardump, and still nothing. I hit submit, and no matter what I do, the page just sits there. I've never run into behavior like this before, and firebug et al give me no errors or leads.
If anyone has any ideas at all, no matter how crazy, I'm willing to try. I'm at a loss. Thanks in advance!
<?php
session_start();
include('functions.php');
if ($_POST['submit']) {
$company = $_POST['company'];
$taxid = $_POST['taxid'];
header("location:step2.php");
}
include('head.php'); ?>
<form method="post" name="basic" action="step1.php">
<div class="col70">
<label for="company">Organization/Business name <img src="img/req.jpg" alt="required"></label>
<input type="text" name="company" id="company" value="" />
</div>
<div class="col30">
<label for="taxid">Taxpayer ID# (IEN or SS#) <img src="img/req.jpg" alt="required"></label>
<input type="text" name="taxid" id="taxid" value="" />
</div>
<div class="newcol">
<label for="address">Mailing Address <img src="img/req.jpg" alt="required"></label>
<input type="text" name="address" id="address" value="" />
</div>
<div class="col30 newcol">
<label for="city">City <img src="img/req.jpg" alt="required"></label>
<input type="text" name="city" id="city" value="" />
</div>
<div class="col30">
<label for="state">State <img src="img/req.jpg" alt="required"></label>
<select name="state" id="state" tabindex="<?php echo $tabin; $tabin++; ?>">
<option value="0"></option>
<option value="1">Alabama</option>
</select>
</div>
<div class="col25">
<label for="zipcode">Zip Code <img src="img/req.jpg" alt="required"></label>
<input type="text" name="zipcode" id="zipcode" value="" />
</div>
<fieldset><legend>1. What kind of group/company do you have? <img src="img/req.jpg" alt="required"></legend>
<span id="nfpfp" class="InputGroup">
<label><input name="nfpfp" id="nfpfp_1" type="radio" value="1" />For-profit business.</label>
<label><input name="nfpfp" id="nfpfp_2" type="radio" value="2" />Non-profit 501(c)3 organization.</label>
</span>
</fieldset>
<fieldset><legend>2. How will you use the booth space? Select all that apply. <img src="img/req.jpg" alt="required"></legend>
<span id="type" class="InputGroup">
<label><input name="food" id="type_1" type="checkbox" value="1" />Food sales</label>
<label><input name="retail" id="type_2" type="checkbox" value="2" />Retail sales</label>
<label><input name="activity" id="type_3" type="checkbox" value="3" />Activity</label>
<label><input name="display" id="type_4" type="checkbox" value="4" />Display</label>
<label><input name="other" id="type_5" type="checkbox" value="5" />Other</label>
</span>
</fieldset>
<label for="otherdetails" class="newcol offsides">Enter a short description of your use. (Ex: "BBQ sandwiches", "kite kits", "face painting".) <img src="img/req.jpg" alt="required"></label>
<input type="text" name="otherdetails" id="otherdetails" value="" />
<fieldset><legend>3. Select any/all that apply. Additional questions may appear, if further information is required.</legend>
<span id="additional" class="InputGroup">
<label><input name="raffle" id="raffle_1" type="checkbox" class="switchcheck1" value="1" />I'll be selling raffle tickets and/or holding a raffle at the festival.</label>
<div class="newcol offstate1">
<label for="raffledetails">You'll need written permission from the Exchange Club. Please enter details about the raffle. <img src="img/req.jpg" alt="required"></label>
<textarea name="raffledetails" id="raffledetails" tabindex="<?php echo $tabin; $tabin++; ?>"></textarea>
</div>
<label><input name="trailer" type="checkbox" id="trailer_1" value="1">I'll be bringing a trailer.</label>
<label><input name="outlets" type="checkbox" id="outlets_1" class="switchcheck2" value="1" />I'll require electrical outlets.</label>
<div class="newcol offstate2">
<label for="outletsdetails">How many outlets will you require? <img src="img/req.jpg" alt="required"></label>
<input type="text" name="outletsdetails" id="outletsdetails" />
</div>
</span>
</fieldset>
<input type="button" name="submit" class="a_button" value="submit" />
</form>
The element with name="submit" is of type button and not submit, so it renders a plain button that does nothing (with the intention that you bind some JavaScript to it).
Use type="submit" instead.
Try
<input type="submit" name="submit" class="a_button" value="submit" />
for your submit button.
I've recently developed a website for a freelance client of mine, and within their website is a Contact Form and a Request for Estimate form.
Once a day, both forms are being submitted and emailed to the designated email address. However, the submitted forms are clearly not from a real user, this is because all of the fields contain the number 1. For example, the name field will be Name:1, and the address field will be Address:1. The number 1 is repeated for all input text fields, and even radio and check box form fields.
Below is a copy of the PHP file that I am using to submit the Request for Estimate form.
<?
$subject="Associated Sennott Contractors Request For Estimate From:".$_GET['firstname'];
$headers= "From: ".$_GET['email']."\n";
$headers.='Content-type: text/html; charset=iso-8859-1';
mail("email#gmail.com", $subject, "
<html>
<head>
<title>Associated Sennott Contractors Request For Estimate</title>
</head>
<body>
<p><strong>Associated Sennott Contractors Request For Estimate</strong></p>
<p>
First Name: ".$_GET['firstname']." <br />
Last Name: ".$_GET['lastname']." <br />
Company Name: ".$_GET['company']." <br />
Address 1: ".$_GET['address1']." <br />
Address 2: ".$_GET['address2']." <br />
City: ".$_GET['city']." <br />
State: ".$_GET['state']." <br />
Zip: ".$_GET['zip']." <br />
Phone: ".$_GET['phone']." <br />
Fax: ".$_GET['fax']." <br />
Email: ".$_GET['email']." <br /><br />
<strong>Property Type:</strong><br />
Residential Single Family: ".$_GET['singlefamily']." <br />
Residential Multi-Family: ".$_GET['multifamily']." <br />
Residential Out-Building : ".$_GET['outbuilding']." <br />
Commercial Office: ".$_GET['commercial']." <br />
Retail Store: ".$_GET['retail']." <br />
Restaurant: ".$_GET['restaurant']." <br />
Industrial Building: ".$_GET['industrial']." <br /><br />
<strong>Requested Services:</strong><br />
Fire, Water or Wind Damage Restoration: ".$_GET['restoration']." <br />
Scope of Loss Estimate to Insurance Company: ".$_GET['scope']." <br />
Smoke Odor Remediation: ".$_GET['smoke']." <br />
Exterior Remodeling or Siding: ".$_GET['exterior']." <br />
Interior Remodeling: ".$_GET['interior']." <br />
Hardwood and Laminate Flooring: ".$_GET['flooring']." <br />
Finish Carpentry: ".$_GET['carpentry']." <br />
Demolition and Debris Removal: ".$_GET['demo']." <br />
Exterior Decks, Patios and Fencing: ".$_GET['patio']." <br />
Other: ".$_GET['other']." <br /><br />
<strong>Additional Information:</strong><br />
Message: ".$_GET['info']."
</p>
</body>
</html>" , $headers);
header( 'Location: thankyou.html' ) ;
?>
You can also view the PHP code by follow the link here: http://sennottcontractors.com/home-repair-estimate/quote-code.html
You can then view the HTML code for the actual form below:
<!DOCTYPE>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Request An Estimate Form</title>
<script type="text/javascript">
function formSubmit()
{
document.getElementById("estimate-form").submit();
}
</script>
</head>
<body>
<fieldset>
<legend><h3>Request a Home Restoration Estimate</h3></legend>
<form id="estimate-form" name="estimate-form" target="_parent" method="get" action="quote.php" onsubmit='return formValidator()'>
<p><strong>Contact Information</strong></p>
<p>First Name: *<br />
<input type="text" size="40" name="firstname" id="firstname" /></p>
<p>Last Name: *<br />
<input type="text" size="40" name="lastname" id="lastname" /></p>
<p>Company Name:<br />
<input type="text" size="40" name="company" id="company" /></p>
<p>Address 1: *<br />
<input type="text" size="40" name="address1" id="address1" /></p>
<p>Address 2:<br />
<input type="text" size="40" name="address2" id="address2" /></p>
<p>City: *<br />
<input type="text" size="30" name="city" id="city" /></p>
<p>State: *<br />
<input type="text" size="5" name="state" id="state" /></p>
<p>Zip: *<br />
<input type="text" size="10" name="zip" id="zip" /></p>
<p>Phone: *<br />
<input type="text" size="20" name="phone" id="phone" /></p>
<p>Fax:<br />
<input type="text" size="20" name="fax" id="fax" /></p>
<p>Email: *<br />
<input type="text" size="40" name="email" id="email" /></p>
<br />
<p><strong>Property Type</strong> *</p>
<p><input type="checkbox" name="singlefamily" id="singlefamily"/> Residential Single Family</p>
<p><input type="checkbox" name="multifamily" id="multifamily"/> Residential Multi-Family <em>(Condominium, apartment, town house, ect)</em></p>
<p><input type="checkbox" name="outbuilding" id="outbuilding"/> Residential Out-Building <em>(Garage, shed, ect)</em></p>
<p><input type="checkbox" name="commercial" id="commercial"/> Commercial Office</p>
<p><input type="checkbox" name="retail" id="retail"/> Retail Store</p>
<p><input type="checkbox" name="restaurant" id="restaurant"/> Restaurant</p>
<p><input type="checkbox" name="industrial" id="industrial"/> Industrial Building</p>
<br />
<p><strong>Requested Services</strong> *</p>
<p><input type="checkbox" name="restoration" id="restoration"/> Fire, Water or Wind Damage Restoration</p>
<p><input type="checkbox" name="scope" id="scope"/> Scope of Loss Estimate to Insurance Company</p>
<p><input type="checkbox" name="smoke" id="smoke"/> Smoke Odor Remediation</p>
<p><input type="checkbox" name="exterior" id="exterior"/> Exterior Remodeling or Siding</p>
<p><input type="checkbox" name="interior" id="interior"/> Interior Remodeling</p>
<p><input type="checkbox" name="flooring" id="flooring"/> Hardwood and Laminate Flooring</p>
<p><input type="checkbox" name="carpentry" id="carpentry"/> Finish Carpentry</p>
<p><input type="checkbox" name="demo" id="demo"/> Demolition and Debris Removal</p>
<p><input type="checkbox" name="patio" id="patio"/> Exterior Decks, Patios and Fencing</p>
<p><input type="checkbox" name="other" id="other"/> Other</p>
<br />
<p><strong>Additional Information</strong><br />
Please provide any information regarding details of your home restoration project or additional information to your requested services.</p>
<p><textarea rows="10" cols="65" id="info" name="info"></textarea></p>
<button type="submit" id="submit" onclick="formSubmit()">Submit</button>
</form>
<p>* Required Fields</p>
</fieldset>
</body>
</html>
The Request an Estimate form that is using the PHP file and code mentioned above you can view by following the link here: http://sennottcontractors.com/home-repair-estimate/index.html
Again, both the Request an Estimate form and the Contact Form are being submitted once a day, everyday, with the number 1 in every form field.
My guess is that this may be an issue with the PHP file itself, or it may be an issue from the server side of the hosted website.
Please help!!!
There's nothing technically wrong with your form. You said the cause of the issue yourself: "... the submitted forms are clearly not from a real user ...". So the solution is to make your form anti-bot. See this question on the pro Webmasters site for how you can do this: Make your site anti-bot?
One part of this problem is that you need to use a form nonce or "token".
Form.php
<?php
session_start();
$_SESSION['token'] = md5(mt_rand() . unique_id('form', TRUE));
...
?>
<form>
<input type="hidden" value="<?php print $_SESSION['token']; ">
...
</form>
process.php
<?php
session_start();
if($_SESSION['token'] !== $_POST['token'])
{
die('They did not load the form!');
}
...
(validation)
...
$db->insert($record);
You're not doing any validation. What do you expect?
Anyone could just grab the form fields, create the URL (because you're using GET instead of POST), and submit it ad nauseum if they wanted to. What you're probably encountering is a bot trying to figure out if it can hijack your form to send emails where it wants to send them.
What you should do is switch to using POST and check the $_SERVER['HTTP_REFERER'] variable to make sure it's coming from your form (at least). You could also use a CAPTCHA, but those are becoming increasingly unreliable. You could take this further and use a validation class to set rules for each field and what kind of data is allowed to be in each one.
Forms are easily manipulated, so if you expect to have any integrity in your form submissions, you should be doing the validation on the server-side. Client-side validation doesn't hurt, but only use it for user experience purposes, not to ensure data integrity.
First of all thanks in advance, this has been very frustrating and I'm hoping someone can see something I'm not, I am definitely no php expert. Well here' what is going on.
I have a form where I have a checkbox for people to opt in to our newletter. The form element looks like this:
<label for=newsletter accesskey=N class="checkbox">Signup for Cloverton's Newsletter</label>
<input name="newsletter" type="checkbox" id="newsletter" value="Yes" style="width:20px;" />
That is then submitted to a php file with this code:
if (isset($_POST['newsletter']) && $_POST['newsletter'] == 'Yes'){
echo "newletter yes";
$newsletter = 1;
}else{
echo "newsletter no";
$newsletter = 0;
}
$newsletter is then inserted into a database field.
The issue is that whether the box is checked or not it is being sent to php as true, so every entry is receiving the newsletter.
Any help would be greatly appreciated! Thanks!
Here's the full form minus the option list for the sake of brevity
<form method="post" action="contact.php" name="contactform" id="contactform">
<fieldset>
<legend>Please fill in the following form all fields are required, thanks!</legend>
<label for=firstName accesskey=F><span class="required">*</span>First Name</label>
<input name="firstName" type="text" id="firstName" size="30" value="" />
<br />
<label for=lastName accesskey=L><span class="required">*</span>Last Name</label>
<input name="lastName" type="text" id="lastName" size="30" value="" />
<br />
<label for=email accesskey=E><span class="required">*</span>Email</label>
<input name="email" type="text" id="email" size="30" value="" />
<br />
<label for=city accesskey=C><span class="required">*</span>City</label>
<input name="city" type="text" id="city" size="30" value="" />
<br />
<label for=state accesskey=S><span class="required">*</span>State</label>
<select name="state" type="text" id="state">
<option value="AL">Alabama</option>
...
<option value="WY">Wyoming</option>
</select>
<br />
<label for=newsletter accesskey=N class="checkbox">Signup for Cloverton's Newsletter</label>
<input name="newsletter" type="checkbox" id="newsletter" value="Yes" style="width:20px;" />
<br />
<p><span class="required">*</span> Are you human?</p>
<label for=verify accesskey=V> 3 + 1 =</label>
<input name="verify" type="text" id="verify" size="4" value="" style="width: 30px;" /><br /><br />
<input type="submit" class="submit" id="submit" value="Submit" />
</fieldset>
</form>
Your code is correct. You most likely have a problem with your database insert/update logic. Why do you assume it is the PHP form handling?
This has just dawned on me.
If a checkbox is unchecked it isn't set in the $_POST superglobal. So if !isset($_POST['newsletter']) then it wasn't checked - if isset($_POST['newsletter']) it was checked.
Edit: Remove the 'yes' part - the value will never be yes, just true or 'on'.
Edit 2:
I've tested this to death. Change your code to:
if (isset($_POST['newsletter'])){
echo "newletter yes";
$newsletter = 1;
}else{
echo "newsletter no";
$newsletter = 0;
}
Remove the value="Yes" attribute from your checkbox input also. If you want it checking by default use checked="checked".