need help with a Make contact form and send email in PHP

Status
Not open for further replies.

zynischen

New Member
Messages
38
Reaction score
0
Points
0
i need help it is not exactly working

PHP:
<?
  if ($_POST["email"]<>'') {
$ToEmail = 'youremail@site.com';
$EmailSubject = 'Site contact form ';
$mailheader = "From: ".$_POST["email"]."\r\n";
$mailheader .= "Reply-To: ".$_POST["email"]."\r\n";
$mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n";
$MESSAGE_BODY = "Name: ".$_POST["name"]."<br>";
$MESSAGE_BODY .=  "Email: ".$_POST["email"]."<br>";
$MESSAGE_BODY .=  "Comment: ".nl2br($_POST["comment"])."<br>";
mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure");
?>
Your message was sent
<? } else { ?>
<form action="test.php" method="post">
<table width="400" border="0" cellspacing="2" cellpadding="0">
<tr>
<td width="29%" class="bodytext">Your name:</td>
<td width="71%"><input name="name" type="text" id="name" size="32"></td>
</tr>
<tr>
<td class="bodytext">Email address:</td>
<td><input name="email" type="text" id="email" size="32"></td>
</tr>
<tr>
<td class="bodytext">Comment:</td>
<td><textarea name="comment" cols="45" rows="6" id="comment" class="bodytext"></textarea></td>
</tr>
<tr>
<td class="bodytext">&nbsp;</td>
<td align="left" valign="top"><input type="submit" name="Submit" value="Send"></td>
</tr>
</table>
</form> 
<? }; ?>

so can anyone help or do it for me not to good with this stuff
 

kajasweb

New Member
Messages
1,723
Reaction score
0
Points
0
- Change
PHP:
if ($_POST["email"]<>'') {
To
PHP:
if ($_POST['email'] != "") {

- Change " to ' used in Array Association Strings, i.e., $_POST["something"] to $_POST['something']

- Not a big one, but consider changing
PHP:
<form action="test.php" method="post">
to
PHP:
<form action="<?php print $_SERVER['PHP_SELF']; ?>" method="post">
 

Slothie

New Member
Messages
1,429
Reaction score
0
Points
0
PHP:
<?php
  if (!empty($_POST["email"])) {
	$ToEmail = 'youremail@site.com';
	$EmailSubject = 'Site contact form ';
	$mailheader = "From: ".$_POST["email"]."\r\n";
	$mailheader .= "Reply-To: ".$_POST["email"]."\r\n";
	$mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n";
	$MESSAGE_BODY = "Name: ".$_POST["name"]."<br>";
	$MESSAGE_BODY .=  "Email: ".$_POST["email"]."<br>";
	$MESSAGE_BODY .=  "Comment: ".nl2br($_POST["comment"])."<br>";
	mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure");
	?>
	Your message was sent
<?php } else { 	?>
	<form action="test.php" method="post">
	<table width="400" border="0" cellspacing="2" cellpadding="0">
	<tr>
	<td width="29%" class="bodytext">Your name:</td>
	<td width="71%"><input name="name" type="text" id="name" size="32"></td>
	</tr>
	<tr>
	<td class="bodytext">Email address:</td>
	<td><input name="email" type="text" id="email" size="32"></td>
	</tr>
	<tr>
	<td class="bodytext">Comment:</td>
	<td><textarea name="comment" cols="45" rows="6" id="comment" class="bodytext"></textarea></td>
	</tr>
	<tr>
	<td class="bodytext">&nbsp;
	</td>
	<td align="left" valign="top"><input type="submit" name="Submit" value="Send"></td>
	</tr>
	</table>
	</form> 
<?php }; ?>
 
Status
Not open for further replies.
Top