distant Posted November 23, 2009 Share Posted November 23, 2009 How can I keep whatever I write in the form? Quote Link to comment https://forums.phpfreaks.com/topic/182644-keeping-data-in-form/ Share on other sites More sharing options...
mraza Posted November 23, 2009 Share Posted November 23, 2009 what do you mean by keep? you wants to store in database? you wants to send email of that form? or anything else? plz explain Quote Link to comment https://forums.phpfreaks.com/topic/182644-keeping-data-in-form/#findComment-963969 Share on other sites More sharing options...
distant Posted November 23, 2009 Author Share Posted November 23, 2009 Thanks for replying mraza I mean keeping an username and password on the field of the form once I click submit. Hope that's clear. what do you mean by keep? you wants to store in database? you wants to send email of that form? or anything else? please explain Quote Link to comment https://forums.phpfreaks.com/topic/182644-keeping-data-in-form/#findComment-963976 Share on other sites More sharing options...
Anzeo Posted November 23, 2009 Share Posted November 23, 2009 Not sure why you'd want that, but you can use the value attribute of the input element. like: <?php $username = $_POST['username]; ?> <input type="text" name="username" value="<?php echo $username ?>" /> Quote Link to comment https://forums.phpfreaks.com/topic/182644-keeping-data-in-form/#findComment-963977 Share on other sites More sharing options...
mrMarcus Posted November 23, 2009 Share Posted November 23, 2009 <input type="text" name="username" value="<?php echo $_POST['username']; ?>" /> change out 'username' for your value(s), and do the same for any other form fields you want. Quote Link to comment https://forums.phpfreaks.com/topic/182644-keeping-data-in-form/#findComment-963980 Share on other sites More sharing options...
distant Posted November 23, 2009 Author Share Posted November 23, 2009 this is what I got and I want the username and pass to stay in the flield once i submit it. $message = "<p>Please enter your login information below:</p>" ; $tempUsername = ($_POST["username"]) ; $tempPass = ($_POST["password"]) ; $congrats = "<span class='stylesheet'><p>Congrats, you successfully logged in.<p/></span>" ; $sorry = "<span class='style1'><p>Sorry, your username and password combo was not correct, please try again.</p></span>" ; if (isset($_POST ['submit'])) { if($tempUsername == "Michael") { echo $congrats ; } elseif($tempPass == "pass") { echo $Congrats ; } else echo $sorry ; } else echo $message ; <form id="form1" name="form1" method="post" action="login.php"> <p> <label for="username">Username:</label><br /> <input type="text" name="username" id="username" value="" /> </p> <p> <label for="password">Password:</label><br /> <input type="text" name="password" id="password" value="" /> </p> <p><input name="submit" type="submit" /></p> </form> Quote Link to comment https://forums.phpfreaks.com/topic/182644-keeping-data-in-form/#findComment-963987 Share on other sites More sharing options...
Anzeo Posted November 23, 2009 Share Posted November 23, 2009 Well like we said: add the value attributes to your input tags like this: <form id="form1" name="form1" method="post" action="login.php"> <p> <label for="username">Username:</label><br /> <input type="text" name="username" id="username" value="<?php echo $tempUsername?>" /> </p> <p> <label for="password">Password:</label><br /> <input type="text" name="password" id="password" value="<?php echo $tempPass?>" /> </p> <p><input name="submit" type="submit" /></p> </form> Quote Link to comment https://forums.phpfreaks.com/topic/182644-keeping-data-in-form/#findComment-963997 Share on other sites More sharing options...
distant Posted November 23, 2009 Author Share Posted November 23, 2009 Thank you so much, guys! You rock! Quote Link to comment https://forums.phpfreaks.com/topic/182644-keeping-data-in-form/#findComment-964001 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.