View unanswered posts | View active topics
Your status has been updated!
|
Page 1 of 1
|
[ 3 posts ] |
|
Author |
Message |
Guest
|
Post subject: Sends Me An Email Everytime You Browse Page Posted: Mon Dec 25, 2006 5:43 am |
|
Points:
|
Below is a simple script I came across. I like some of it compared to the current script, I'm using for my website, but with the below script it sends me an email anytime someone browses the webpage. The code does do it's job.
Any help greatly appreciated.
<form method=\"post\" action=\"contact.php\">
Email: <input name=\"email\" type=\"text\"><br>
Message:<br>
<textarea name=\"message\" rows=\"15\" cols=\"40\"></textarea><br>
<input type=\"submit\">
</form>
<?php
$to = \"you@yoursite.com\";
$subject = \"Contact Us\";
$email = $_REQUEST[\'email\'] ;
$message = $_REQUEST[\'message\'] ;
$headers = \"From: $email\";
$sent = mail($to, $subject, $message, $headers) ;
if($sent)
{print \"Your mail was sent successfully\"; }
else
{print \"We encountered an error sending your mail\"; }
?>
|
|
Top |
|
 |
Guest
|
Post subject: Posted: Mon Dec 25, 2006 11:03 am |
|
Points:
|
okey just add (if)
<form method=\"post\" action=\"contact.php\">
Email: <input name=\"email\" type=\"text\"><br>
Message:<br>
<textarea name=\"message\" rows=\"15\" cols=\"40\"></textarea><br>
<input type=\"submit\">
</form>
<?php
if (isset($submit))
//if the user click button submit then do this code
//if begin
{
$to = \"you@yoursite.com\";
$subject = \"Contact Us\";
$email = $_REQUEST[\'email\'] ;
$message = $_REQUEST[\'message\'] ;
$headers = \"From: $email\";
$sent = mail($to, $subject, $message, $headers) ;
if($sent)
{print \"Your mail was sent successfully\"; }
else
{print \"We encountered an error sending your mail\"; }
//end if
}
?>
|
|
Top |
|
 |
Guest
|
Post subject: Mail script Posted: Tue Dec 26, 2006 5:38 am |
|
Points:
|
You would also want to add this to the code so that you are *kind-of* protected against simple hackers.
[php]
<?php
function clean_code($code){
$code = striptags(trim(stripslashes($code)));
return $code;
}
?>
<form method="post" action="contact.php">
Email: <input name="email" type="text"><br>
Message:<br>
<textarea name="message" rows="15" cols="40"></textarea><br>
<input type="submit">
</form>
<?php
if (isset($submit)) {
//if the user click button submit then do this code
//if begin
$to = "you@yoursite.com";
$subject = "Contact Us";
$email = clean_code($_REQUEST['email']);
$message = clean_code($_REQUEST['message']);
$headers = 'From: '. $email;
$sent = mail($to, $subject, $message, $headers);
if($sent) {
print "Your mail was sent successfully";
} else {
print "We encountered an error sending your mail";
}
//end if
}
?>
[/php]
|
|
Top |
|
 |
|
Page 1 of 1
|
[ 3 posts ] |
|
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|
|