A Digital Age Deserves A Digital Leader

PHP Script help

PHP Script help

Postby Sisco22 » Mon May 12, 2008 2:15 pm

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>
Image
PRO Level 14
User avatar
Posts: 964
Joined: Mon Mar 29, 2004 9:25 pm
Location: Nashville, TN
Real Name: Adam Lowe

Postby DRAGON OF DARKNESS » Mon May 12, 2008 3:46 pm

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
PRO Level 16
User avatar
Posts: 1826
Joined: Fri Jul 16, 2004 11:14 pm
Location: MIA > FLA > USA

Postby Sisco22 » Mon May 12, 2008 3:50 pm

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.
Image
PRO Level 14
User avatar
Posts: 964
Joined: Mon Mar 29, 2004 9:25 pm
Location: Nashville, TN
Real Name: Adam Lowe

Postby jbullard » Mon May 12, 2008 4:23 pm

Try this

I haven't tested this for any errors but this should work just fine. :yesnod:

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);
   
?>
VP - Software
User avatar
Posts: 3653
Joined: Sun Jun 06, 2004 10:17 pm
Location: Utah
Real Name: Jason Bullard

Postby Sisco22 » Mon May 12, 2008 4:48 pm

here is the error i get with that one:

Parse error: syntax error, unexpected T_SL in /homepages/36/d152963933/htdocs/massage/contact.php on line 14
Image
PRO Level 14
User avatar
Posts: 964
Joined: Mon Mar 29, 2004 9:25 pm
Location: Nashville, TN
Real Name: Adam Lowe

Postby jbullard » Mon May 12, 2008 5:12 pm

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);
   
?>
VP - Software
User avatar
Posts: 3653
Joined: Sun Jun 06, 2004 10:17 pm
Location: Utah
Real Name: Jason Bullard

Postby Sisco22 » Mon May 12, 2008 5:16 pm

Parse error: syntax error, unexpected T_SL in /homepages/36/d152963933/htdocs/massage/contact.php on line 14


Same thing :(
Image
PRO Level 14
User avatar
Posts: 964
Joined: Mon Mar 29, 2004 9:25 pm
Location: Nashville, TN
Real Name: Adam Lowe

Postby jbullard » Mon May 12, 2008 5:48 pm

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";
?>
VP - Software
User avatar
Posts: 3653
Joined: Sun Jun 06, 2004 10:17 pm
Location: Utah
Real Name: Jason Bullard

Postby DRAGON OF DARKNESS » Tue May 13, 2008 1:19 pm

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 :)
Stephen
PRO Level 16
User avatar
Posts: 1826
Joined: Fri Jul 16, 2004 11:14 pm
Location: MIA > FLA > USA

Postby Absolute-Zero » Tue May 13, 2008 1:35 pm

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.
Image
PROfessional Member
User avatar
Posts: 2495
Joined: Sat Jun 26, 2004 2:46 pm
Location: Forever blowing bubbles...
Real Name: Dan

Next

Return to HTML, CSS, and Scripts

Who is online

Users browsing this forum: Google [Bot] and 0 guests

cron
cron