08-08-2004
|
#1 (permalink)
|
|
Incredible Indelible Etiquette
Join Date: Oct 2003
Location: Hobe Sound, Florida
Posts: 1,751
|
PHP Mail Form Help..
index.php
PHP Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>| ShockedStyle |</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" type="text/css" href="http://www.shockedstyle.com/style.css" /> </head> <body> <div class="zer"> <div class="one"> <br /><div class="two" align="center"><span id="two"><img src="http://shockedstyle.com/images/logo.gif" /><p><a href="http://www.shockedstyle.com">MAIN</a> | <a href="http://www.shockedstyle.com/blog">BLOG</a> | <a href="html://www.shockedstyle.com/contact">CONTACT</a></p></span> <div class="content"> <? {?> <form method="post" action="comments.php"> E-Mail: <input type="text" name="email" size=60> Subject: <input type="text" name="subject" size=60> Comments: <textarea name="comments" rows="10" cols="30"></textarea> <input type="submit" name="submit" value="submit"> </form> <? }?> </div> </div> <!-- one --></div> <!-- zer --></div> </body> </html>
comments.php
PHP Code:
<? if($submit) { mail("youremailaddress@whatever.com", "$subject", "$email", "$comments"); }?>
It doesn't work... why?
|
|
|
08-08-2004
|
#2 (permalink)
|
|
Guest
|
mail("youremailaddress@whatever.com", "$subject", "$comments", "'From: '.$email");
try that
|
|
|
|
08-08-2004
|
#3 (permalink)
|
|
Incredible Indelible Etiquette
Join Date: Oct 2003
Location: Hobe Sound, Florida
Posts: 1,751
|
Well, it's working now but when it comes in it is still coming in as from "Nobody" - how can I get it to come from their E-Mail Address?
*Waits for Ryan to tell me*
|
|
|
08-08-2004
|
#5 (permalink)
|
|
Incredible Indelible Etiquette
Join Date: Oct 2003
Location: Hobe Sound, Florida
Posts: 1,751
|
Now that is working.
But, at the end of each e-mail ($comments) it would be like this...
"Testing 1 2 3
."
What's with the little period at the end of each e-mail?
|
|
|
08-09-2004
|
#6 (permalink)
|
|
Guest
|
check the $comments variable, can i see the code again please?
|
|
|
|
08-10-2004
|
#7 (permalink)
|
|
Incredible Indelible Etiquette
Join Date: Oct 2003
Location: Hobe Sound, Florida
Posts: 1,751
|
Index.php
PHP Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>| ShockedStyle |</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" type="text/css" href="http://www.shockedstyle.com/style.css" /> </head> <body> <div class="zer"> <div class="one"> <br /><div class="two" align="center"><span id="two"><img src="http://shockedstyle.com/images/logo.gif" /><p><a href="http://www.shockedstyle.com">MAIN</a> | <a href="http://www.shockedstyle.com/blog">BLOG</a> | <a href="html://www.shockedstyle.com/contact">CONTACT</a></p></span> <div class="content"> <? {?> <form method="post" action="comments.php"> Name: <input type="text" name="name" size=60> E-Mail: <input type="text" name="email" size=60> Subject: <input type="text" name="subject" size=60> Comments: <textarea name="comments" rows="10" cols="30"></textarea> <input type="submit" name="submit" value="submit"> </form> <? }?> </div> </div> <!-- one --></div> <!-- zer --></div> </body> </html>
Comments.php
PHP Code:
<? if($submit) { mail('yuneek@earthlink.net',$subject,$comments,"From: $name <$email>"); }?>
|
|
|
08-11-2004
|
#8 (permalink)
|
|
Guest
|
Ah ive found out what it is!! u need to 'trim' the variables!!
like so:
$comments = trim($comments);
what 'trim' does is that it gets of extra spaces at the beginning and end of a string!
exactly what you need!
|
|
|
|
08-11-2004
|
#9 (permalink)
|
|
Incredible Indelible Etiquette
Join Date: Oct 2003
Location: Hobe Sound, Florida
Posts: 1,751
|
Can you show me how I could impliment that into this line exactly?
PHP Code:
<?
if($submit)
{
mail('yuneek@earthlink.net',$subject,$comments,"From: $name <$email>");
}?>
|
|
|
08-11-2004
|
#10 (permalink)
|
|
Local Biorust Beast
Join Date: Oct 2003
Location: San Diego, CA, USA
Posts: 2,253
|
trim handles spaces, not the period, which I am unsure why it is acting like that.
stick with what you have, but use the appropriate variables! Each variable is in the $_POST global scope, so do this:
PHP Code:
if(isset($_POST['submit']))
{
mail('yuneek@earthlink.net', $_POST['subject'], $_POST['comments'], 'From: ' . $_POST['name'] . '<' . $_POST['email'] . '>');
}
else
{
die("Nothing to do.. seems you got here by not using the form..");
}
This cleans things up a bit, sure it is more typing but there are less security holes, and you are adhereing to the register_globals rules.. when you use just $submit, php does not check to see if it form data, query string data, or cookie data, so someone can easy spoof and open up a security vulnerability in your code, always use your global vars for this stuff.. the common global vars can be found and explained at the PHP Manual:
http://www.php.net/manual/en/languag...predefined.php
|
|
|
08-14-2004
|
#11 (permalink)
|
|
Guest
|
Oh with trim, before you carry the vars, put it at the top, so:
<?php
$comments = trim($comments);
if(isset($_POST['submit']))
{
mail('yuneek@earthlink.net', $_POST['subject'], $_POST['comments'], 'From: ' . $_POST['name'] . '<' . $_POST['email'] . '>');
}
else
{
die("Nothing to do.. seems you got here by not using the form..");
?>
(using the code from order, just a c+p job, but you get what i mean!)
Its like setting an array, you do it before you want to carry or print or use it!!
|
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT +1. The time now is 05:35 PM. Content Relevant URLs by vBSEO 3.2.0
|