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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.