Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6

Thread: PHP Submit

  1. #1
    New Coder
    Join Date
    Oct 2006
    Posts
    68
    Thanks
    3
    Thanked 0 Times in 0 Posts

    PHP Submit

    I do not know what its called but basically it is a form. It is more than a form.
    It's hard to explain.
    Let's say that I have two files: info.txt/info.dat and form.php.
    In form.php, I have the form code, then when you view it and test it and make something up. I want all the data that was submit to go inside the info.txt file.

    If i am not clear, please reply. Thank you

    BTW: this is not to phish someone, but this is for my school club website that I am doing.
    Last edited by van21691; 04-13-2008 at 03:59 AM.

  • #2
    Regular Coder Iszak's Avatar
    Join Date
    Jun 2007
    Location
    Perth, Western Australia
    Posts
    332
    Thanks
    2
    Thanked 58 Times in 57 Posts
    You'll want to the fread, fwrite commands, this way you can save data into the file, but I'll have a character that seperates each submit like a linebreak or something so when you're parsing it you can seperate it.

  • #3
    New Coder
    Join Date
    Oct 2006
    Posts
    68
    Thanks
    3
    Thanked 0 Times in 0 Posts
    could you post on how would I do that.
    Thank you

  • #4
    New Coder
    Join Date
    Oct 2006
    Posts
    68
    Thanks
    3
    Thanked 0 Times in 0 Posts
    This is what I got from the net. Basically, what this do is after you hit submit, it will replace whatever is in the info.dat. What I want is instead of replacing what is in the info.dat, I want to put more
    PHP Code:
    <?
    $newcontents
    ="This
    is my content"
    //
    $filename="info.dat";

    $fp fopen ($file_name"w");


    fclose ($fp);

    chmod($file_name,0777);

    ?>
    <html>
    <head>
    <title>File Editor Test</title>
    </head>
    <body>
    <h1>File Editor Test</h1>

    <?php
    $newcontents 
    $contents;
    if(isset(
    $_POST['submit'])) { //if submit was pressed
    $writefh fopen($filename"w"); //File handle for $filename

    if(get_magic_quotes_gpc()){
    $newcontents=stripslashes($_POST['editcontents']);
    //strips unneeded backspaces by magicquotes
    else{
    $newcontents $_POST['editcontents'];
    }

    //NEXT 3 LINES ARE THE PROBLEM SPOT:
    fwrite($writefh$newcontentsstrlen($newcontents)); //Saves changes
    rewind($readfh); //resets cursor in file

    echo("The changes were saved.<br/>\n");
    fclose($writefh);
    }
    ?>
    Edit the file here:
    <form method="post" action="<? echo($PHP_SELF); ?>">
    <textarea name="editcontents" style="width:400px; height:150px;"><? echo($newcontents); ?></textarea>
    <br />
    <input type="submit" name="submit" value="Save Changes" />


    </form>
    </body>
    </html>

  • #5
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Change this
    PHP Code:
    $fp fopen ($file_name"w"); 
    to this
    PHP Code:
    $fp fopen ($file_name"a+"); 
    There are other things you could use. I suggest you read the manual on whats available.
    http://us.php.net/manual/en/function.fopen.php
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #6
    New Coder
    Join Date
    Oct 2006
    Posts
    68
    Thanks
    3
    Thanked 0 Times in 0 Posts
    thanks for the help. i got it now
    Thank you


  •  

    Posting Permissions

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