ARTICLES

Php feedback form problem

tnan January 4, 2006 at 19:58:19 Pacific
winxp, 2.4/1gb

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

?>



Google Ads

#1
+1
Stephen Hall January 4, 2006 at 20:01:48 Pacific

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...!"



#2
+1
tnan January 4, 2006 at 20:22:24 Pacific

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!



#3
+1
SN January 4, 2006 at 21:16:18 Pacific

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



Google Ads
Start New Discussion Reply to Message Icon
Related Posts

« Blog and Gallery Software making javascript libs? »


This post is quite old and has been locked from receiving new replies. Please create a new posting instead.



Ask the Community!
Describe your Problem
Example: Hard Drive Not Detected on My PC


Google Ads



Results for: Php feedback form problem

Php form problem (non static) www.computing.net/answers/webdevel/php-form-problem-non-static/1420.html

User Feedback Forms www.computing.net/answers/webdevel/user-feedback-forms/3306.html

Php email form www.computing.net/answers/webdevel/php-email-form/4380.html