Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filling a form with another form 1

Status
Not open for further replies.

jisoo22

Programmer
Joined
Apr 30, 2001
Messages
277
Location
US
Hello all!

I'm using PHP and Postgresql although I think the same concepts will apply to Mysql. I have two forms, one with a single text field where a name is inputed, and a submit button. When that button is pressed, you are taken to the next form to fill out additional information for final submission. Here's the problem, one of the text fields in the 2nd page needs to be populated by the same name in the first page. I tried to use the following command in the "value" argument for the text field:

VALUE = <?php echo&quot;$_POST[name]&quot;;?>

It only partially works, it seems to only take in only one word. Usually more then one word will be inputted into that text field in the first form. Does anyone know how I can capture all the text in the field?

Thanks,
Jisoo22
 
Sure... this is almost always the result of a basic HTML error.
Code:
<input type=&quot;text&quot; name=&quot;foo&quot; value=foo bar>
will appear on your page as a text box containing the value foo. Attributes in HTML are, by the standard, to be quoted. So
Code:
value = &quot;<?php echo $_POST[&quot;name&quot;]?>&quot;

Should do the trick for you.

-Rob
 
That did the trick, thanks a lot!

-Jisoo22
 
Hello again!

Now I have a similar problem with respect to what I had before. I still have that 2nd page which takes a value from the first page, but that first page has now changed. The new text field is now a list box that is automatically populated via a database. I used the following code for that:

<select name=&quot;name&quot;>
<option value= &quot;&quot; selected>Select One</option>
<?
while($i <= $num){
$ass_name = pg_Result($query, $i, name);
echo&quot;<option value=$name>name</option>&quot;;
$i++;
}
?>
</select>

When I used this instead of just a regular text box, I get the same problem as before, instead of the full name being fed into the 2nd page, only the first name/word does. I'm guessing this is also a formatting issue? Any suggestions would be very helpful.

Thanks,
Jisoo22
 
This time you're not quoting it on the way in... same basic idea... change
Code:
echo &quot;<option value...&quot;;
to
echo &quot;<option=\&quot;$name\&quot;>name</option>&quot;;
or
echo '<option=&quot;'.$name.'&quot;>name</option>';

It's good practice to quote all your HTML attributes all the time.

-Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top