Jump to content

PhP Code problem


DaveyBoy

Recommended Posts

First let me say that I did not write this php code. I'm real new at trying to write and implement a php file and a "Join our mailing list" form. I can not see what's wrong so I am asking for some help. When I click the submit button on the web page I get nothing. No mail sent, just a blank page. Can someone look at the code(s) for me and maybe correct ?

 

Here is the php code:

 

<?PHP 

if($_POST['submit']) 

{ 

$recipient="me@mywebsite.com"; 

$subject="My Web Site"; 

$body=" 

$name 

$email 



"; 

$headers='From: '.$email."\r\n".'Reply-to: '.$email."\r\n"; 

mail($recipient, $subject, $body, $headers); 

echo " 

"; 

} 

else 

{ 

echo " 

"; 

} 

?> 

 

And the form code:

 

>Untitled Document





</pre>
<table width="63%" border="2" cellpadding="4">Join Our Mailing List  NameEmailComments




   
</table>
<br

 

 

Thanks for looking!

Link to comment
Share on other sites

You need to fill the $email and $name variables with the contents of the form:

 

<?PHP 

if($_POST['submit']) 

{ 
$email = $_POST['email'];
$name = $_POST['name'];

$recipient="me@mywebsite.com"; 

$subject="My Web Site"; 
...

 

Also, your form has "Submit" while the PHP has "submit" with lower case "s", so change your form to read:

 


Link to comment
Share on other sites

Thanks folks! I have"repaired" the code and now it works fine. I want to thank all that replyed and also Stefan Mischook for his tutorials on PHP. After viewing the tutorials I was able to see the error(s) and understand more about PHP code. Thanks again!

 

Oh...Here is the repaired code.

 

<?PHP

if($_POST['submit'])

{

$recipient="me@mysite.com";

$subject="Contact from my Web Site";

$body="

$name

$email

$comments

";

$headers='From: '.$email."\r\n".'Reply-to: '.$email."\r\n";

mail($recipient, $subject, $body, $headers);

echo "

";

}

else

{

echo "

";

}

?>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...