View Single Post
  #1 (permalink)  
Old 10-05-2008, 10:42 AM
calvynlee's Avatar
calvynlee calvynlee is offline
Blogging Moderator
 
Join Date: Jul 2006
Location: LittlePenang.com
Posts: 1,690
Rep Power: 63
calvynlee has a spectacular aura about calvynlee has a spectacular aura about
Code or mail function problem?

hi all coder here,

I do a simple form for inquiry purpose, inquiry.htm and here is the code


Code:
<form method="post" action="inquiry.php">

<?php
$ip = getenv("REMOTE_ADDR");
$httpref = getenv ("HTTP_REFERER");
$httpagent = getenv ("HTTP_USER_AGENT");
?>

<input type="hidden" name="ip" value="<?php echo $ip ?>" />
<input type="hidden" name="httpref" value="<?php echo $httpref ?>" />
<input type="hidden" name="httpagent" value="<?php echo $httpagent ?>" />

    
    <p>Your Name: <br>
    <input type="text" name="visitor" size="35"> (Require)<br>
    Your Email:<br>
    <input type="text" name="visitormail" size="35"> (Require)<br>
    Subject <br>
    <input type="text" name="visitorsubject" size="35"> (Require)<br>

    
    <p>
    
    Attention:<br>
    <select name="attn" size="1">
    <option value=" General Support ">General Inquiry</option>
    <option value=" Sales & Presales ">Sales n Pre-Sales</option>    
    <option value=" Technical Support ">Technical Support</option>
    <option value=" Payment & Billing ">Payment & Billing</option>
    </select> <br>

    Mail Message: <br>
    <textarea name="notes" rows="4" cols="40"></textarea> 

    <input type="submit" value="Send">
and after my visitor fill up the form, it will link to inquiry.php

PHP Code:
<html>
<head> 
<title>Sendemail Script</title>
</head>
<body>


<?php

$ip 
$_POST['ip']; 
$httpref $_POST['httpref']; 
$httpagent $_POST['httpagent']; 
$visitor $_POST['visitor']; 
$visitormail $_POST['visitormail'];
$visitorsubject $_POST['visitorsubject'] ;
$notes $_POST['notes'];
$attn $_POST['attn'];


if (
eregi('http:'$notes)) {
die (
"Do NOT try that! ! ");
}
if(!
$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,"."))) 
{
echo 
"<h2>Use Back - Enter valid e-mail</h2>\n"
$badinput "<h2>Feedback was NOT submitted</h2>\n";
echo 
$badinput;
die (
"Go back! ! ");
}

if(empty(
$visitor) || empty($visitormail) || empty($notes )) {
echo 
"<h2>Use Back - fill in all fields</h2>\n";
die (
"Use back! ! "); 
}

$todayis date("l, F j, Y, g:i a") ;

$attn $attn 
$subject $attn

$notes stripcslashes($notes); 

$message " $todayis [EST] \n
Attention: $attn \n
Subject : $visitorsubject \n
Message: $notes \n 
From: $visitor ($visitormail)\n


Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n
"
;

$from "From: $visitormail\r\n";


mail("me@myemail.com"$subject$message$from);

?>

<p align="center">
Date: <?php echo $todayis ?> 
<br />
Thank You : <?php echo $visitor ?> ( <?php echo $visitormail ?> ) 
<br />

Attention: <?php echo $attn ?>
<br /> 
Message:<br /> 
<?php $notesout str_replace("\r""<br/>"$notes); 
echo 
$notesout?> 
<br />
<?php echo $ip ?> 


</body>
</html>
after settle, i do try it, but unable to receive my email, any one can help me point out where is my problem?
__________________
I blog my IT Engineer LIFE at iCalvyn.com
Reply With Quote