Page 1 of 1

html and php form issues

Posted: Tue Oct 07, 2008 2:58 pm
by zsobell
I am having trouble writing a simple script that will email me and the commenter the contents of their comment. Right now it looks like

Code: Select all

<?php
  $name = $_REQUEST['name'] ;
  $email = $_REQUEST['email'] ;
  $comment = $_REQUEST['comment'] ;
  
  $subject = 'a comment for you' ;
  $content = 'Comment:' ."\n" .$comment.
            .'From,' ."\n"
            .$name. ;
            
  $subject2 = 'Comment Confirmation' ;
  $content2 = 'Please do not reply.  This is an automated comment confirmation send by http://www.sobellium.com.' ."\n" ."\n"
            .$comment.
            .'From,' ."/n"
            .$name. ;
            
   mail( 'zach@sobell.com', $subject, $content, "From: $email") ;
   mail( $email, $subject2, $content2, "From: 'sobellium.com'") ;
   header( "Location: http://www.sobellium.com/contact" ) ;
?>
the error involves a "T_VARIABLE" on line 7

I'm sure its something blatantly obvious...

Re: html and php form issues

Posted: Tue Oct 07, 2008 3:05 pm
by onion2k
Your quotes and concatenation is a bit messed up.

What you have at the moment:

Code: Select all

$content = 'Comment:' ."\n" .$comment..'From,' ."\n".$name.;
What it should be:

Code: Select all

$content = 'Comment:\n'.$comment.'\nFrom,\n'.$name;
The way it works is that your closing quote needs to match the opening quote.. so if you open with ' you need to close with ', and between quoted blocks you should glue things together with periods (full stops) eg 'Text here'.$var.'more text here' ... Don't put a period at the end, or two periods next to each other.

Re: html and php form issues

Posted: Tue Oct 07, 2008 3:17 pm
by zsobell
Thank you for your timely response (5 minutes...) and your help, although it appears that the ' quotes denote (at least in this case) output text, so i get a string that says, for example, "thank you,\nZach"

what is the correct way to solve this?

would this work:

Code: Select all

 $content = 'Comment:'."\n".$comment."\n".'From,'."\n".$name;
 
*edit -- it works. no need to reply unless there is a more correct way

thanks again