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
https://forums.phpfreaks.com/topic/73711-quick-php-edit-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.