jeff5656 Posted August 15, 2009 Share Posted August 15, 2009 I want to process the form on the same page. At the bottom, after </form> I have: <?php if(isset($_POST['myusername'])) { echo "Your username has been added."; include ("connectdb.php"); $username = mysql_real_escape_string($_POST['myusername']); $password = mysql_real_escape_string($_POST['mypassword']); $query = "INSERT INTO members (id, username, password) VALUES('','$username', '$password')"; mysql_query($query) or die(mysql_error()); ?> <?php } ?> So it echoes "your username has been added" if there is a username value, but how do I clear this value if someone reloads the page so that sentence is not displayed and a new username can be added? Quote Link to comment https://forums.phpfreaks.com/topic/170454-processing-form-on-same-page-and-then-clearing-the-post-values/ Share on other sites More sharing options...
oni-kun Posted August 15, 2009 Share Posted August 15, 2009 <?php if(isset($_POST['myusername'])) { echo "Your username has been added."; include ("connectdb.php"); $username = mysql_real_escape_string($_POST['myusername']); $password = mysql_real_escape_string($_POST['mypassword']); $query = "INSERT INTO members (id, username, password) VALUES('','$username', '$password')"; mysql_query($query) or die(mysql_error()); unset($_POST['myusername']); unset($username); unset($password); } ?> I assume that will work.. refreshing the page would not have a POST. Quote Link to comment https://forums.phpfreaks.com/topic/170454-processing-form-on-same-page-and-then-clearing-the-post-values/#findComment-899165 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.