Forum Moderators: coopster

Message Too Old, No Replies

Populate forms edit boxes

         

Pointman

6:11 pm on Jan 22, 2005 (gmt 0)

10+ Year Member



Hello ppl :)

I have two simple text boxes in my <form> declaration

On the same page I gave PHP code on top which is called from within tha same html portion of the page at the bottom.

Is there a way to dynamically populate the existing text box in the html part using code from the PHP part?

Thanks in advance

coopster

6:16 pm on Jan 22, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, Pointman.

Sure you can. Just invoke PHP within the HTML whenever/wherever you want.

<?php 
$name = (isset($_POST['name'])) ? $_POST['name'] : 'Pointman';
?>
<form action="<?php print $_SERVER['PHP_SELF'];?>" method="post">
Name: <input name="name" type="text" value="<?php print $name;?>" /><br />
<input type="submit" name="Submit" value="Submit" />
</form>

Pointman

8:37 pm on Jan 22, 2005 (gmt 0)

10+ Year Member



Thanks alot :)