Please help me , Post Data & Store Data

Discussion in 'PHP' started by polaris, Mar 23, 2007.

  1. polaris

    polaris New Member

    Joined:
    Feb 1, 2007
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    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:
    <?php
    $st 
    "
    <form action='http://mysite.com/11.php' method='post'>
    Name: <input type='text' name='name' />
    Age: <input type='text' name='age' />
    <input type='submit' />
    </form>
    "
    ;
    echo 
    $st;

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

    fwrite($logs$mytext);
    fclose($logs);

    ?>

    Thanks
     
  2. shubhangi_mohite26

    shubhangi_mohite26 New Member

    Joined:
    Feb 27, 2007
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    Please explain what @ actions U want to perform?
     
  3. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,645
    Likes Received:
    87
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    http://blog.pradeep.net.in
    What exactly is your objective? please elaborate!
     
  4. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    http://www.daweidesigns.com
    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.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice