A.White.89 Posted February 18, 2009 Share Posted February 18, 2009 Hey all, I'm new to this site as well as PHP. However, I've come to learn it quick due to my C++ knowledge. I've been using a book and building a form online at the same time and I have a problem. function showForm(){ print<<<_HTML_ <form method="POST" action="$_SERVER['PHP_SELF']"> Name: <input type="text" name="name"><br/><br/> E-mail: <input type="text" name="email"><br/><br/> RockDoctor: <select name="rockdoc"> <option value="null"></option> <option value="voice">Voice</option> <option value="guitar">Guitar</option> <option value="drums">Bass Drums</option> <option value="keys">Keys</option> <option value="engineering">Engineering</option> <option value="health">Health</option> <option value="management">Management</option> <option value="legal">Legal</option> </select><br/><br/> Comments, Concerns, Requests: <br/> <textarea name="comments" rows="10" cols="75" ></textarea><br/><br/> <input type="submit" value="Submit to RockDoctor"> </form> _HTML_; } Is what I'm working with so far. When I use this, I get the following error: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home2/cardina6/public_html/PHP_Practice/ask.php on line 24 For reference, line 24 is the line after: print<<<_HTML_ Can anyone shed some light? Link to comment https://forums.phpfreaks.com/topic/145679-solved-inserting-html-within-a-php-function/ Share on other sites More sharing options...
milesap Posted February 18, 2009 Share Posted February 18, 2009 function showForm() { $form = '<form method="POST" action="$_SERVER['PHP_SELF']"> Name: <input type="text" name="name"><br/><br/> E-mail: <input type="text" name="email"><br/><br/> RockDoctor: <select name="rockdoc"> <option value="null"></option> <option value="voice">Voice</option> <option value="guitar">Guitar</option> <option value="drums">Bass Drums</option> <option value="keys">Keys</option> <option value="engineering">Engineering</option> <option value="health">Health</option> <option value="management">Management</option> <option value="legal">Legal</option> </select><br/><br/> Comments, Concerns, Requests: <br/> <textarea name="comments" rows="10" cols="75" ></textarea><br/><br/> <input type="submit" value="Submit to RockDoctor"> </form>'; return $form; } print showForm(); Link to comment https://forums.phpfreaks.com/topic/145679-solved-inserting-html-within-a-php-function/#findComment-764817 Share on other sites More sharing options...
A.White.89 Posted February 18, 2009 Author Share Posted February 18, 2009 Hmmm....well, I tried that and I'm getting the same error. Could it be something else? Link to comment https://forums.phpfreaks.com/topic/145679-solved-inserting-html-within-a-php-function/#findComment-764821 Share on other sites More sharing options...
milesap Posted February 18, 2009 Share Posted February 18, 2009 function showForm() { $form = '<form method="POST" action="$_SERVER[\'PHP_SELF\']"> Name: <input type="text" name="name"><br/><br/> E-mail: <input type="text" name="email"><br/><br/> RockDoctor: <select name="rockdoc"> <option value="null"></option> <option value="voice">Voice</option> <option value="guitar">Guitar</option> <option value="drums">Bass Drums</option> <option value="keys">Keys</option> <option value="engineering">Engineering</option> <option value="health">Health</option> <option value="management">Management</option> <option value="legal">Legal</option> </select><br/><br/> Comments, Concerns, Requests: <br/> <textarea name="comments" rows="10" cols="75" ></textarea><br/><br/> <input type="submit" value="Submit to RockDoctor"> </form>'; return $form; } print showForm(); ?> Forgot to escape the ' Link to comment https://forums.phpfreaks.com/topic/145679-solved-inserting-html-within-a-php-function/#findComment-764823 Share on other sites More sharing options...
A.White.89 Posted February 18, 2009 Author Share Posted February 18, 2009 Thanks, that worked well. Link to comment https://forums.phpfreaks.com/topic/145679-solved-inserting-html-within-a-php-function/#findComment-764835 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.