Jump to content

php email


common

Recommended Posts

Hi all,

I am trying to set up a email form through php. I do not want the emailaddress to whom it is send be visible, so I constructed this code, but it does not seem to work...can any one tell me why(the mail account inserted does not exist, but I have entered mine and uploaded it to a host, but the  code runs through but I never get the mail...)

 

if (isset($_POST['submitted'])) 
{
if (!empty($_POST['name']) && !empty($_POST['subject']) && !empty($_POST['message']) ) 
{
	$headers = "From: ".$_POST['name'];
	mail('[email protected]',$_POST['subject'], $_POST['message'],$headers);

	print "Your message has been send";
	// Clear $_POST (so that the form's not sticky):
	$_POST = array();
}

else
{
	print "Error: You havn't filled in all the fields!<p/>";
	include('emailform.php');
}
}

else
{
print "<table border='0' cellpadding='0' cellspacing='5'><tr>
<form action='index.php' method='post'>
<td style='vertical-align:top;font-familiy:calibri;font-size:12px;'>Name: </td>
<td><input type='text' name='name' size='30' value='<?php if(isset($_POST['submitted'])){print $_POST['name'];}?>'/></td></tr><tr>
    
<td style='vertical-align:top;font-familiy:calibri;font-size:12px;'>Subject: </td>
<td><input type='text' name='subject' size='30' value='<?php if(isset($_POST['submitted'])){print $_POST['subject'];}?>'/></td></tr><tr>
    
<td style='vertical-align:top;font-familiy:calibri;font-size:12px;'>Message: </td>
<td><textarea name='message' cols='40' rows='5'><?php if(isset($_POST['submitted'])){print $_POST['message'];}?></textarea></td></tr><tr>
<td><input type='hidden' name='submitted'></td>
<td style='text-align:right;'><input type='submit' value='Send'/></form></td></tr></table>";
}

Link to comment
https://forums.phpfreaks.com/topic/165807-php-email/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.