Jump to content

[SOLVED] PrePoulating a form


NewbieBryan

Recommended Posts

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

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.