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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:17:45+00:00 2026-05-16T00:17:45+00:00

I was looking online for a script that demonstrates how I would go about

  • 0

I was looking online for a script that demonstrates how I would go about making it possible for users on my site able to edit fields and such, but I could not find anything about it. So I was wondering if someone could explain to me how it works or just demonstrate with a script? To make it clear, I want users to be able to edit stuff that they’ve submitted by simply clicking ‘edit’ and pressing a button to update whatever it was they changed.

Edit: I forgot to mention that what’s been changed should update a table in a MySQL database.

  • 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-16T00:17:46+00:00Added an answer on May 16, 2026 at 12:17 am

    You need 2 PHP files to do this. You could use a single file but the concept is easier to explain this way.

    1. A form that will load the database content into the fields where users can then edit the values and then submit them for change by pressing a button once done.
    2. A file that receives the changed information and updates the database.

    Here is a code example for the first file:

    <?php 
    // connect to SQL
    $dbcnx = @mysql_connect("localhost", "db_name", "password");
    if (!$dbcnx) {
      echo( "<P>Unable to connect to the database server at this time.</P>" );
      exit();
    }
    // connect to database
    $dbcon = @mysql_select_db("db_table", $dbcnx);
    if (!$dbcon) {
      echo( "<P>Unable to locate DB table at this time.</P>" );
      exit();
    }
    
    #data preparation for the query
    $id = intval($_GET["id"]);
    
    # selects title and description fields from database
    $sql = "SELECT * FROM table_name WHERE id=$id";
    $result = mysql_query($sql) or die(mysql_error());        
    # retrieved by using $row['col_name']
    $row = mysql_fetch_array($result);
    
    ?>
    
    <h3>Edit</h3>
    <form action="save_edit.php" enctype="multipart/form-data" method="post" name="myForm" />
      <table>
        <tr>
          <td><b>Title</b></td>
          <td><input type="text" size="70" maxlength="100" name="title" value="<?php echo $row['title'] ?>"></td>
        </tr>
        <tr>
          <td><b>Description</b></td>
          <td><textarea cols="80" rows="18" name="description"><?php echo $row['description']; ?></textarea></td>
        </tr>
      </table>
      <input type="hidden" name="id" value="<?php echo $id; ?>" />
      <input name="enter" type="submit" value="Edit">
    </form>
    
    <?php 
    mysql_close($dbcnx);
    ?>
    

    And here is an example of code for the second file where it receives the changes made by the user and updates the database.

    <?php
    // connect to SQL
    $dbcnx = @mysql_connect("localhost", "db_name", "password");
    if (!$dbcnx) {
      echo( "<P>Unable to connect to the database server at this time.</P>" );
      exit();
    }
    // connect to database
    $dbcon = @mysql_select_db("db_table", $dbcnx);
    if (!$dbcon) {
      echo( "<P>Unable to locate DB table at this time.</P>" );
      exit();
    }
    
    #data preparation for the query
    $id = intval($_POST["id"]);
    foreach ($_POST as $key => $value) $_POST[$key] = mysql_real_escape_string($value);
    
    $sql = "UPDATE table_name SET 
            title='$_POST[title]', 
            description='$_POST[description]', 
            WHERE id=$id";
    
    if (!mysql_query($sql,$dbcnx)) {
      die('Error: ' . mysql_error());
    }
    
    mysql_close($dbcnx);
    header ("location: http://www.domain.com/url_to_go_to_after_update");
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

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.