Computing.Net > Forums > Web Development > Php feedback form problem

Php feedback form problem

Reply to Message Icon

Original Message
Name: tnan
Date: January 4, 2006 at 19:58:19 Pacific
Subject: Php feedback form problem
OS: winxp
CPU/Ram: 2.4/1gb
Comment:

I'm having a problem with my php feedback form, i've searched everywhere and to no avail...

The Problem: as soon as a user goes on my 'Feedback form' webpage I immediately receive a blank email (before they even have a chance to look and input anything)....and when they fill out their info/feedback and click on SEND, I receive another email with their info (which is what I want). So why do I get that initial blank email? Here's the php script (what's wrong with it)?

<?php
//Destination Email ID
$to = "myemailaddress";

//Name of the Person
$namenew = $_GET['name'];

//Email Id of the person
$emailnew = $_GET['email'];

//Feedback detail
$feedbacknew = $_GET['feedback'];

//Subject line of the email
$subject = "Feedback Form";

/*********** Email body *******************/
$matter = "Below are the details filled by"." "."$namenew"."\n\n".
"Name:"." "."$namenew"."\n\n".
"Email:"." "."$emailnew"."\n\n".
"Suggestion:"." "."$feedbacknew"."\n\n";
/**********************************************/

mail("$to","$subject","$matter","From: mywebsite.com");

?>


Report Offensive Message For Removal


Response Number 1
Name: Stephen Hall
Date: January 4, 2006 at 20:01:48 Pacific
Subject: Php feedback form problem
Reply: (edit)

tnan,

I can't determine anything from the code you posted. That's the PHP file that sends the e-mail, but you said it works fine after the user has pressed "Send". Where's the code for the "Send" button (the "feedback form")?

Stephen


"Live long and PROGRAM......or at least do _something_ with all that time...!"


Report Offensive Follow Up For Removal

Response Number 2
Name: tnan
Date: January 4, 2006 at 20:22:24 Pacific
Subject: Php feedback form problem
Reply: (edit)

thanks for your reply...

the feedback form was done through flash mx...but i don't think thats the problem because i would still recieve an email (even without a feedback form including) in other words if you go on the blank form.php page it will still send me an email (weird)...i'm racking my brain wandering if there's something in the php code that signifies sending the email immediately...i'm stumped!


Report Offensive Follow Up For Removal

Response Number 3
Name: SN
Date: January 4, 2006 at 21:16:18 Pacific
Subject: Php feedback form problem
Reply: (edit)

tnan-
As you've discovered, that PHP code is run every time the page is accessed - whether somebody filled out the form or whether they're just looking at it.

You can do one of two things: Separate the feedback form (an html file that contains the flash control) out from the mailing php file you posted above into separate files, or do a test in the php code to see if the form was filled out before sending the e-mail.

Something like:
<?php
if (isset($_GET['name']))
{
//your code here
}
?>

Good luck,
-SN


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Php feedback form problem

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




How often do you use Computing.Net?

Every Day
Once a Week
Once a Month
This Is My First Time!


View Results

Poll Finishes In 3 Days.
Discuss in The Lounge