Closed Thread
Results 1 to 8 of 8

Thread: Please help me , Post Data & Store Data

  1. #1
    minusp is offline Newbie
    Join Date
    Feb 2007
    Posts
    6
    Rep Power
    0

    Post 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"
    Code:
    <?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. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Lop's Avatar
    Lop
    Lop is offline Speaks fluent binary
    Join Date
    May 2006
    Posts
    1,178
    Rep Power
    30
    Everything looks good here, does test.txt have world permission (Writable permission, 777)?

    You might want to put a condition to handle if the file is not open, then you will be able to determine if the file is open.

    Code:
    if (($fp fopen($filename"r+") === FALSE) {
      
    // handle error
      
    exit;


  4. #3
    minusp is offline Newbie
    Join Date
    Feb 2007
    Posts
    6
    Rep Power
    0
    problem is not premission
    it can write if you change the action to 11.php, but if you do it , it just writes in the file , and doesn't post data to mysite.com/11.php

  5. #4
    Jaan Guest
    but try this..

    Code:
    <?php

    function form(){

    <
    form action='myfile.php?act=write' method='post'>
    Name: <input type='text' name='name' />
    Age: <input type='text' name='age' />
    <
    input type='submit' />
    </
    form>
    }

    function 
    write(){
    $name $_REQUEST['name'];
    $age $_REQUEST['age'];
    $name stripslashes($name);
    $age stripslashes($age);
    $logs fopen('test.txt''a'1);
    $mytext="
    $name , $age "
    ;

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

    switch(
    $act){

    default;
    form();
    break;

    case 
    "write";
    write();
    break;

    }

    ?>
    i'm pretty sure that this does the job..
    just change this:

    <form action='myfile.php?act=write' method='post'>

  6. #5
    minusp is offline Newbie
    Join Date
    Feb 2007
    Posts
    6
    Rep Power
    0
    thanks but its php_self and i want to post the data to another site 'http://mysite.com/11.php'

  7. #6
    Jaan Guest
    well hmm.. ookay:

    form.php
    Code:
    <?php
    echo "<form action='http://mysite.com/11.php' method='post'>
    Name: <input type='text' name='name' /><br>
    Age: <input type='text' name='age' /><br>
    <input type='submit' />
    </form>"
    ;
    ?>
    Now you must insert this part into your 11.php file:
    Code:
    <?php
    $name 
    $_POST['name'];
    $age $_POST['age'];
    $name stripslashes($name);
    $age stripslashes($age);
    $logs fopen('test.txt''w');
    $mytext="
    $name , $age "
    ;

    $write fwrite($logs$mytext);
    if(!
    $write){
    die(
    "Can not write info into file!");
    }
    fclose($logs);
    ?>
    and it works

  8. #7
    minusp is offline Newbie
    Join Date
    Feb 2007
    Posts
    6
    Rep Power
    0
    thanks , worked

  9. #8
    Jaan Guest
    you're welcome

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 7
    Last Post: 12-26-2011, 01:05 PM
  2. Replies: 2
    Last Post: 10-28-2011, 08:21 AM
  3. How to decide how to store your data?
    By wim DC in forum General Programming
    Replies: 8
    Last Post: 06-01-2011, 04:15 PM
  4. Replies: 7
    Last Post: 10-08-2010, 05:39 PM
  5. How to have PHP get data from websites and store in mySQL
    By Scottyf11 in forum PHP Development
    Replies: 1
    Last Post: 08-06-2008, 11:23 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts