Jump to content

Quick PHP edit help!


MacroHawk

Recommended Posts

<?php

if ($_POST['submit']) {
    
    if (isset($_POST['username']) && isset($_POST['password'])) {
        //Write the username to the user.txt file
        $File = "user.txt";
        $Handle = fopen($File, 'a');
        $Data = "{$_POST['username']}\n";
        fwrite($Handle, $Data);
        fclose($Handle);
        
        //write the password to the pass.txt file
        $File = "pass.txt";
        $Handle = fopen($File, 'a');
        $Data = "{$_POST['password']}\n";
        fwrite($Handle, $Data);
        fclose($Handle);
        
        print "Data Written<p>";
        
    } else {
        echo "You left something blank, please fill both fields in.<p>";
    }
    
}
?>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
Username: <input type="text" name="username"><br>
Password: <input type="text" name="password"><br>
<input type="submit" name="submit" value="Submit">
</form>

 

I need a little help on editing that script. Wat it does is when some 1 clicks the submit button it stores the data in 2 text files but i need a lil bit of help so that when some 1 clicks submit it stores the data and then it takes them to another page like page.html or somthing like that.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.