Jump to content

Problem with Receiving Unsubmitted Blank Emails from PHP


ibdrumin81

Recommended Posts

Hello,

I have recently delved into the world of PHP to avoid using the Bravenet Form Processing tool.  Everything was working great, sending a confirmation email to the end user, sending an email to me with all of the submitted fields.  Last night I finally figured out how to get the submitted fields in a mysql Database.  The problem is that a few hours after someone submits the form I will receive about 10 emails that have nothing but the text labels I have added before each of the form fields to identify them.  If it makes any difference this is coming from a form in Flash.  As you can see from my example below, I am not entering all of the submitted fields into the database.  Thanks in advance for any help anyone can give me.

Here is an example of my coded form.php file:

<?php

$con = mysql_connect("*****","*****","password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db("******", $con);
$to = "email@website.com";
$subject= "Reservation Request";
$subject2= "Your Reservation Request";

if ($field8=="No")

{
$msg= "Reservation Request Information

Party Date: $PartyDate
First Party: $FirstParty
Prev. Res. #: $ReservationNumber
His Name: $HisName
Her Name: $HerName
Email: $EmailAddress
Profile Name: $ProfileUsername
Profile Website: $ProfileWebsite

BlahBlahBlah
Guestlist: $AppearOnGuestList
Use Previous Pic: $UsePreviousPhoto

Comments: $Comments";
}

else

{
$msg= "Reservation Request Information

Party Date: $PartyDate
First Party: $FirstParty
Prev. Res. #: $ReservationNumber
His Name: $HisName
Her Name: $HerName
Email: $EmailAddress
Profile Name: $ProfileUsername
Profile Website: $ProfileWebsite

Guestlist: $AppearOnGuestList
Use Previous Pic: $UsePreviousPhoto

Comments: $Comments";
}

if ($FirstParty=="no")
{
$confirmation = "Thank You, $HisName and $HerName for your request to attend the Party on $PartyDate.

Feel free to check our Guest List for other members attending the party on $PartyDate.

Can't wait to see you there!";
}
else
{
$confirmation = "Thank You, $HisName and $HerName for your request to attend the Party on $PartyDate.
Since this is your first party, you will receive a Reservation Number in a few hours.

Feel free to check our Guest List for other members attending the party on $PartyDate.

Can't wait to see you there!";
}


mail($to, $subject, $msg, "From: Form Submission\nReply-To: $EmailAddress\n");
mail($EmailAddress, $subject2, $confirmation, "From: Form Submission\nReply-To: $to\n");


mysql_query("INSERT INTO reservations (ReservationNumber, FirstParty, ProfileUsername, HisName, HerName, EmailAddress)
VALUES ('$ReservationNumber' , '$FirstParty' , '$ProfileUsername' , '$HisName' , '$HerName' , '$EmailAddress')");

mysql_close($con);

?>
Link to comment
Share on other sites

The reason I have two mail() sets is because one of them gets sent as a confirmation to the end user who submits the form and the other gets sent to me so I have all of the data.  Everything still works fine, both emails get sent, it is just for some reason the blank emails get sent an hour or so later for no reason at all.

And also I might add that the blank emails are only going to me not to the end user's email so it is only using the first of the two mail() sets when it sends the blank emails.

One more thing I just discovered.  It looks like it is running the whole form.php file process when it is unsolicited.  I have a blank entry in my database as well.  Hope that helps.
Link to comment
Share on other sites

I just found something on another forum about using a different method to define the form fields in the PHP file.  I know with the original script I was using as a guide, users had left feedback saying that the fields need to be defined like the following to make the form work correctly, but I wasn't having a problem with just using the fields directly from the form.

i.e.

$field2= $_POST["field2"];

Could this possible have anything to do with it?
Link to comment
Share on other sites

didnt even notice that you should be posting all the varable names try
good luck.

example

do this for every varable since you got a insert sorry missed that.

but i am 99 per sent sure that the double mail is doing the double posting.

$name=addslashes($_POST['name']);
Link to comment
Share on other sites

redarrow:  I tried that method and now im not even getting any emails nor is my mysql database getting any entries.  What is the reasoning behind using the method you mentioned?  Sorry I was completely new at this about 5 days ago.

zero:  I'm using this method to post my form:

loadVariablesNum ("form.php", 0, "POST");

I know the rest of the form is working correctly its all just basicaly validation and such.

Thanks for trying to help guys.
Link to comment
Share on other sites

what version of php you got and have you got the globel settings on ?

i am asking as your comment is strange and sounds like you have globel settings on in the php.ini.

the reason for adding the post code and addslashes was that the database gets the information and no slashes are added to the entry.

also can you post your whole form as i never understood your form format cheers.

if globel settings is on it can cause problams like youve exsplain but i think that if you have the globel settings turned off your benifit from that.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.