Jump to content

displaying info from form on a different page


maciek4

Recommended Posts

[quote]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]
<TR><TD ALIGN="right" VALIGN="middle" width="40%"> Product name:&nbsp;
</TD>
<TD ALIGN="right" valign="middle"><input name="name" size="27" type="text"></TD>
</TR>
<TR><TD ALIGN="right" VALIGN="middle">Description:&nbsp;</TD>
   <TD ALIGN="right">  <textarea name="desc" rows="5"></textarea>
   </TD>
   </TR>
[/code]

And in the file add_new.php I want to display whatever text user wrote in those two fields Product name and description.

[code]
<?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:&nbsp;
</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:&nbsp;</TD>
   <TD ALIGN="right"><textarea name="desc" rows="5" value="'.$_POST['desc'].'"></textarea>
   </TD>
   </TR>
   </form>';
}
?>  
[/code]

Unfortunatelly nothing is displayed althought there are no errors.[/quote]
What's in your <form> tag? Is its action pointing to the right file and the method set as POST? Also might be useful to check the source of the page that gets returned. That way you'd know if it's just your $_POST variables not being output, or the whole thing, or parts of it.

For something like this, I'd more likely use HereDoc syntax:

echo <<<END
[i]... HTML with variable interpolation ...[/i]
END;

but it's just a matter of preference. :)
[!--quoteo(post=360482:date=Mar 31 2006, 11:51 PM:name=bqallover)--][div class=\'quotetop\']QUOTE(bqallover @ Mar 31 2006, 11:51 PM) [snapback]360482[/snapback][/div][div class=\'quotemain\'][!--quotec--]
What's in your <form> tag? Is its action pointing to the right file and the method set as POST? Also might be useful to check the source of the page that gets returned. That way you'd know if it's just your $_POST variables not being output, or the whole thing, or parts of it.

For something like this, I'd more likely use HereDoc syntax:

echo <<<END
[i]... HTML with variable interpolation ...[/i]
END;

but it's just a matter of preference. :)
[/quote]

<form action="add_new.php" method="POST" name="submit">

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.