PHP form help needed<

liunx

Guest
Guys,
I need help in making my contact form at <!-- w --><a class="postlink" href="http://www.guanco.com/contact.html">www.guanco.com/contact.html</a><!-- w --> work using a mailer.php script. The php script that I have is as follows:

<script language="JavaScript" type="text/javascript">
function check(form){

if (form.name.value == "") {
alert("Please enter your name.");
form.name.focus();
return false;
}
else if (form.email.value == "") {
alert("Please enter your email.");
form.email.focus();
return false;
}
else if(!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(form.email.value))){
alert("Please enter a valid email address.");
form.email.focus();
return false;
}
else if (form.comment.value == "") {
alert("Please enter a comment/question.");
form.comment.focus();
return false;
}
else{
return true;
}
}

</script>

<?php

function mailcheck($emailadr){
return eregi("^[a-zA-Z0-9_\.-]+@[a-zA-Z0-9\.-]+\.[a-zA-Z]{2,4}$", $emailadr);
}

if (!isset($_POST['submit']))
{
?>
<h3>Feel free to contact me.</h3>
<form method="post" name="emailform" action="<?php echo $_SERVER['mailer.php']?>" onSubmit="return check(this);">
<p>Product Description : <input type="text" name="prodesc" /></p>
<p>Size : <input type="text" name="size" /></p>
<p>Quantity : <input type="text" name="quan" /></p>
<p>Company Name : <input type="text" name="company" /></p>
<p>Email : <input type="text" name="email" /></p>
<p>Contact Nos : <input type="text" name="contact" /></p><br />
<p>Comments : <br /><textarea name="comments" rows="10" cols="30"></textarea></p>
<p><input type="submit" name="submit" value="Submit" /></p>
</form>
<?php
}
else
{
$name = $_POST['company'];
$email = $_POST['email'];
$comment = $_POST['comments'];
$to = "Ven<[email protected]> " ;

if ((mailcheck($_POST['email']))||($comment!=NULL)||($name!=NULL))
#check if a real email address, if it returns true it sends the email
{
# subject
$subject = "Mail from site.";

# message
$message = '
<html>
<head>
<title>Mail from site</title>
</head>
<body>
<p>The email contains user comments.</p>
<br />
Name of person : '.$name.'<br />
Email of person : '.$email.'<br />
Comment/Question left:<br />
<p>'.$comments.'</p>
<br />
</body>
</html>
';

$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";


$headers .= "From: $email>\r\n";
#Will show up in your box from their email address

#mail it
mail($to, $subject, $message, $headers);
echo 'Thank you for sending mail.';
}
else {
echo 'Sorry, one or more of your fields is invalid.';}
}

?>
Questions:
1. How come when I install this mailer.php script in our server and fill up the form and submit, i dont get the data in my email?( But i see the 'thank you' page after i submit the data in the form.)
2. How do i retain the original form of contact.html? Do I insert contact.html inside mailer.php? Is this how it works?Originally posted by ven7
action="<?php echo $_SERVER['mailer.php']?>

from the looks of this, this code should actually be;

action="<?php echo $_SERVER['SCRIPT_NAME']?>"


where did you get this scipt from? url?Got it from this site : <!-- m --><a class="postlink" href="http://www.alphibia.com/phpscripts.php?p=6thought">http://www.alphibia.com/phpscripts.php?p=6thought</a><!-- m --> so, you can go here;
<!-- m --><a class="postlink" href="http://forum.weborum.com/index.php?showtopic=353">http://forum.weborum.com/index.php?showtopic=353</a><!-- m -->

for the script and also if you still can't get it working post and ask for helpOK thanks for d advice Joe. :P
 
Back
Top