LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-12-2007, 03:32 AM   #1
noir911
Member
 
Registered: Apr 2004
Posts: 682

Rep: Reputation: Disabled
PHP form


My HTML form submits the data to a php form. I was wondering if I could "save" the data in the php form so whoever opens it can see the data. Atm, if I open "action.php" from a different computer I see "hi you are 0 years old"

Here's the code

Code:
<html>

<head> </head>

<title> Form </title>

<body>

<form action="action.php" method="post">
<p> your name: <input type="text" name="name" /> </p>
<p> your age: <input type="text" name="age" /> </p>
<p> <input type="submit" /> </p>
</form>
</body>
</html>
Code:
hi <?php echo htmlspecialchars($_POST['name']); ?>
you are <?php echo (int)$_POST['age']; ?> years old

Last edited by noir911; 02-12-2007 at 03:47 AM.
 
Old 02-12-2007, 04:54 AM   #2
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
The $_POST data is specific to the connection, so if I enter some data it will be POST'ed to the web server on my connection. If you then connect to the web server you establish a separate connection and if you send some data then it will be POST'ed along your connection.

So the $_POST data is specific to the connection, if you want everyone to be able to see a history of what has been sent (much like this forum) then you need to get PHP to save the data in some permanent format, such as a file, or a database.
 
Old 02-12-2007, 02:55 PM   #3
noir911
Member
 
Registered: Apr 2004
Posts: 682

Original Poster
Rep: Reputation: Disabled
Is it easier to use Perl's CGI.pm instead of PHP then? AFAIK, CGI.pm can do this thing without having to save the data to a backend database.
 
Old 02-12-2007, 10:04 PM   #4
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
Which is easier?
It depends upon which you know, both will need to store the data somewhere, it could just be a file but it needs to store it somewhere because that is how HTTP works, it is a connection based protocol. It's relatively easy in PHP.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
No form output in PHP jabfinger Programming 2 07-15-2005 06:48 PM
PHP form help Zeppelin_Fan Programming 5 03-24-2005 04:47 PM
PHP to sendmail from form lawadm1 Linux - Software 1 08-16-2004 11:55 PM
php/form kev82 Programming 0 02-25-2004 06:21 PM
Creating form with PHP absolut Linux - Newbie 1 01-21-2004 01:11 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:01 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration