Get support from Xavier Media
It is currently Sun Dec 08, 2013 12:25 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Sends Me An Email Everytime You Browse Page
PostPosted: 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\"; }
?>


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: 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
}

?>


Report this post
Top
  
Reply with quote  
 Post subject: Mail script
PostPosted: 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]


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Registered users: No registered users


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

Search for:
Jump to:  

Portal » Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
[
SEO MOD © 2007 StarTrekGuide ]