Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8521753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:54:57+00:00 2026-06-11T06:54:57+00:00

When I type something in a text box and save it in mysqli it

  • 0

When I type something in a text box and save it in mysqli it works perfectly but when I refresh that same page the text that i wrote stuff, it disappears for no reason. I also I have another text box in that page and it works perfectly fine. How can I fix that? The bio text box is the one I’m having issues.

    $getpro = mysql_fetch_assoc(mysql_query("SELECT * FROM `profile` WHERE username = '".$user_data['username']."'  "));$pro = $getpro;
$bios = $pro["bios"];
$realtionship = $pro["realtionship"];
$impmessage = $pro["impmessage"];
if ($_POST['bio']){
$bio = $_POST['bio'] ;
$query;
}
if ($_POST['impmessage']){
$impmessage = $_POST['impmessage'] ;
$query;
}
$query = mysql_query("UPDATE `profile` SET  bios ='$bio',  impmessage = '$impmessage' WHERE username = '".$user_data['username']."'");<form name="bio"action="" method="post">
<p>Important Message</p> <textarea   cols="50" style="resize:none" name="bio"  rows="7" ><? echo $bios; ?></textarea><br />
<input type="submit" value="change">
</form><hr /><form name="impmessage"action="" method="post">
<p>Important Message</p> <textarea   cols="50" style="resize:none" name="impmessage"  rows="7" ><? echo $impmessage; ?></textarea><br />
<input type="submit" value="change">
</form>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T06:54:59+00:00Added an answer on June 11, 2026 at 6:54 am

    I have rearranged & removed some of the code and tried tidying it a bit:

    <?php
        if ( $_SERVER['REQUEST_METHOD'] == 'POST' ) // if form is submitted using POST method
        {
            if ( isset( $_POST['bio'] ) ){
                $bio = mysql_real_escape_string( $_POST['bio'] ); // escape special characters is user input
                $query = mysql_query("UPDATE `profile` SET  bios ='$bio' WHERE username = '".$user_data['username']."'"); //update bios
            }
    
            if (isset( $_POST['impmessage'] ) ){
                $impmessage = mysql_real_escape_string( $_POST['impmessage'] ); // escape special characters is user input
                $query = mysql_query("UPDATE `profile` SET impmessage = '$impmessage' WHERE username = '".$user_data['username']."'"); //update impmessage
            }
        }
    
        $pro = mysql_fetch_assoc(mysql_query("SELECT * FROM `profile` WHERE username = '".$user_data['username']."'  "));
    ?>
    
    <form name="bio" action="" method="post">
        <p>Bios</p>
        <textarea cols="50" style="resize:none" name="bio" id="bio" rows="7" ><?php echo $pro["bios"]; ?></textarea>
        <br />
        <input type="submit" value="change">
    </form>
    <hr />
    <form name="impmessage" action="" method="post">
        <p>Important Message</p>
        <textarea cols="50" style="resize:none" name="impmessage" id="impmessage" rows="7" ><?php echo $pro["impmessage"]; ?></textarea>
        <br />
        <input type="submit" value="change">
    </form>
    

    Some notes for you:

    • First of all avoid mysql_* functions. Instead use mysqli or PDO
    • I would always prefer writing the code for processing of user inputs in the very beginning of the page, ie. before outputting anything. Because, if the user inputs makes any changes on the output, it would easily display the updates since we are doing the processing before outputting anything. So, when we query the db, it would fetch the updated data. Also, if we wanted to redirect to another page or have to send some other headers to the browser, we could do it, as the headers should always be sent before outputting anything.
    • Another thing is, always escape user inputs. Otherwise, prone to sql injections. Best thing would be to use prepared statements which is available in mysqli & PDO.
    • When you name id of elements in your HTML, make sure that it is unique. Because no same ids could occur twice. But class names can occur for any number of times.
    • Also make sure that your PHP code doesn’t get mixed up with the HTML. Properly enclose the PHP code with the <?php & ?> tags. I would always prefer avoiding shorthands.
    • Since you are using two forms, both the input won’t reach the server side. Only a single one. If you wanted to both inputs to be reached at the same time, then use a single form.
    • I have also avoided unwanted assignment operations from the fetched data, to other variables.
    • Also, you should always properly indent your code for better readability.

    I hope this would help. Wish you good luck. 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a text box in my page which the user will type something
I've a search box works with jquery and php, when you type something in
I have something like the StackOverflow's "Ask Question" page, where a text-box is used
Suppose I have something like this: if ($command === 'txt') { header('Content-type: text/plain;charset=utf-8'); echo
I have an input on an HTML page where a person will type something
On this page http://equals.lsri.nottingham.ac.uk/puzzle/create , if you type something into an input and then
In my jsp page i have one text box and two combo box. An
Okay, so my app will find the word you type into the text box
I'm creating a search field that when you type something in to a clear
i have a text-box in my tree that is generated run-time for giving the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.