PDA

View Full Version : Blank email form submissions along with filled in forms


sydesign
01-17-2011, 01:19 AM
I am kinda new to websites and coding, but i recently got a new client and I was working on a form on their site with many different categories.

I set up the form and it works and i do have validation set up but along whenever a person fills in the form another 10 or so blank emails are sent along with it.

this may have a correlation to the filled in form that is sent or i feel it may be spam or some sort of bot that is somehow sending blank forms even though the form is validated and should not be able to be sent without anything filled in.

Any ideas what the problem could be? Is it possible that maybe it is a bot visiting the php page and that is somehow sending a blank form?

any ideas?? any help is greatly appreciated!

edbr
01-17-2011, 04:47 AM
post the php sctipt

sydesign
01-17-2011, 04:49 AM
<?php

/* Email Variables */
$emailSubject = 'XXXXXXXXXXX'; /*Make sure this matches the name of your file*/
$webMaster = 'XXXXX@aol.com';


/* Data Variables */

$pickupcityField = $_POST['pickupcity'];
$stateField = $_POST['state'];
$zipcodeField = $_POST['zipcode'];
$pickuptimeField = $_POST['time_pick'];
$pickupdateField = $_POST['date1'];
$passengersField = $_POST['passenger_pick'];
$destinationcityField = $_POST['city_destination'];
$destinationstateField = $_POST['state1'];
$departuretimeField = $_POST['departure_time'];
$departuredateField = $_POST['date2'];
$stateField = $_POST['state'];
$passengerdestinationField = $_POST['passenger_dest'];
$phoneField = $_POST['phone'];
$email = $_POST['email'];
$commentsField = $_POST['comments'];


$body = <<<EOD
<br><hr><br>
Email: $email <br>
Phone: $phoneField <br>
Pick Up City: $pickupcityField <br>
Pick Up State: $stateField <br>
Zipcode: $zipcodeField <br>
Pick Up Time: $pickuptimeField <br>
Pick Up Date: $pickupdateField <br>
Passengers: $passengersField <br>
Destination City: $destinationcityField <br>
Destination State: $destinationstateField <br>
Departure Time Field: $departuretimeField <br>
Departure Date: $departuredateField <br>
State: $stateField <br>
Passengers Destination: $passengerdestinationField <br>
Comments: $commentsField <br>
EOD;

$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($webMaster, $emailSubject, $body,
$headers);


/* Results rendered as HTML */
$theResults = <<<EOD
<html>
<head>
<title>sent message</title>
<meta http-equiv="refresh" content="4;http://www.XXXXXXX.org/">
<style type="text/css">
<!--
body {
background-color: #444; /* You can edit this CSS to match your website*/
font-family: "Arial";
font-size: 20px;
font-style: normal;
line-height: normal;
font-weight: normal;
color: #FFF;
text-decoration: none;
padding-top: 200px;
margin-left: 150px;
width: 800px;
}
-->
</style>
</head>
<div align="center">Thank you! Your email will be answered as soon as possible! You will return to XXXXXX in a few seconds.</div>
</div>
</body>
</html>
EOD;
echo "$theResults";
?>

edbr
01-17-2011, 05:30 AM
no that looks fine i have no idea what would be causing multiples your thought re spam bot may be valid, you could validata against an empty field or more, maybe you should think about adding a captcha image also

sydesign
01-17-2011, 05:42 AM
okay thank you very much for your help!

i saw this as an option, i believe its an if statement to check and make sure the submit button on the form was actually clicked and the php file wasn't found directly.

do you think this is correct? and did i place it in the right spot? at the beginning and end?



<?php
if (array_key_exists('submit', $_POST)) {

/* Email Variables */
$emailSubject = 'xxxxxxxxx'; /*Make sure this matches the name of your file*/
$webMaster = 'xxxxxxxx@aol.com';


/* Data Variables */

$pickupcityField = $_POST['pickupcity'];
$stateField = $_POST['state'];
$zipcodeField = $_POST['zipcode'];
$pickuptimeField = $_POST['time_pick'];
$pickupdateField = $_POST['date1'];
$passengersField = $_POST['passenger_pick'];
$destinationcityField = $_POST['city_destination'];
$destinationstateField = $_POST['state1'];
$departuretimeField = $_POST['departure_time'];
$departuredateField = $_POST['date2'];
$stateField = $_POST['state'];
$passengerdestinationField = $_POST['passenger_dest'];
$phoneField = $_POST['phone'];
$email = $_POST['email'];
$commentsField = $_POST['comments'];


$body = <<<EOD
<br><hr><br>
Email: $email <br>
Phone: $phoneField <br>
Pick Up City: $pickupcityField <br>
Pick Up State: $stateField <br>
Zipcode: $zipcodeField <br>
Pick Up Time: $pickuptimeField <br>
Pick Up Date: $pickupdateField <br>
Passengers: $passengersField <br>
Destination City: $destinationcityField <br>
Destination State: $destinationstateField <br>
Departure Time Field: $departuretimeField <br>
Departure Date: $departuredateField <br>
State: $stateField <br>
Passengers Destination: $passengerdestinationField <br>
Comments: $commentsField <br>
EOD;

$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($webMaster, $emailSubject, $body,
$headers);


/* Results rendered as HTML */
$theResults = <<<EOD
<html>
<head>
<title>sent message</title>
<meta http-equiv="refresh" content="4;http://www.xxxxxxxxxxx.org/">
<style type="text/css">
<!--
body {
background-color: #444; /* You can edit this CSS to match your website*/
font-family: "Arial";
font-size: 20px;
font-style: normal;
line-height: normal;
font-weight: normal;
color: #FFF;
text-decoration: none;
padding-top: 200px;
margin-left: 150px;
width: 800px;
}
-->
</style>
</head>
<div align="center">Thank you! Your email will be answered as soon as possible! You will return to xxxxxx in a few seconds.</div>
</div>
</body>
</html>
EOD;
echo "$theResults";
} else {
echo "You can't see this page without submitting the form.";
}
?>