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 6071609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:04:01+00:00 2026-05-23T10:04:01+00:00

I have a simple form with a submit button (below). I am trying to

  • 0

I have a simple form with a submit button (below). I am trying to let the user type in the text box then when he/she clicks submit the page will refresh and echo out what they typed in a div. The data the user types is stored in a database before being echoed. The problem is that when I click submit, the input doesnt show immediatly. I have to click refresh for it to show and when I do my browser gives me a popup (safari) asking to resend the data. This will result in duplicate data inserted in the DB. I have a feeling I need to use javascript and I could also make it more elegant with a fadeIn, but I dont know how to do that. I guess I’m asking if there’s a way to use javascript to take a user’s text and insert it into a mysql DB and also display it after submit is clicked all on 1 or 0 (prefereably) refreshes. thanks

Here’s my code:

<form method='POST'  action='index.php'>
<input type='text' name='text' id='text'>
<input type ='submit' value='submit' name='submit'>
</form>

<?php
$input=$_POST['text'];
$put=mysql_query("INSERT INTO table VALUES ('$input')");

echo "<div id='area'>";
//i connect to the DB and echo out the data here

echo "</div>";

?>
  • 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-05-23T10:04:01+00:00Added an answer on May 23, 2026 at 10:04 am

    I would put the php statements before you’re actual html code and would modify you’re code like this

    <?php
    if (isset($_POST['text']))
    {
      $input = mysql_real_escape_string($_POST['text']);
    
      $put=mysql_query("INSERT INTO table VALUES ('$input')"); //At this point the info has been put inside the DB
    
      echo "<div id='area'>";
      //i connect to the DB and echo out the data here
      echo mysql_query("SELECT * FROM table");
      echo "</div>";
    }
    ?>
    
    <form method='POST'  action='index.php'>
    <input type='text' name='text' id='text'>
    <input type ='submit' value='submit' name='submit'>
    </form>
    

    The reason why you don’t see it is that the HTML is loaded before you php I think. So I would do a php page where all the sql treatement would be done and once that is done recal you index.php and in there query you’re information from the database.

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

Sidebar

Related Questions

I have an HTML page with a simple form. When the user clicks submit,
I have simple registration form. Once all information entered, user click submit button and
Let's assume I have a very simple form, with a submit button and a
I have a simple form like this: <form name=serachForm method=post action=/home/search> <input type=text name=searchText
I have simple form with a textarea and a button, and I submit the
I have a simple form. Input fields, checkboxes, radio buttons and finally SUBMIT button.
I have a simple form. Its got one field and a submit button. I
I have a simple form with just one textbox and one submit button. The
I am trying to create simple user registration form. I have an index.html file
I have a simple form (textbox, submit button) which is wrapped in an update

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.