Solved

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

Posted on 2004-04-22
6
240 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
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…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

911 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now