PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
anthony88guy
Forum Contributor
Posts: 246 Joined: Thu Jan 20, 2005 8:22 pm
Post
by anthony88guy » Thu Jan 20, 2005 8:29 pm
I am creating a simple form where you just type your email address and a message and then it sends it to me. Its just a simple test for a bigger mailing list thing i will be making.
Here is my html code
Code: Select all
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#333333" text="#999966" link="#FFFF00" vlink="#999933" alink="#FFFF99">
<div align="center">
<form action="mail.php" method="post" name="mail" id="mail">
<p>Your Email:</p>
<p>
<input name="from" type="text" id="from2" size="50">
</p>
<p>Message: </p>
<p>
<textarea name="message" cols="43" rows="5" id="message"></textarea>
</p>
<p>
<input type="submit" name="Submit" value="Send Mail">
</p>
</form>
<p> </p></div>
</body>
</html>
Thats my html and form, here is my php file code...
Code: Select all
<?
$to = "myemail@optonline.net";
$from = "email";
$subject = "From $from";
$message = "message";
mail($to, $subject , $message);
header("location:http://www.nokidding.websiteallies.com");
?>
I don't understand why when i try it out i get an email from nobody and the subject is : From email, and the body consist of message.
Thanks guys
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Thu Jan 20, 2005 8:54 pm
your php code asks php to store the strings "message" and "email" .. they have nothing to do with the form. $_POST['from'] and $_POST['message'] will be the information you're thinking should be there.
anthony88guy
Forum Contributor
Posts: 246 Joined: Thu Jan 20, 2005 8:22 pm
Post
by anthony88guy » Thu Jan 20, 2005 9:19 pm
thank you, i can recieve an email now and it works, except that in the subject line i get: From $from
how do i go about fixing that?
thanks again
Code: Select all
<?
$to = "myemail@optonline.net";
$from = $_POSTї'email'];
$subject = 'From $from';
$message = $_POSTї'message'];
mail($to, $subject , $message);
header("location:http://www.nokidding.websiteallies.com");
?>
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Thu Jan 20, 2005 9:24 pm
single quotes vs. double quotes:
variables inside a singlequote string will not be parsed by php. Variables in a double quote string will.
note: you are missing a colon in the from string.
anthony88guy
Forum Contributor
Posts: 246 Joined: Thu Jan 20, 2005 8:22 pm
Post
by anthony88guy » Fri Jan 21, 2005 12:10 pm
where exactly am i missing a colon?
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Fri Jan 21, 2005 12:12 pm
ignore that bit