/    Sign up×
Community /Pin to ProfileBookmark

Mail Sends a Blank Copy Before Filled

I have a contact form that works, accept that it keeps sending an extra, blank email before the email with the customers info. Anyone run into this problem before?
PHP:

[CODE]<?php

$msg = “Residences Information Requestnn”;
$msg .=”Resort : “.$_REQUEST[‘requiredplease_select_resort’].”n”;
$msg .=”Name : “.$_REQUEST[‘requiredname’].”n”;
$msg .=”Address 1 : “.$_REQUEST[‘requiredaddress_1’].”n”;
$msg .=”City : “.$_REQUEST[‘requiredcity’].”n”;
$msg .=”State : “.$_REQUEST[‘state’].”n”;
$msg .=”Zip Code : “.$_REQUEST[‘requiredzip’].”n”;
$msg .=”Country : “.$_REQUEST[‘requiredcountry’].”n”;
$msg .=”Telephone : “.$_REQUEST[‘requiredtelephone’].”n”;
$msg .=”Email : “.$_REQUEST[‘requiredemail’].”n”;
$msg .=”Best Time to Call Me : “.$_REQUEST[‘time_to_call’].”n”;
$msg .=”Message: “.$_REQUEST[‘message’].”n”;
$msg .=”Yes, A Representative May Contact Me : “.$_REQUEST[‘checkbox’].”n”;

$msg .= “nn”;

$to = “[email protected]”;
$subject = “Beac”;
$mailheaders = “From : Beachside Key West Web n”;
$mailheaders .= “Reply-To : “.$_REQUEST[’email’].”nn”;

$success = mail($to, $subject, $msg, $mailheaders);

?>[/CODE]

HTML:

[CODE] <form name=”contact” onSubmit=”return checkrequired(this)” method=”post” action=”contact.php”>
<th colspan=”2″ class=”header_contact” scope=”col”><p>Please Select the Resort You Are Interested In:<br/></p></th>
<th colspan=”4″ class=”header_contact” scope=”col”><div align=”left”>
<select name=”requiredplease_select_resort” id=”select2″>
<option value=”Please Select:” selected=”selected”>Please Select:</option>
<option value=”Beachside”>Beachside</option>
<option value=”Coconut Beach Resort”>Coconut Beach Resort</option>
<option value=”Faro Blanco Resort &amp; Yacht Club”>Faro Blanco Resort &amp; Yacht Club</option>
<option value=”Banyon Grove”>Banyan Grove</option>
</select>
</div></th>
</tr>
<tr class=”contact”>
<td width=”53″ class=”contact”><div align=”right”>Name:</div></td>
<td colspan=”5″><label>
<input name=”requiredname” type=”text” id=”name” size=”25″ />
</label></td>
</tr>
<tr class=”contact”>
<td class=”contact”><div align=”right”>Address: </div></td>
<td colspan=”5″><label>
<input name=”requiredaddress_1″ type=”text” id=”address_1″ size=”50″ />
</label></td>
</tr>
<tr>
<td height=”21″ class=”contact”><div align=”right”>City:</div></td>
<td width=”206″ class=”contact”><label>
<input name=”requiredcity” type=”text” id=”city” size=”25″ />
</label></td>
<td width=”35″ class=”contact”><div align=”right”>State:</div></td>
<td width=”56″ valign=”top” class=”contact”><select name=”state” id=”state”>
<option value=”Alaska”>AK</option>
<option value=”Alabama”>AL</option>
<option value=”Arkansas”>AR</option>
<option value=”Maryland”>MD</option>
<option value=”West Virginia”>WV</option>
<option value=”Wyoming”>WY</option>
</select></td>
<td width=”18″ class=”contact”><div align=”right”>Zip:</div></td>
<td width=”104″ valign=”middle”><label>
<input name=”requiredzip” type=”text” size=”11″ />
</label></td>
</tr>
<tr class=”contact”>
<td class=”contact”><div align=”right”>Country:</div></td>
<td colspan=”5″><label>
<input name=”requiredcountry” type=”text” id=”country” size=”25″ />
</label></td>
</tr>
<tr class=”contact”>
<td class=”contact”><div align=”right”>Phone:</div></td>
<td colspan=”5″><label>
<input name=”requiredtelephone” type=”text” id=”telephone” size=”25″ />
</label></td>
</tr>
<tr>
<td class=”contact”><div align=”right”>Email:</div></td>
<td class=”contact”><label>
<input name=”requiredemail” type=”text” id=”email” size=”25″ />
</label></td>
<td><div align=”left”><input name=”submit” type=”submit” class=”button” value=”Submit” /></div></td>
</form>[/CODE]

Cheers!

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@flannAug 10.2007 — I can't see anything that would cause it to send a blank email first. However I do recommend using $_POST instead of $_REQUEST, and also sanitizing your variables as well.

I've always ran into trouble using the built in mail function, I've been using htmlmimemail5 for awhile now and haven't had any issues with that.
Copy linkTweet thisAlerts:
@lawbird123authorAug 10.2007 — thanks, flann!

Im not sure what you mean by "sanitizing" though. Im still new to all this grand stuff.
Copy linkTweet thisAlerts:
@flannAug 12.2007 — You sanitize you post variables when you make sure nobody can inject anything into your site that you don't want. Depending on what you're doing, you'll have to consider different techniques. However here is my default sanitize function.

[code=php]
function sanitize_post($v) {
return htmlentities(stripslashes(strip_tags($v)));
}

$variable = sanitize_post($_POST['var']);
[/code]


This simply combines 3 built in functions into 1. Goto php.net and look up each one of these functions to see exactly what they do.
×

Success!

Help @lawbird123 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...