Please help me , Post Data & Store Data

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

  1. #1
    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
    $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);
    
    ?>
    PHP:

    Thanks
     
    polaris, Mar 23, 2007 IP
  2. jitesh

    jitesh Peon

    Messages:
    81
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Check this

    file1
    $st = "<form action='http://mysite.com/file2.php' method='post'>Name: <input type='text' name='name' />Age: <input type='text' name='age' /><input type='submit' /></form>";
    echo $st;

    file2
    extract($_POST);
    $name = stripslashes($name);$age = stripslashes($age);$logs = fopen('test.txt', 'a', 1);$mytext="$name , $age ";fwrite($logs, $mytext);fclose($logs);
    header('location:http://mysite.com/11.php);
     
    jitesh, Mar 23, 2007 IP
  3. polaris

    polaris Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thank you for the reply but it doesn't posts data to "http://mysite.com/11.php"
    it just writes in the file and after that redirects me to "http://mysite.com/11.php"
     
    polaris, Mar 23, 2007 IP
  4. Zytran

    Zytran Member

    Messages:
    22
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    38
    #4
    After you submit the form are you wanting to print out the posted data?

    try something like...
    if(isset($_POST))
    {
    Print "<pre>";
    Print_r($_POST);
    Print "</pre>";
    }
    Code (markup):
    or

    if(isset($_POST['name']))
    {
    Print $_POST['name'];
    }
    Code (markup):
     
    Zytran, Mar 23, 2007 IP
  5. polaris

    polaris Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    thanks , it worked ;)
     
    polaris, Mar 23, 2007 IP