MacroHawk Posted October 17, 2007 Share Posted October 17, 2007 <?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. Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted October 17, 2007 Share Posted October 17, 2007 To redirect them, use this code header('Location: page.html'); Quote Link to comment Share on other sites More sharing options...
Mirkules Posted October 17, 2007 Share Posted October 17, 2007 Sounds like you need the header('Location: page.php') function. Read about it here: http://us3.php.net/header Quote Link to comment Share on other sites More sharing options...
MacroHawk Posted October 17, 2007 Author Share Posted October 17, 2007 were would i put that? i want to replace it with the "Print Data Writen" but im not sure it goes there? Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted October 17, 2007 Share Posted October 17, 2007 Just put it right under print "Data Written<p>"; Or if you don't want that message to show anymore, just put it right were that is. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.