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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:14:31+00:00 2026-06-02T04:14:31+00:00

I seem to be having problems with editing a users/members information. I have provided

  • 0

I seem to be having problems with editing a users/members information. I have provided the scipt with the form below. Any solution to this is very much appreciated. I have taken out the validation checks to shorten the script.

The page renders with no errors. and the success message is being shown. However, information is not being changed/edited in the database.

Also the values from the database (corresponding to the 2nd db query being run) are being displayed in the fields of the form. However when i POST the changes the changes are not being made in the database.

**PHP scipt**

<?php
 session_start();
if (isset($_SESSION['id'])) {
$id = $_SESSION['id'];
$username = $_SESSION['username'];
}

else {
echo "You have not signed in";
}

 if (isset ($_POST['submit'])){
 $title = $_POST['title'];
 $content = $_POST['content'];
 $make= $_POST['make'];
 $model = $_POST['model'];
 $price = $_POST['price'];
 $location = $_POST['location'];

 include_once "scripts/connect_to_mysql.php";     

 $title = mysql_real_escape_string($title);
 $content = mysql_real_escape_string($content);
 $make = mysql_real_escape_string($make);
 $model = mysql_real_escape_string($model);
 $price = mysql_real_escape_string($price);
 $location = mysql_real_escape_string($location);

 $title = eregi_replace("`", "", $title);
 $content = eregi_replace("`", "", $content);
 $make = eregi_replace("`", "", $make);
 $model = eregi_replace("`", "", $model);
 $price = eregi_replace("`", "", $price);
 $location = eregi_replace("`", "", $location);

 $sql = mysql_query ("UPDATE `advertisements` SET `title`='$title',        
 `content`='$content', `make`='$make', `model`= '$model', `price`='$price', 
 `location`='$location', `id`='$id' WHERE `advertisements` . `ads_id`='$ads_id'")
 or die (mysql_error());

 $success = "You have successfuly edited your ad";
 }

 else {

  if (isset($_GET['ads_id'])) {
  $ads_id = $_GET['ads_id'];
  }

  else {
  echo "URL not found";
   }

   include_once "scripts/connect_to_mysql.php";
   $query = mysql_query("SELECT * FROM advertisements WHERE ads_id='$ads_id'");

   while($row = mysql_fetch_assoc($query))
   {
   $title = $row["title"];
$content = $row["content"];
$make = $row["make"];   
$model = $row["model"];
$price = $row["price"];
$location = $row["location"];
$ads_id = $row ["ads_id"];
   }



   }

   ?>


   **form**

   <h1>Edit Advertisement</h1>

    <?php echo "$success";?>

<form action="edit.php" method="POST" enctype="multipart/form-data">

 Title: <input name="title" type="text" value="<?php print "$title"; ?>"/><br/>
 Content: <input name="content" type="text" value="<?php print "$content";
     ?>"/><br/>
 Make: <select name="make"> 
 <option value="<?php echo "$make"; ?>"><?php echo "$make"; ?></option> 
        <option value="1">1</option>
        <option value="2">2</option>
        <option value="3">3</option>
        <option value="4">4</option>
 </select> <br/>

 Model: <select name="model"> 
  <option value="<?php echo "$model"; ?>"><?php echo "$model"; ?></option>
        <option value="1">1</option>
        <option value="2">2</option>
        <option value="3">3</option>
        <option value="4">4</option>
</select> <br/>
Price: <input name="price" type="text" value="<?php print "$price"; ?>"> <br/>

Location: <select name="location"> <br/>
        <option value="<?php echo "$location"; ?>"><?php echo "$location";
                    ?></option>
        <option value="Leicester">Leicester</option>
        <option value="Loughborough">Loughborough</option>
        <option value="Nottingham">Nottingham</option>
        <option value="Derby">Derby</option>
</select> <br/> <br/>

     <input name="submit" type="submit" value="Edit ad"/>

</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-02T04:14:34+00:00Added an answer on June 2, 2026 at 4:14 am

    try moving the

        if (isset($_GET['ads_id'])) {
      $ads_id = $_GET['ads_id'];
      }
    
      else {
      echo "URL not found";
       }
    

    to the top right after the

     if (isset ($_POST['submit'])){
    

    this may cause problems

    and your form action as i guess must have something like

    <form action ="edit.php?ads_id=the id for the page" >
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I seem to be having some problems with something simple here. I have some
I have the following code, I seem to be having problems with booleans in
I seem to be having problems with my java gui code, and I have
I seem to be having problems with this and I cannot seem to figure
I seem to be having a problem with this jquery code. I want to
I'm having a problem in ruby and I can't seem to find the solution
I'm having a problem and can't seem to find the solution.. int linearSearch(nodeptr list,char
I seem to be having problems with my code and wondered if you guys
I seem to be having some problems creating a jquery plugin. I am testing
I just moved a project to another server and seem to be having problems

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.