Jump to content

Echo content issue


Mekaboo

Recommended Posts

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❤️

Link to comment
Share on other sites

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.

  • Like 1
Link to comment
Share on other sites

  • Psycho changed the title to Echo content issue

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; ?>>

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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