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
maciek4
Forum Commoner
Posts: 29 Joined: Tue Apr 04, 2006 8:17 am
Post
by maciek4 » Tue Apr 04, 2006 8:47 am
I want to gather information from the user and display it on another page.
In the file commit.php I have 2 fields
Product name:
Description:
Code: Select all
<form action="add_new.php" method="POST" name="submit">
<TR><TD ALIGN="right" VALIGN="middle" width="40%"> Product name:
</TD>
<TD ALIGN="right" valign="middle"><input name="name" size="27" type="text"></TD>
</TR>
<TR><TD ALIGN="right" VALIGN="middle">Description: </TD>
<TD ALIGN="right"> <textarea name="desc" rows="5"></textarea>
</TD>
</TR>
</form>
And in the file add_new.php I want to display whatever text user wrote in those two fields Product name and description.
Code: Select all
<?php
if (isset ($_POST['name']) || isset ($_POST['desc']))
{
echo'<form action="add_new.php" method="POST" name="submit">
<TR><TD ALIGN="right" VALIGN="middle" width="40%"> Product name:
</TD>
<TD ALIGN="right" valign="middle"><input name="name" size="27" type="text" value="'.$_POST['name'].'"></TD>
</TR>
<TR><TD ALIGN="right" VALIGN="middle">Description: </TD>
<TD ALIGN="right"><textarea name="desc" rows="5" value="'.$_POST['desc'].'"></textarea>
</TD>
</TR>
</form>';
}
?>
Unfortunatelly nothing is displayed althought there are no errors.
maciek4
Forum Commoner
Posts: 29 Joined: Tue Apr 04, 2006 8:17 am
Post
by maciek4 » Tue Apr 04, 2006 9:04 am
I partially solved it. I got rid of a href and its almost ok except for the textarea
Code: Select all
<textarea name="desc" rows="5" value="'.$_POST['desc'].'"></textarea>
Why its not displaying value I dont know
maciek4
Forum Commoner
Posts: 29 Joined: Tue Apr 04, 2006 8:17 am
Post
by maciek4 » Tue Apr 04, 2006 9:13 am
Used that
<textarea name="desc" rows="5">'.$_POST['desc'].'</textarea>
and now it works.
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Tue Apr 04, 2006 9:18 am
Yup, that is the correct way to do it with text areas. It's slightly different to other form elements