Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Check box with basic mail() script
Old 07-19-2008, 04:05 AM Check box with basic mail() script
aslanandbeez's Avatar
Experienced Talker

Posts: 39
Trades: 0
Hey,

I have a basic mail() script I wish to use, but I want to add a checkbox with it if I can, can I do it with this script;

<?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
{
//send email
$email = $_REQUEST['email'] ;
$subject = $_REQUEST['subject'] ;
$message = $_REQUEST['message'];
mail( "", "Subject: $subject",
$message, "From: $email" );
echo "Thank you for filling out the form.";
}
else
//if "email" is not filled out, display the form
{
echo "<form method='post' action='mailform.php'>
Email: &nbsp;&nbsp;&nbsp;<input name='email' type='text' /><br />
Subject: <input name='subject' type='text' /><br /><br />
Message:<br />
<textarea name='message' rows='15' cols='40'>
</textarea><br />
<input type='checkbox' name='mailing' />Yes, I want to receive further information and updates from jonathonbaker.com<br />
<input type='submit' />
</form>";
}
?>

and where do I have the checkbox info sent to? (I left the email address for it to be sent to out)
__________________
Aslan & Beez Web Design - Today, Tomorrow, Forever
aslanandbeez is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-19-2008, 08:57 AM Re: Check box with basic mail() script
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
In that case im assuming you would add the persons email to the mainling list, so you would have to get the users email from a input field and then have something like this:

PHP Code:
$usersEmail mysql_escape_string($_POST['usersEmail']);
mysql_query("INSERT INTO mailinglisttable SET email='$usersEmail'"); 
Also NEVER EVER EVER use $_REQUEST

This leaves you open to all sorts of hacking, and injection especially where this is using mail u could very easily find your account suspended or terminated because a spammer could send many unsolicited emails using this code.

use $_POST to reduce the risk.

because $_REQUEST uses BOTH $_POST and $_GET

so someone could do this

http://ursite.com/thisscript.php?ema...m&subject=haha this is spam&message=This is a spam email sent using a silly persons script

and that would send a email every time it was loaded.

Hopefully you get what i mean

Hope this helps.

Dan
(Reputation Points much apprieciated)
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Reply     « Reply to Check box with basic mail() script
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.15262 seconds with 12 queries