PHP Script help
11 posts
• Page 1 of 2 • 1, 2
PHP Script help
Hey guys, I need some help with my script. Its not outputting the right stuff for some reason. here is the code:
Any ideas of what im missing?
- Code: Select all
<?
$subject="from ".$_GET['your_name'];
$headers= "From: contact@mydomain.com ";
$headers.='Content-type: text/html; charset=iso-8859-1';
mail("email@gmail.com", $subject, "
<html>
<head>
<title>Contact letter</title>
</head>
<body>
<br>
".$_Get['message']."
</body>
</html>" , $headers);
echo ("Your message was successfully sent!");
?>
<script>
resizeTo(300,300)
//window.close()
</script>
- Sisco22
- Posts: 964
- Joined: Mon Mar 29, 2004 9:25 pm
- Location: Nashville, TN
- Real Name: Adam Lowe
Can you be more specific about what isn't outputting correctly? I your email not being sent? Please explain more. Also do you have short tags enabled in your php.ini settings?
Stephen
- DRAGON OF DARKNESS
- Posts: 1826
- Joined: Fri Jul 16, 2004 11:14 pm
- Location: MIA > FLA > USA
This is what i get when i fill out the form, i get an email sent to my email and here is the body of the email:
<html>
<head>
<title>Contact letter</title>
</head>
<body>
<br>
</body>
</html>
It should say the information that i have inputted.
Actually i don't think i have a PHP.ini file in there.
I have a form that consists of name, address, phone #, email and then a message field.
<html>
<head>
<title>Contact letter</title>
</head>
<body>
<br>
</body>
</html>
It should say the information that i have inputted.
Actually i don't think i have a PHP.ini file in there.
I have a form that consists of name, address, phone #, email and then a message field.
- Sisco22
- Posts: 964
- Joined: Mon Mar 29, 2004 9:25 pm
- Location: Nashville, TN
- Real Name: Adam Lowe
Try this
I haven't tested this for any errors but this should work just fine.
I haven't tested this for any errors but this should work just fine.
- Code: Select all
<?php
$subject = "from " . $_GET['your_name'];
// Set MIME-Version and Content-type (required for HTML email)
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type: text/html; charset = iso-8859-1" . "\r\n";
// Set additional headers (helps prevent junk box placement)
$headers .= "To: Someones Name <email@gmail.com>" . "\r\n";
$headers .= "From: My Name <contact@mydomain.com>" . "\r\n";
// Declare entire message
$message = <<<EOF
<html>
<head>
<title>Contact Letter</title>
</head>
<body>
<br>
{message}
</br>
</body>
</html>
EOF;
// Set email
mail("email@gmail.com", $subject, str_replace('{message}', $_GET['message'], $message), $headers);
?>
- jbullard
- VP - Software
- Posts: 3653
- Joined: Sun Jun 06, 2004 10:17 pm
- Location: Utah
- Real Name: Jason Bullard
Try this. I accidentally added formatting to the heredoc which is not authorized in PHP.
- Code: Select all
<?php
$subject = "from " . $_GET['your_name'];
// Set MIME-Version and Content-type (required for HTML email)
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type: text/html; charset = iso-8859-1" . "\r\n";
// Set additional headers (helps prevent junk box placement)
$headers .= "To: Someones Name <email@gmail.com>" . "\r\n";
$headers .= "From: My Name <contact@mydomain.com>" . "\r\n";
// Declare entire message
$message = <<<EOF
<html>
<head>
<title>Contact Letter</title>
</head>
<body>
<br>
{message}
</br>
</body>
</html>
EOF;
// Set email
mail("email@gmail.com", $subject, str_replace('{message}', $_GET['message'], $message), $headers);
?>
- jbullard
- VP - Software
- Posts: 3653
- Joined: Sun Jun 06, 2004 10:17 pm
- Location: Utah
- Real Name: Jason Bullard
Alright, lets try this modified version.
- Code: Select all
<?php
$subject = "From " . $_GET['your_name'];
// Set MIME-Version and Content-type (required for HTML email)
$headers = "MIME-Version: 1.0\r\n
Content-type: text/html; charset = iso-8859-1\r\n
To: Someones Name <email@gmail.com>\r\n
From: My Name <contact@mydomain.com>\r\n
Reply-To: My Name <contact@mydomain.com>\r\n
X-Mailer: PHP/" . phpversion();
// Declare entire message
$message = "<html>
<body bgcolor=\"#DCEEFC\">
<center>
{message}
</center>
</body>
</html>";
// Set email
mail("email@gmail.com", $subject, str_replace('{message}', $_GET['message'], $message), $headers);
echo "Email sent";
?>
- jbullard
- VP - Software
- Posts: 3653
- Joined: Sun Jun 06, 2004 10:17 pm
- Location: Utah
- Real Name: Jason Bullard
Its alittle striped down but it gets the job done, also I emailed it to you because I dont know if its gonna display right on the forum:
EDIT: ugh ... I can never get code to display right, but I emailed it to you, let me know if it works
EDIT: ugh ... I can never get code to display right, but I emailed it to you, let me know if it works
Stephen
- DRAGON OF DARKNESS
- Posts: 1826
- Joined: Fri Jul 16, 2004 11:14 pm
- Location: MIA > FLA > USA
DRAGON OF DARKNESS wrote:I can never get code to display right
Try making sure the "Disable HTML in this post" box is checked before submitting your post.
- Absolute-Zero
- PROfessional Member
- Posts: 2495
- Joined: Sat Jun 26, 2004 2:46 pm
- Location: Forever blowing bubbles...
- Real Name: Dan
11 posts
• Page 1 of 2 • 1, 2
Return to HTML, CSS, and Scripts
Who is online
Users browsing this forum: No registered users and 6 guests