Mekaboo Posted November 10, 2021 Share Posted November 10, 2021 Hey☺️ I have this simple form <div class="row"> <form action="pro.php" method="post"> Bio: <input type="text" name="bio" size="40"><br> <input type="submit"> </form> Along with this echo <p><?php echo $_POST["bio"]; ?> </p> Everything works fine..the issue is that when I refresh the page with the echo the content disappears. How do I fix it so that it remains in place until new content is submitted? Thank ya❤️ Quote Link to comment https://forums.phpfreaks.com/topic/314194-echo-content-issue/ Share on other sites More sharing options...
requinix Posted November 10, 2021 Share Posted November 10, 2021 Depends on how do you want the site to remember - as in what mechanism saves the data. Because it has to be saved somewhere. For example, there's a session for saving information that you want to use on the rest of the site. And there's cookies for saving information on whatever specific device the user has at that moment. And there's databases for saving virtually anything for any reason. So for you to decide where you store it, you'll first have to decide why you want to. 1 Quote Link to comment https://forums.phpfreaks.com/topic/314194-echo-content-issue/#findComment-1591901 Share on other sites More sharing options...
Mekaboo Posted November 10, 2021 Author Share Posted November 10, 2021 @requinix I can have it saved in my DB. I have it set up already. Quote Link to comment https://forums.phpfreaks.com/topic/314194-echo-content-issue/#findComment-1591927 Share on other sites More sharing options...
Barand Posted November 10, 2021 Share Posted November 10, 2021 I have a solution. SOLVED Quote Link to comment https://forums.phpfreaks.com/topic/314194-echo-content-issue/#findComment-1591929 Share on other sites More sharing options...
gizmola Posted November 10, 2021 Share Posted November 10, 2021 We couldn't possibly guess, without knowing what your pro.php script does to store the data you submitted to it. 1 Quote Link to comment https://forums.phpfreaks.com/topic/314194-echo-content-issue/#findComment-1591930 Share on other sites More sharing options...
Mekaboo Posted November 11, 2021 Author Share Posted November 11, 2021 @gizmola pro.php is the page <p><?php echo $_POST["bio"]; ?> </p> resides on Quote Link to comment https://forums.phpfreaks.com/topic/314194-echo-content-issue/#findComment-1591945 Share on other sites More sharing options...
Mekaboo Posted November 11, 2021 Author Share Posted November 11, 2021 @requinix, @gizmola, @Barand The goal is for the user to update bio every time form is submitted Quote Link to comment https://forums.phpfreaks.com/topic/314194-echo-content-issue/#findComment-1591946 Share on other sites More sharing options...
gizmola Posted November 12, 2021 Share Posted November 12, 2021 Let's try again. What is the code in pro.php? For the "form" script, how and when does that get called? Is this a user system, where a user can change things in their profile? What is your design goal? Do you want the form to always be populated with the existing data? Where do we get the existing user data from? Does it need to be queried from the database? Let's assume your profile page with form, has queried all the user profile data from the database and stored that in an array variable named $user, with array keys for the fields. Then your form code would be something like this: Bio: <input type="text" name="bio" size="40" <?php if (!empty($user['bio']): ?>value="<?= $user['bio'] ?>" <?php endif; ?>> Quote Link to comment https://forums.phpfreaks.com/topic/314194-echo-content-issue/#findComment-1591972 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.