Jump to content

PHP echo HTML form


Thomisback

Recommended Posts

Hi,

 

I am trying to echo a HTML form in PHP but I also need to echo PHP variables in the form, I have done it like this:

 

echo ' 
<table width="300" border="0" align="center" cellpadding="0" cellspacing="1">
<tr>
<form name="form1" method="post" action="registercheck.php">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1">
<tr>
</tr>
<tr>
<td width="78">Gebruikersnaam:</td>
<td width="6">:</td>
<td width="294"><input name="usr" type="text" id="usr" value=<?php echo $userName;?> </td> <<< does not work
</tr>
<tr>
<td>Wachtwoord</td>
<td>:</td>
<td><input name="pw" type="text" id="pw" value=$userPassword></td> <<< does not work either
</tr>
<td>E-mail adres:</td>
<td>:</td>
<td><input name="email" type="text" id="email" value=$userMail></td> <<< does not work either
</tr>
<td>Type:</td>
<td>:</td>
<td><input name="type" type="text" id="type" value=$type></td> <<< does not work either
</tr>
<tr>
<td> </td>
<td> </td>
<td><input type="submit" name="Submit" value="Meld aan!"></td>
</tr>
</table>
</td>
</form>
</tr>
</table>
';

Link to comment
https://forums.phpfreaks.com/topic/95374-php-echo-html-form/
Share on other sites

Your already within php so there no need for more <?php tags. however, variables are not interpolated within single quotes. You will need to come out of the quotes and concatinate your variables. eg;

 

value=<?php echo $userName;?> </td>

 

will become...

 

value=' . $userName . '</td>

Link to comment
https://forums.phpfreaks.com/topic/95374-php-echo-html-form/#findComment-488434
Share on other sites

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.