Go4Expert (http://www.go4expert.com/)
-   PHP (http://www.go4expert.com/forums/php/)
-   -   Please help me , Post Data & Store Data (http://www.go4expert.com/forums/help-post-data-store-data-t3579/)

polaris 23Mar2007 15:17

Please help me , Post Data & Store Data
Hi guys

want to make a form with 2 actions, means by 1 click 2 actions performs and I do not want to use PHP_SELF, because the first action address is the main target and the second one is to store data

its my code but it doesn't store data in "test.txt" just posts to "http://mysite.com/11.php"
PHP Code:

<form action='http://mysite.com/11.php' method='post'>
Name: <input type='text' name='name' />
Age: <input type='text' name='age' />
<input type='submit' />

$name stripslashes($name);
$age stripslashes($age);
$logs fopen('test.txt''a'1);
$name , $age ";




shubhangi_mohite26 24Mar2007 00:32

Re: Please help me , Post Data & Store Data
Please explain what @ actions U want to perform?

pradeep 24Mar2007 10:10

Re: Please help me , Post Data & Store Data
What exactly is your objective? please elaborate!

DaWei 31Mar2007 03:43

Re: Please help me , Post Data & Store Data
You have a couple of issues.

Oddly enough, the writers of functions like fopen and fwrite provide a means of testing them for success. You seem to believe that is a wasted, worthless effort, since you don't use it. You may succeed occassionally, but not as a real programmer.

Worse, you seem to think that the client and server side actions are interactive on an intimate scale. They are not.

At the time your shown code runs, it constructs a document that will ask for the given information. It then transmits that document to the client and closes the connection. At that time there is no user information available for test.txt other than what you have stuffed in the variables, yourself. In this case, that is zero, zip, zilch, nada, nothing. Your program terminates, having disappointed you in your expectations.

At some later time, maybe, and maybe never, a client may fill in the form and press the submit button. At this time a new request is made of your server: specifically, that it will execute a file named 11.php, located on a path whose URL is http://mysite.com/. There is no indication from you that this file is the same file as the one you show.

This new (same?) file will be provided with the information that formed the NEW request, including POST information. It will be the responsibility of this different file (or the one you show, if that is indeed its name, and IF YOU ADD TO IT, to grab this information and store it away in test.txt.

Think of this client/server as more of a walkie talkie communication than as a telephone conversation. There is no intimate interaction. Requests are made. Responses are given. The server has no inkling of your user moving the mouse or banging on the keyboard. Your server doesn't know if the client is there or not. If you want any continuity, you have to build it in. Even so, it isn't guaranteed. The client has to cooperate, one way or another, in sustaining it.

All times are GMT +5.5. The time now is 02:19.