You are here: PHP email form not working « PHP Programming Language « IT news, forums, messages
PHP email form not working

Posted by alice on 01/06/07 05:32

I found this code for making a php email form for a web site. It works
fine on my ISP, but not on my friends...could it be that my ISP uses
php5, I know that hers does not, so I assume it's php4. Is there anyway
to tell? Here's the code. It sends me email fine, but when it's on her
ISP, it says it sent the mail, but nothing goes through.

<?php
if (isset($submit)) {
switch ($recipient) {
case "whole-family":
$recipient_email = "gregf@kcls.org";
$subject = "Gregs test php mail";
break;
case "Brian":
$recipient_email = "brian@meyer-family.com";
$subject = "Message to Brian";
break;
case "Jessica":
$recipient_email = "jessica@meyer-family.com";
$subject = "Message to Jessica";
break;
case "Eric":
$recipient_email = "eric@meyer-family.com";
$subject = "Message to Eric";
break;
case "Paul":
$recipient_email = "paul@meyer-family.com";
$subject = "Message to Paul";
break;
case "Dudley":
$recipient_email = "dudley@meyer-family.com";
$subject = "Message to Dudley";
break;
}

if (!empty($name) and !empty($email) and !empty($message)) {
if (mail ($recipient_email, $subject, $message, "From: $name
<$email>"))
$status = "<p>Thanks for your message, $name, it has been
successfully
sent!</p>";
else
$status = '<p>Your message couldnt be sent! Please try again or
send
us a conventional e-mail to
<a href="mailto:gregf@kcls.org">gregf@kcls.org</a>.
Thank you!</p>';
}
else
$status = "Please fill the highlighted fields!";
}
?>

<html>
<head>
<title>www.meyer-family.com - Contact</title>
<style type="text/css">
<!--
.error { font-weight: bold; color: red; }
-->
</style>
</head>
<body>
<h1>Contact</h1>
<?php
if(isset($status))
echo ($status);
?>
<form action="contact.php" method="post">
<p>Send message to:
<select name="recipient" size="1">
<option value="whole-family">The whole Meyer family</option>
<option value="Brian">Brian</option>
<option value="Jessica">Jessica</option>
<option value="Eric">Eric</option>
<option value="Paul">Paul</option>
<option value="Dudley">Dudley</option>
</select></p>
<p<?php
if (isset($submit) and empty($name))
echo(' class="error"');
?>>Your name:
<input type="text" name="name" value="<?php if(!empty($name))
echo($name); ?>" size="30"
/></p>
<p<?php
if (isset($submit) and empty($email))
echo(' class="error"');
?>>Your e-mail address:
<input type="text" name="email" value="<?php if(!empty($email))
echo($email); ?>"
size="30" /></p>
<p<?php
if (isset($submit) and empty($message))
echo(' class="error"');
?>>Your message:
<textarea name="message" cols="30" rows="5"><?php
if(!empty($message))
echo($message);
?></textarea></p>
<input type="submit" name="submit" value="Send" />
</form>
</body>
</html>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация