Jump to content


Photo

Problem with Receiving Unsubmitted Blank Emails from PHP


  • Please log in to reply
11 replies to this topic

#1 ibdrumin81

ibdrumin81
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 31 August 2006 - 02:06 PM

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);

?>

#2 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 31 August 2006 - 02:16 PM

Take the database information out please.

why have you got two mail( set if one of them is to send you the information lookup headers ok.



otherwise.
The code looks good to me.


Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#3 ibdrumin81

ibdrumin81
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 31 August 2006 - 02:25 PM

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.

#4 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 31 August 2006 - 02:35 PM

look up headers that also uses a return email method ok.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#5 ibdrumin81

ibdrumin81
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 31 August 2006 - 03:19 PM

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?

#6 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 31 August 2006 - 03:21 PM

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']);
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#7 zero118

zero118
  • Members
  • PipPipPip
  • Advanced Member
  • 40 posts

Posted 31 August 2006 - 03:24 PM

Show us the form code too.

#8 ibdrumin81

ibdrumin81
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 31 August 2006 - 03:40 PM

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.

#9 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 31 August 2006 - 03:44 PM

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.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#10 ibdrumin81

ibdrumin81
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 31 August 2006 - 03:56 PM

it looks like I was using PHP Version 4.4.4

Apparently I can use 5 as well by just renaming the PHP file with the extension .php5.

Should I do that or no?

I can't seem to find where I would change the setting for GlobalSettings.

#11 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 31 August 2006 - 03:59 PM

make sure you use POST not post ok.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#12 ibdrumin81

ibdrumin81
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 08 September 2006 - 01:42 PM

Just to let everyone that tried to help me know.... The cause of the blank emails was when I would upload the .php file to my server.  Is there a way to avoid that happening?  It's not a big deal just a little annoying.

Thanks Again to all who tried to help!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users