Forum Moderators: coopster
<?php
if ($_SERVER['REQUEST_METHOD'] != 'POST'){
$me = $_SERVER['PHP_SELF'];
?>
<form name="form1" method="post"
action="<?php echo $me;?>">
<table border="0" cellspacing="0" cellpadding="2">
<tr>
<td><font face="Arial, Helvetica, sans-serif">Name:</font></td>
<td><input type="text" name="Name"></td>
</tr></br>
<tr>
<td><font face="Arial, Helvetica, sans-serif">E-mail:</font></td>
<td><input type="text" name="e-mail"></td>
</tr></br>
<tr>
<td valign="top"><font face="Arial, Helvetica, sans-serif">Phone:</font></td>
<td><input name="Phone" type="text" value=""></td>
</tr></br>
<tr>
<td><font face="Arial, Helvetica, sans-serif">Fax:</font></td>
<td><input type="text" name="Fax"></td>
</tr></br>
<tr>
<td> </td>
<td><input type="submit" name="Submit"
value="Send"></td>
</tr></br>
</table>
</form>
}
<p>
<?php
else {
error_reporting(0);
$recipient = 'aaron@example.com';
$from = stripslashes($_POST['Name']);
$e-mail = stripslashes($_POST['E-mail']);
$phone = stripslashes($_POST['Phone']);
$fax = stripslashes($_POST['Fax']);
if (mail($recipient, $name, $e-mail, $phone, $fax))
echo nl2br("<b>Message Sent:</b>
To: $recipient
Name: $name
E-mail: $e-mail
Phone: $phone
Fax: $fax
$msg");
else
echo "Message failed to send";
}
?>
all help is greatly appreciated
[edited by: jatar_k at 2:37 pm (utc) on Mar. 28, 2008]
[edit reason] examplified email [/edit]
im not sure about this bit
if (mail($recipient, $name, $e-mail, $phone, $fax))
should you use isset() with this?
else{
echo "Message failed to send";
}
not sure you need this either as you should get a mail error from the server anyways if something is missing such as an address
<?php
} else {
error_reporting(0);
$recipient = 'aaron@example.com';
$from = stripslashes($_POST['Name']);
$e-mail = stripslashes($_POST['E-mail']);
$phone = stripslashes($_POST['Phone']);
$fax = stripslashes($_POST['Fax']);
if (mail($recipient, $name, $e-mail, $phone, $fax))
echo nl2br("<b>Message Sent:</b>
To: $recipient
Name: $name
E-mail: $e-mail
Phone: $phone
Fax: $fax
$msg");
else
echo "Message failed to send";
}
?>
[edited by: jatar_k at 3:20 pm (utc) on Mar. 28, 2008]
}
Notice: Undefined index: trigger in E:\CustomerData\webspaces\webspace_00152424\wwwroot\register.php on line 103
Notice: Undefined variable: recipient in E:\CustomerData\webspaces\webspace_00152424\wwwroot\register.php on line 111
Notice: Undefined variable: name in E:\CustomerData\webspaces\webspace_00152424\wwwroot\register.php on line 111
Notice: Undefined variable: email in E:\CustomerData\webspaces\webspace_00152424\wwwroot\register.php on line 111
Notice: Undefined variable: phone in E:\CustomerData\webspaces\webspace_00152424\wwwroot\register.php on line 111
Notice: Undefined variable: fax in E:\CustomerData\webspaces\webspace_00152424\wwwroot\register.php on line 111
Warning: mail() [function.mail]: SMTP server response: 503 5.5.2 Need Rcpt command. in E:\CustomerData\webspaces\webspace_00152424\wwwroot\register.php on line 111
if (mail($recipient, $name, $email, $phone, $fax)) else{ echo "Message failed to send"; }
}
Notice: Undefined index: trigger in E:\CustomerData\webspaces\webspace_00152424\wwwroot\register.php on line 103
Notice: Undefined variable: recipient in E:\CustomerData\webspaces\webspace_00152424\wwwroot\register.php on line 111
Notice: Undefined variable: name in E:\CustomerData\webspaces\webspace_00152424\wwwroot\register.php on line 111
Notice: Undefined variable: email in E:\CustomerData\webspaces\webspace_00152424\wwwroot\register.php on line 111
Notice: Undefined variable: phone in E:\CustomerData\webspaces\webspace_00152424\wwwroot\register.php on line 111
Notice: Undefined variable: fax in E:\CustomerData\webspaces\webspace_00152424\wwwroot\register.php on line 111
Warning: mail() [function.mail]: SMTP server response: 503 5.5.2 Need Rcpt command. in E:\CustomerData\webspaces\webspace_00152424\wwwroot\register.php on line 111
if (mail($recipient, $name, $email, $phone, $fax)) else{ echo "Message failed to send"; }
how do i fix this?
[webmasterworld.com...]
i think you have set this up wrong,
you want it so that the if statements run when the form is submitted - the function mail() is within the if statement -
the else isnt needed i think - you could have the error message pop up if one of your fomr fields is empty - this will cause the mail() function to fail. mail() will give an error if a parameter is wrong, follow the script suggested on our original thread
$array = array('one' => 'value 1', 'two' => 'value 2');
echo $array['three']; // undefined index
echo $array['One']; // also undefined [b]o[/b]ne != [b]O[/b]ne
$this = 'this';
$that = 'that';
echo $another; // undefined variable
echo $This; // also undefined [b]t[/b]his != [b]T[/b]his
Also $array['E-mail'] and $E-mail are not the same thing (first is a single element from the $array...array, the second is a variable). So make sure that you have arrays and variable at the correct places.