Jump to content


Photo

displaying info from form on a different page


  • Please log in to reply
2 replies to this topic

#1 maciek4

maciek4
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 31 March 2006 - 09:03 PM

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:

<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>

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

<?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>';
 }
 ?>  

Unfortunatelly nothing is displayed althought there are no errors.



#2 bqallover

bqallover
  • Members
  • PipPipPip
  • Advanced Member
  • 111 posts
  • LocationLeeds, UK

Posted 31 March 2006 - 09:51 PM

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
... HTML with variable interpolation ...
END;

but it's just a matter of preference. :)

#3 maciek4

maciek4
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 03 April 2006 - 10:54 AM

[!--quoteo(post=360482:date=Mar 31 2006, 11:51 PM:name=bqallover)--][div class=\'quotetop\']QUOTE(bqallover @ Mar 31 2006, 11:51 PM) View Post[/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
... HTML with variable interpolation ...
END;

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

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





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users