the_real_JLM Posted March 26, 2008 Share Posted March 26, 2008 I'm working on a small job application for a company, using basic sendmail and a form. Here's the sendmail code: <?php $email = $_REQUEST['email'] ; $message = $_REQUEST['message'] ; $firstname = $_REQUEST['firstname'] ; $lastname = $_REQUEST['lastname'] ; $telephone = $_REQUEST['telephone'] ; $driverslicense = $_REQUEST['driverslicense'] ; $position = $_REQUEST['position'] ; $address = $_REQUEST['address'] ; mail( "[email protected]", "Job Application", $message . $firstname), "From: $email" ); header( "http://blah.com" ); ?> You can see where the strings are returned, message and firstname, I need a new line inserted between them. I've tried using . \n . and . '\n' . and . $newline . and a few other ideas but its not happening. Can anybody shed some light on the subject please? Quote Link to comment https://forums.phpfreaks.com/topic/97999-alternatives-to-newline-code-n/ Share on other sites More sharing options...
wildteen88 Posted March 26, 2008 Share Posted March 26, 2008 To use a newline in a string you need to use double quotes not single quotes: $str = "string with \n new lines in \n it"; echo '<pre>' . $str . '</pre>'; Quote Link to comment https://forums.phpfreaks.com/topic/97999-alternatives-to-newline-code-n/#findComment-501413 Share on other sites More sharing options...
the_real_JLM Posted March 26, 2008 Author Share Posted March 26, 2008 Thanks for the quick reply, ok so I tried this: <?php $email = $_REQUEST['email'] ; $message = $_REQUEST['message'] ; $firstname = $_REQUEST['firstname'] ; $lastname = $_REQUEST['lastname'] ; $telephone = $_REQUEST['telephone'] ; $driverslicense = $_REQUEST['driverslicense'] ; $position = $_REQUEST['position'] ; $address = $_REQUEST['address'] ; mail( "[email protected]", "Job Application", $message . "\n" . $firstname), "From: $email" ); header( "blah.com" ); ?> and was returned this: Parse error: syntax error, unexpected ',' in /home/hodd5538/public_html/sendmail.php on line 12 Am I still doing something wrong somewhere? Quote Link to comment https://forums.phpfreaks.com/topic/97999-alternatives-to-newline-code-n/#findComment-501417 Share on other sites More sharing options...
rhodesa Posted March 26, 2008 Share Posted March 26, 2008 You have an extra ) after $firstname Special characters like \n \r \t are only converted into their respective special values inside double quotes. So, "\n" is a new line '\n' are the literal characters \ and n Quote Link to comment https://forums.phpfreaks.com/topic/97999-alternatives-to-newline-code-n/#findComment-501420 Share on other sites More sharing options...
rhodesa Posted March 26, 2008 Share Posted March 26, 2008 Also, are you trying to forward the page to http://hodder.ca/index.php ? If so, it should be: header("Location: http://hodder.ca/index.php"); Quote Link to comment https://forums.phpfreaks.com/topic/97999-alternatives-to-newline-code-n/#findComment-501422 Share on other sites More sharing options...
Demonic Posted March 26, 2008 Share Posted March 26, 2008 header( "blah.com" ); Should be header("Location: blah.com") -.-..he beat me to it. Quote Link to comment https://forums.phpfreaks.com/topic/97999-alternatives-to-newline-code-n/#findComment-501423 Share on other sites More sharing options...
the_real_JLM Posted March 26, 2008 Author Share Posted March 26, 2008 Perfect! I didnt even notice the extra bracket, I should have =.= Thanks a ton for the help guys the redirect works now too btw, thanks guys Quote Link to comment https://forums.phpfreaks.com/topic/97999-alternatives-to-newline-code-n/#findComment-501425 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.