|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Pass a value to a text box on php form
How can I pass a value to a text box on a php form from an html form?
|
|
#2
|
||||
|
||||
|
PHP Code:
|
|
#3
|
|||
|
|||
|
Not doing so hot here in AZ.
The following form is placed inside my php routine. $VariablePassed is the variable passed from the search or submit form in the http address. I get a Parse error: parse error, unexpected '<' message when I use the following statements in the form below <form method="GET" action="TheForm5.php"> <p><b><font size="4" face="Arial">The Form5</font></b></p> <input type="text" value="<?=$VariablePassed;?>"> </form> Other input type= statements I have tried have been the following with the same resuts. <p><input type="text" input name="SeeAlso" size="20" value=<? echo $SeeAlso?><input type="submit"></p> <p><input type="text" input name="SeeAlso" size="20" value= <echo $SeeAlso><input type="submit"></p> <p><input type="text" input name="SeeAlso" size="20" value=<echo $SeeAlso><input type="submit"></p> <input type="text" value="<?=$SeeAlso;?>"><input type="submit"></p> <p><input type="text" value="<?=$SeeAlso;?>"><input type="submit"></p> <input type="text" value="<?=$SeeAlso;?>"> <p><input type="submit"></p> input type="text" value="<?=$SeeAlso;?>" <p><input type="submit"></p> <p><input type="text" value="?=$SeeAlso;?"><input type="submit"></p> <p><input type="text" value="?=$SeeAlso;?"></p> <input type="text" value="<?=$SeeAlso;?>"> |
|
#4
|
|||
|
|||
|
You probably have some PHP code that you're not closing out of before you start your HTML:
PHP Code:
Make sure you have that '?>' before your opening <form> tag. Also, a note on syntax: Whether the echo shortcut <?=$foo?> works is determined by the short_open_tag ini setting. <? echo $foo; ?> will always work, so if you're writing code that needs to be highly portable, you're probably better off using the full echo. That said, most of my code doesn't have to be that portable, so I use the short form. |
|
#5
|
|||
|
|||
|
Madpawn. You are correct. Excellent!!!!!
Here is the working code for archival purposes. <BODY> <?php $var = 'foo'; ?> <p> </p> <form method="GET" action="The Form.php"> <p><b><font size="4" face="Arial">Search Other</font></b></p> <p><input type="text" value="<?=$Variable1;?>" input name="Var1" size="20"><input type="submit"><input type="reset" value="Reset" name="B2"></p> </form> <p> </p> |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > Pass a value to a text box on php form |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|