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

  • Home
  • SEARCH
  • 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 3984818
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:48:57+00:00 2026-05-20T05:48:57+00:00

I have a PHP update page in which I am showing a text field

  • 0

I have a PHP update page in which I am showing a text field containing a value from the database. It is like this, and it is working,

<input type="text" name="title" id="title" class="text_box" value="<?php echo $row['title']?>"/>

Now I need to put this updated value back in the database! I have used the code like this, but it’s not updating:

$title=$_POST['title'];
$v_id = $_GET['v_id'];
$sql = mysql_query("update vehicles set title = '$title' where v_id = '$v_id'");

In detail… an input field is there. It’s showing a value contained in $title (retrieved from the database) and that value is to be edited and updated.

From my side my code is working perfectly without showing any error, but the value that I give $title is giving the same one without any change.

Is there any other way to show a value in an input field without putting in a “value” tag?
Two things wants to happen in a single input field!

  • 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-20T05:48:58+00:00Added an answer on May 20, 2026 at 5:48 am

    You’ll need to post your form HTML as well.

    Unless your form looks like the following, that code won’t work

    <form method='post' action='page.php?v_id=1'>
       <input type="text" name="title" id="title" class="text_box" value="<?php echo $row['title']?>"/>
    </form>
    

    This is because you’re using $_GET to get the id field and $_POST to get the value field

    EDIT
    Your edit has muddied the water a bit more. I’m going to assume all you want to do is show a title and let the user update the title

    <?php
       if ($_POST) {
            $title = mysql_escape_string($_POST['title']);
            $id    = intval($_GET['v_id']);
            $sql   = "update vehicles set title = '$title' where v_id = '$id'";
            mysql_query($sql) or trigger_error(mysql_error()." ".$sql);
       } 
       if (isset($_GET['v_id'])) {
           $id      = intval($_GET['v_id']);
           $sql     = 'SELECT title FROM vehicles WHERE v_id = ' . $id;
           $rs      = mysql_query($sql) or trigger_error(mysql_error()." ".$sql);
           $row     = mysql_fetch_assoc($rs);
           $title   = htmlspecialchars($row['title']);
       }
    ?>
    
    <form method='post' action='?v_id=<?php echo $id?>'>
       <input type="text" name="title" id="title" class="text_box" value="<?php echo $title ?>"/>
       <input type='submit' value='update'>
    </form>
    

    This should work for you. I haven’t error tested obviously, but the idea is sound. You should also add any other input screening you feel necessary.

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

Sidebar

Related Questions

UPDATE 2: I have now removed the following from the .php file: <?php error_reporting(
I have created a PHP-script to update a web server that is live inside
Can you create websites with Chinese characters in PHP? UPDATE: Perhaps I should have
We have a PHP project that we would like to version control. Right now
Does php have the ability to do this: Let's say you have an observatory.
I have a script called 'sess-start.php' which lies in an /include directory within my
I am running a php page form the command line to update a mysql
I have a table in my MySQL DB which basically contains cron-like tasks. Basically
I have PHP configured so that magic quotes are on and register globals are
We have PHP 5.2.6 deployed to c:\php and in that folder there is 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.