Jump to content

[SOLVED] Inserting HTML within a PHP function


A.White.89

Recommended Posts

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?

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();

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 '

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.