Print out parts of a URL, then enter it in a form field

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Cre8tor
Forum Newbie
Posts: 18
Joined: Tue Aug 24, 2010 3:58 pm

Re: Print out parts of a URL, then enter it in a form field

Post by Cre8tor »

Now that I got the number printed, how would I pass that number through a form? The form code would go something like this:

<form method="post" action="my-form-script.php">
<input name="number" id="number" "type="text">
</form>

but how would I incorporate the

<?php
echo $_GET['number'];
?>

into it so that it is either displaying inside the text field or again passed through in some entirely different other way?
tonchily
Forum Commoner
Posts: 54
Joined: Thu Sep 02, 2010 10:44 am

Re: Print out parts of a URL, then enter it in a form field

Post by tonchily »

Cre8tor wrote:Now that I got the number printed, how would I pass that number through a form? The form code would go something like this:

<form method="post" action="my-form-script.php">
<input name="number" id="number" "type="text">
</form>

but how would I incorporate the

<?php
echo $_GET['number'];
?>

into it so that it is either displaying inside the text field or again passed through in some entirely different other way?
This:

Code: Select all

<?php
echo $_GET['number'];
?>

<form method="post" action="my-form-script.php">
<input name="number" id="number" type="text" value="<?php echo $_GET['number']; ?>">
</form>
Cre8tor
Forum Newbie
Posts: 18
Joined: Tue Aug 24, 2010 3:58 pm

Re: Print out parts of a URL, then enter it in a form field

Post by Cre8tor »

Wow, judging by the way this thread started I would never have believed I'd actually get this completed. Everything has worked. Thanks alot to everyone who contributed.
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Print out parts of a URL, then enter it in a form field

Post by Jonah Bron »

That number is just printed out inline in the page wherever the code is. So if you put the PHP code between the quotes in the input field, it goes there.

Simple :)
Post Reply