kdawg2k12 Posted February 3, 2012 Share Posted February 3, 2012 this is my email.php file <?php $senderName =$_POST['userName']; $senderEmail =$_POST['userEmail.']; $senderMessage =$_POST['userMessage.']; //security $senderName=stripslashes($userName); $senderEmail=stripslashes($userEmail); $senderMsg=stripslashes($userMessage); $to = '[email protected]'; $from = '[email protected]'; $subject = 'Testing CONTACT PAGE'; $message = 'Message From your site: Their Name: $senderName Their Email: $senderEmail Their Message is below: $senderMsg'; // Build $headers Variable $headers = 'From: Company <[email protected]>' . "\r\n"; $to = '$to'; // Send the email mail($to, $subject, $message, $headers); $my_msg='thanks your message has been sent.'; print $my_msg; ?> The error I'm getting is this: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\xampp\htdocs\PHP_Test\email.php on line 5 all I want to be able to do is verify my form works and that I can receive emails from users of mysite any help would be greatly appreciated. Also what should the send_mail in the PHP.INI file be set to? thansk Quote Link to comment https://forums.phpfreaks.com/topic/256355-sending-email-please-help/ Share on other sites More sharing options...
Andy-H Posted February 3, 2012 Share Posted February 3, 2012 $senderName =$_POST['userName']; $senderEmail =$_POST['userEmail.']; // should the full stop be here? $senderMessage =$_POST['userMessage.']; // should the full stop be here? //security $senderName=stripslashes($userName); $senderEmail=stripslashes($userEmail); $senderMsg=stripslashes($userMessage); $senderName =$_POST['userName']; $senderEmail =$_POST['userEmail.']; // should the full stop be here? $senderMessage =$_POST['userMessage.']; // should the full stop be here? //security $senderName=stripslashes($senderName); $senderEmail=stripslashes($senderEmail); $senderMsg=stripslashes($senderMessage); Also, you should wrap code in or tags Quote Link to comment https://forums.phpfreaks.com/topic/256355-sending-email-please-help/#findComment-1314255 Share on other sites More sharing options...
Pikachu2000 Posted February 3, 2012 Share Posted February 3, 2012 Is that the actual code, cut from your script and pasted in here? The code above doesn't contain any parse errors. Quote Link to comment https://forums.phpfreaks.com/topic/256355-sending-email-please-help/#findComment-1314256 Share on other sites More sharing options...
kdawg2k12 Posted February 4, 2012 Author Share Posted February 4, 2012 @ ANDY H I am not sure what you are referring to when you say should the full stop be here? I am new to PHP thanks for the quick replies Quote Link to comment https://forums.phpfreaks.com/topic/256355-sending-email-please-help/#findComment-1314301 Share on other sites More sharing options...
kdawg2k12 Posted February 4, 2012 Author Share Posted February 4, 2012 Pikachu2000 yes that is the full script I have a html form that retrieves the information. Can someone give me an example of what I need to change in the PHP.INI file to test it locally? and What I should have in the email.php file when i upload it to the live server? I been racking my brain tryna figure this stuff out for over a week now! Quote Link to comment https://forums.phpfreaks.com/topic/256355-sending-email-please-help/#findComment-1314303 Share on other sites More sharing options...
Andy-H Posted February 4, 2012 Share Posted February 4, 2012 $_POST['userMessage.'] the period shouldn't be there, they're not allowed in array keys. This is the issue. Quote Link to comment https://forums.phpfreaks.com/topic/256355-sending-email-please-help/#findComment-1314305 Share on other sites More sharing options...
Pikachu2000 Posted February 4, 2012 Share Posted February 4, 2012 Although the full stops probably aren't supposed to be in the code above, with associative indices, they work fine. With enumerated indices, the index value is truncated at the full stop, but no parse errors are thrown. $array[1.1] = 'numeric'; $array[1.2] = 'numeric2'; $array['string.string'] = 'associative'; $array['string.string2'] = 'associative2'; echo '<pre>'; print_r($array); echo '</pre>'; // RETURNS: Array ( [1] => numeric2 [string.string] => associative [string.string2] => associative2 ) Quote Link to comment https://forums.phpfreaks.com/topic/256355-sending-email-please-help/#findComment-1314320 Share on other sites More sharing options...
trq Posted February 4, 2012 Share Posted February 4, 2012 $_POST['userMessage.'] the period shouldn't be there, they're not allowed in array keys. This is the issue. Array keys are just strings. You can put pretty much whatever you like in there. $a = array('^$r%9)k!!~`}+0h*' => 'foo'); is perfectly valid. Quote Link to comment https://forums.phpfreaks.com/topic/256355-sending-email-please-help/#findComment-1314346 Share on other sites More sharing options...
Andy-H Posted February 4, 2012 Share Posted February 4, 2012 Oh, fair enough, I wasn't sure so read an article that said they weren't allowed. My bad :/ Quote Link to comment https://forums.phpfreaks.com/topic/256355-sending-email-please-help/#findComment-1314403 Share on other sites More sharing options...
kdawg2k12 Posted February 5, 2012 Author Share Posted February 5, 2012 okay i resolved the last error and now I am getting this error Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_ I would like to use a secure connection and use port 465 but I do not know all the parameters i need to configure to do this please advise and thanks for the help guys I am a newbe to PHP Quote Link to comment https://forums.phpfreaks.com/topic/256355-sending-email-please-help/#findComment-1314850 Share on other sites More sharing options...
trq Posted February 5, 2012 Share Posted February 5, 2012 Have you got a mail server installed on localhost? Quote Link to comment https://forums.phpfreaks.com/topic/256355-sending-email-please-help/#findComment-1314861 Share on other sites More sharing options...
kdawg2k12 Posted February 6, 2012 Author Share Posted February 6, 2012 no, i thought I could use my live domain server for testing i.e. [email protected] do i need to install one for it to work correctly? Quote Link to comment https://forums.phpfreaks.com/topic/256355-sending-email-please-help/#findComment-1314990 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.