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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:11:41+00:00 2026-05-27T04:11:41+00:00

I am trying to create a page where users can edit information. I can

  • 0

I am trying to create a page where users can edit information.

I can can populate the form with values from an array and update them, however, when it is saved and visited again with different array info it displays the previous form data. I have looked at clearing the cache and setting the array to NULL after the page has been submitted but neither of these have worked!

Here is what i have:

$id = ($_GET['id']);
function get_edit_event_details() {
global $connection;
    $query = 'SELECT * 
        FROM events
        WHERE id = "$id"';
$event_details = mysql_query($query, $connection);
confirm_query($event_details);
return $event_details;
echo $query;
}   
$event_details = get_event_details();
$details = mysql_fetch_array($event_details);

and to populate the form values (I have also tried autocomplete=”off” which has not worked either)

<input type="text" name="event_date" id="event_date" size="27" value="<?php echo $details["date"];?>" autocomplete="off" />

I am relatively new to PHP and have been able to solve every problem I have come across apart from this one!

  • 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-27T04:11:42+00:00Added an answer on May 27, 2026 at 4:11 am

    I know that maybe this is not a real answer, but I’d like to point out some things:

    1. Your ID should be casted to INT, as now you’re vulnerable to injections.
      So, it should be $id = intval($_GET['id']);
    2. How is your ID passing to the function? it’s outside, and not passed as a parameter, nor made global. I believe this could be the issue, as your query will always be without and ID to use as a condition. Try with:

      get_edit_event_details($id){}

    3. Personal taste maybe, but using 2 functions and and external call to the return value, just to fetch results it’s a bit smelly. I’d rewrite the whole thing as:

      function get_edit_event_details($_GET['id']) 
      {
        global $connection;
        $id = intval($_GET['id']);
        $query = "SELECT * FROM events WHERE id = '$id'";
        $result = mysql_query($query, $connection) or trigger_error('Query error: '.mysql_error());
        if(mysql_num_rows($result) > 0)
        {
         return mysql_fetch_array($result);
        }
        else
        {
          return FALSE;
        }
      }
      
      if($details = get_edit_event_details($_GET['id']) :?>
      <input type="text" name="event_date" id="event_date" size="27" value="<?php echo $details["date"];?>" autocomplete="off" /> 
      <?php endif;?>
      

    Keep in mind that this is still not perfect code, I know, kinda smell mine too :). You might want to check if $_GET[‘id’] is set also, inside or outside the function.

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

Sidebar

Related Questions

I'm trying to create an ASP.NET/C# page that allows the user to edit a
I am trying create a 'live' view where our clients can edit the colors
I'm trying to create an html list where the user can edit the items
I'm trying to create a contact form. However at the top of the form
I'm trying to create a page where a user selects the type of subscription
I'm trying to create a User Registration page in ASP.NET and wondering what is
Im trying to create a user control menu where links to a page's usercontrols
I am trying to create a page to display a list of links for
I'm trying to create a page by using view 2. This page list all
I'm trying to create a page that contains a grid and searching. The issue

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.