|
-
Mar 3rd, 2007, 11:48 AM
#1
Thread Starter
Hyperactive Member
php email form
Hi here is an php email form, and remember very new to php, it doesnt seem to work, i cant get it to email me at the given address although the sent page comes up when i use it? Anyone got any ideas?
Code:
<html>
<body>
<?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
{
//send email
$email = $_REQUEST['email'] ;
$subject = $_REQUEST['subject'] ;
$message = $_REQUEST['message'] ;
mail( "[email protected]", "Subject: $subject",
$message, "From: $email" );
echo "Sent";
}
else
//if "email" is not filled out, display the form
{
echo "<form method='post' action='mailform.php'>
Email: <input name='email' type='text' /><br />
Subject: <input name='subject' type='text' /><br />
Message:<br />
<textarea name='message' rows='15' cols='40'>
</textarea><br />
<input type='submit' />
</form>";
}
?>>
</body>
</html>
Thanks
Alex
-
Mar 4th, 2007, 02:32 AM
#2
Re: php email form
read up on mail with php here.
then, read up on the mail() function in php here.
to see if mail() is having a trouble when being called, add an "or die()" statement to your mail() call. for example:
PHP Code:
mail(blah, blah, blah, blah) or die("there was an error sending the message");
of course, I hope you realize you need to fill in the parameters with something other than "blah."
next, if it does give you the error message and it doesn't say anything, you have error reporting suppressed. you need to look at your webserver's error log (which should contain these errors), or you can manually re-set the exceptions for your script using the error_reporting() function. you will want to use E_ALL to find all errors happening.
this should help you find out if the problem is your headers or a bad connection to your smtp server -- or something else.
edit: by the way, adding "subject: [subject]" is a bad idea, simply because when you get your emails, the subject will literally be "subject: [subject]." you should just make your subject "[subject]" instead.
Last edited by kows; Mar 4th, 2007 at 02:41 AM.
-
Mar 4th, 2007, 01:19 PM
#3
Re: php email form
Are you using your ISPs smtp? With my hosting one of the SMTP usage rules were that the outgoing address was [email protected].
ILMV
-
Mar 5th, 2007, 06:23 PM
#4
Addicted Member
Re: php email form
That is a little strange....
-
Mar 14th, 2007, 06:21 AM
#5
Lively Member
Re: php email form
 Originally Posted by youngnoviceinneedofh
Hi here is an php email form, and remember very new to php, it doesnt seem to work, i cant get it to email me at the given address although the sent page comes up when i use it? Anyone got any ideas?
Code:
<html>
<body>
<?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
{
//send email
$email = $_REQUEST['email'] ;
$subject = $_REQUEST['subject'] ;
$message = $_REQUEST['message'] ;
mail( "[email protected]", "Subject: $subject",
$message, "From: $email" );
echo "Sent";
}
else
//if "email" is not filled out, display the form
{
echo "<form method='post' action='mailform.php'>
Email: <input name='email' type='text' /><br />
Subject: <input name='subject' type='text' /><br />
Message:<br />
<textarea name='message' rows='15' cols='40'>
</textarea><br />
<input type='submit' />
</form>";
}
?>>
</body>
</html>
Thanks
Alex
modify your mail() as
PHP Code:
$sendto="[email protected]";
$headers = "From: $email\r\nCC:$ccto\r\nContent-type: text/html;charset=us-ascii";
mail($sendto, $subject, $message, $headers);
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|