NewbieBryan Posted July 12, 2009 Share Posted July 12, 2009 What I want to do is set the initial value of an input block based on a variable; I have tried a couple of things and am possitive that i am missing something elementary.... The default for the 3 test forms below is 1 - BLANK 2 - $name (the word not the variable) 3 - $name (the word not the variable) Where am I going wrong (tx in advance) <?php //set var name $name = "Bryan"; //Checking my vaiable is set echo "Var_name set to " . $name ?> <html> <body> <P>------------------------------------------------------------ FORM1 <form action="myengine.php" method="post"> Event:<input type="text" name="Event" value="<?php $name ?>" /> <P> <input type="submit" /> </form> <P>------------------------------------------------------------ FORM2 <form action="myengine.php" method="post"> Event:<input type="text" name="Event" value="$name" /> <P> <input type="submit" /> </form> <P>------------------------------------------------------------ FORM3 <form action="myengine.php" method="post"> Event:<input type="text" name="Event" value=$name /> <P> <input type="submit" /> </form> </html> </body> Link to comment https://forums.phpfreaks.com/topic/165724-solved-prepoulating-a-form/ Share on other sites More sharing options...
Box Posted July 12, 2009 Share Posted July 12, 2009 you just need to actually print the variable ie: Event:<input type="text" name="Event" value="<?php echo($name); ?>" /> <P> Link to comment https://forums.phpfreaks.com/topic/165724-solved-prepoulating-a-form/#findComment-874248 Share on other sites More sharing options...
NewbieBryan Posted July 12, 2009 Author Share Posted July 12, 2009 Tx Box - Works like a charm: Feel like a right idiot now..... Link to comment https://forums.phpfreaks.com/topic/165724-solved-prepoulating-a-form/#findComment-874255 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.