PDA

View Full Version : PHP Problem



muddywaters
05 Jul 2010, 07:34 PM
Hi everyone,

I'm trying to set up a "simple" html/PHP email form which will allow clients to send their email to me to subscribe to a monthly newsletter. I'm using Dreamweaver CS4.

I preview my form.html page in browser (Firefox), fill in the fields and click "Submit". But immediately Firefox begins opening up continuous untitled/blank web pages and I have to shut down Firefox altogether. I tried it with Safari and a similar problem happened.

I'm very new to PHP and copied the html and php code from a free site and tweaked it to suit my needs but found it not as simple as the site suggested. Does my webpage need to be uploaded and live for this to work???

The html code is as follows...

<form method="post" action="sendmail.php">

Name: <input name="name" type="text" /><br />

Email: <input name="email" type="text"/><br />

<input type="submit" />

</form>

The PHP code is as follows...

<?php

$name = $_REQUEST['name'] ;

$email = $_REQUEST['email'] ;

mail( "myemailaddress@gmail.com", "Feedback Form Results",
$name$email, "From: $email" );

header( "Location: http://www.google.com" );

?>

**I have put my proper email address and header in my original script.

Do I need to have a html header/title etc for my PHP file? Any help would be much appreciated.

Dave

is_numeric
06 Jul 2010, 05:11 AM
Your PHP email script needs to be live as it uses an SMTP server to send out the mail. I am guessing you don't have one on your local environment.

your code....


Best practice... You should have a value attribute in your submit button tag
Best practice... Use $_POST not $_REQUEST
Best practice... include an EXIT after your HEADER redirect