Solved

How to ouput form information on same (form) page?

Posted on 2004-04-22
6
270 Views
Last Modified: 2008-03-06
Hello,

I am wondering if (then how) it is possible to output data received from a form on the same page as form, and also to for every new input in the form, to lineup the datas below each other.

What I am trying to say is that I would like the site to have the functionality as a "Guest book-site" or as a "Forum"  where the visitor can just leave a message and see what others before them have written.

Ex:
*****************************************************
echo "<form action='thispage.php' method='post'>":
//some input fields     ...<input .....name=subject> ....
//.....<input.....name=message> .....
// ...etc ...
echo "</form>";

// here the information inputed in the form should be output ::
$subj = $_POST["subject"];
$msg = $_POST["message"];
etc....

*****************************************************
So, for every new entry in the form (by same or different user) the inputed data should be outputed just below the form.
And so is should lineup every new entry below each other, without overwriting the previous data !!

And I don't want to wirte the form data down to file and then read the data back to the site for every entry because that would be unneccesary .....I think

I hope you got what I meant..
0
Comment
Question by:Hannibal_L
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 1

Accepted Solution

by:
chrgary earned 43 total points
ID: 10887754
I think I understand what you mean, and this would be possible for each individual user to see their own comments using cookies or sessions perhaps, but other visitors that visit the page will not be able to see the comments of other visitors without them being written to a database or text file.  The only variables that everyone can see are $_server and $_env variables, which unfortunately only the webserver and php namespace write to.

Your best bet would probably be to store them in a database, since having a textfile marked as readable and writable might compromise the security since you have to set that file as readable and writable on your webserver, unless you place it outside of the webroot directory.
0
 
LVL 6

Assisted Solution

by:carchitect
carchitect earned 41 total points
ID: 10887762
simple either use some file handling ......

//Form Code
<Any data submitted to form shud be appeneded to the file>
//Form closed

//Display file

It is just like this page (experts exchnage)

or use some database...submit data in it ....and display after form...like forums
0
 

Assisted Solution

by:Uzaree
Uzaree earned 41 total points
ID: 10922501
All you need to do is remove the

"<form action='thispage.php' method='post'>

and change it to

"<form action='' method='post'>

that will cause the form to post to itself

so now you would have

Ex:
*****************************************************
echo "<form name='form' method='post'>":
//some input fields     ...<input .....name=subject> ....
//.....<input.....name=message> .....
// ...etc ...
echo "</form>";

// here the information inputed in the form should be output ::
$subj = $_POST["subject"];
$msg = $_POST["message"];

print $subj;
print $msg;

etc....

*****************************************************
0

Featured Post

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question