Edit page using php/mysql
<p>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.</p>

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

<p>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. </p>

<pre><code>**PHP scipt**

&lt;?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"];
   }



   }

   ?&gt;


   **form**

   &lt;h1&gt;Edit Advertisement&lt;/h1&gt;

    &lt;?php echo "$success";?&gt;

&lt;form action="edit.php" method="POST" enctype="multipart/form-data"&gt;

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

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

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

     &lt;input name="submit" type="submit" value="Edit ad"/&gt;

&lt;/form&gt;
</code></pre>
