Attention: PROnetworks has upgraded our forum from phpbb2 to phpbb3!!

Please head over to our new converted forum at: http://www.pronetworks.org/forums/

This old forum will remain 'read-only' until approximately February 2009. We look forward to seeing you at the new forum!
Author Message
Sisco22
PostPosted: Mon May 12, 2008 10:15 am Reply with quote

PRO Level 15
 
 


Joined: 29 Mar 2004
Posts: 1081
Location: Nashville, TN
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:
<?
$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>
 
Back to top
DRAGON OF DARKNESS
PostPosted: Mon May 12, 2008 11:46 am Reply with quote

PRO SILVER
 
 


Joined: 16 Jul 2004
Posts: 4674
Location: MIA > FLA > USA
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?
 
Back to top
Sisco22
PostPosted: Mon May 12, 2008 11:50 am Reply with quote

PRO Level 15
 
 


Joined: 29 Mar 2004
Posts: 1081
Location: Nashville, TN
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>




</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.
 
Back to top
jbullard
Jason Bullard
PostPosted: Mon May 12, 2008 12:23 pm Reply with quote

VP - Software
 
 


Joined: 06 Jun 2004
Posts: 3304
Location: Utah
Try this

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

Code:

<?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);
   
?>
 
Back to top
Sisco22
PostPosted: Mon May 12, 2008 12:48 pm Reply with quote

PRO Level 15
 
 


Joined: 29 Mar 2004
Posts: 1081
Location: Nashville, TN
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
 
Back to top
jbullard
Jason Bullard
PostPosted: Mon May 12, 2008 1:12 pm Reply with quote

VP - Software
 
 


Joined: 06 Jun 2004
Posts: 3304
Location: Utah
Try this. I accidentally added formatting to the heredoc which is not authorized in PHP.

Code:

<?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);
   
?>
 
Back to top
Sisco22
PostPosted: Mon May 12, 2008 1:16 pm Reply with quote

PRO Level 15
 
 


Joined: 29 Mar 2004
Posts: 1081
Location: Nashville, TN
Parse error: syntax error, unexpected T_SL in /homepages/36/d152963933/htdocs/massage/contact.php on line 14


Same thing sad
 
Back to top
jbullard
Jason Bullard
PostPosted: Mon May 12, 2008 1:48 pm Reply with quote

VP - Software
 
 


Joined: 06 Jun 2004
Posts: 3304
Location: Utah
Alright, lets try this modified version.

Code:

<?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";
?>
 
Back to top
DRAGON OF DARKNESS
PostPosted: Tue May 13, 2008 9:19 am Reply with quote

PRO SILVER
 
 


Joined: 16 Jul 2004
Posts: 4674
Location: MIA > FLA > USA
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 smile
 
Back to top
Absolute-Zero
Dan Wright
PostPosted: Tue May 13, 2008 9:35 am Reply with quote

PROfessional Member
 
 


Joined: 26 Jun 2004
Posts: 7632
Location: E13 9AZ
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.
 
Back to top
Back to top
Index >> Webmaster Domain & Code Room >> PHP Script help

Goto page 1, 2  Next

Page 1 of 2

 


Tired of the Ads? Registered users have 80% less adverts.