khorais
01-27-2006, 10:03 PM
Hi,
I have a contact form which I have forwarded to a non-HR/non-webmail e-mail account. I would like the received e-mail to contain the email address entered, not "Nobody" as it does now. Is this possible?
//My code
<? function show_form($email="",$message="",$subject="") { ?>
<form action="<? echo $PHP_SELF ?>" method="post">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="form_input">
<p>Your E-mail address: <input type=text name=email size=30 value="<? echo $email ?>"></p></td>
</tr>
<tr valign="top">
<td class="form_input"><p>Subject: <input type=text name=subject size=30 value="<? echo $subject ?>"></p></td>
</tr>
<tr valign="top">
<td class="form_input"><p>Message: <textarea rows=10 cols=50 name=message><? echo $message ?></textarea></p></td>
</tr>
<tr><td><input type=submit value="Send message"></td></tr>
</table>
</form>
<? }
if (!isset($email) or !isset($message)) {
show_form();
}
else {
//some form validation that isn't shown goes here
show_form($email,$message,$subject);
}
else {
if ( empty($subject) ) {
$subject="your email";
}
$sent = mail( "recipient@mail.com",
"Web site email: $subject",$message, "Message from: $email" );
if ( $sent ) {
echo "<h1>Your message has been sent.</h1>";
echo "Thank you, $email. <p>We'll
will read your email regarding
$subject and reply soon.</p>";
}
else {
echo "<h1>There is a Problem:</h1>
<p>The server was unable to send your
mail.</p>";
}
}
}
?>
//end code
Thanks for any help!
I have a contact form which I have forwarded to a non-HR/non-webmail e-mail account. I would like the received e-mail to contain the email address entered, not "Nobody" as it does now. Is this possible?
//My code
<? function show_form($email="",$message="",$subject="") { ?>
<form action="<? echo $PHP_SELF ?>" method="post">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="form_input">
<p>Your E-mail address: <input type=text name=email size=30 value="<? echo $email ?>"></p></td>
</tr>
<tr valign="top">
<td class="form_input"><p>Subject: <input type=text name=subject size=30 value="<? echo $subject ?>"></p></td>
</tr>
<tr valign="top">
<td class="form_input"><p>Message: <textarea rows=10 cols=50 name=message><? echo $message ?></textarea></p></td>
</tr>
<tr><td><input type=submit value="Send message"></td></tr>
</table>
</form>
<? }
if (!isset($email) or !isset($message)) {
show_form();
}
else {
//some form validation that isn't shown goes here
show_form($email,$message,$subject);
}
else {
if ( empty($subject) ) {
$subject="your email";
}
$sent = mail( "recipient@mail.com",
"Web site email: $subject",$message, "Message from: $email" );
if ( $sent ) {
echo "<h1>Your message has been sent.</h1>";
echo "Thank you, $email. <p>We'll
will read your email regarding
$subject and reply soon.</p>";
}
else {
echo "<h1>There is a Problem:</h1>
<p>The server was unable to send your
mail.</p>";
}
}
}
?>
//end code
Thanks for any help!