Passing the ID from one page to another
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/5800247/how-to-send-selected-values-from-one-page-to-another-page-using-php">How to send selected values from one page to another page using php</a>  </p>
</blockquote>



<p>I am trying to pass the ID from one page to another in href command. actually when the user clicks on edit it will pass the id to other page and there the edit function happens. Am passing the id something like this : </p>

<pre><code>echo "&lt;td&gt; &lt;a href='products.php?IsEdit=1&amp;ProductID=" .$row['ProductID']. "'&gt; Edit &lt;/a&gt;&lt;/td&gt;";
</code></pre>

<p>and i am storing that id in page2 like this</p>

<pre><code>&lt;?php

global $ID;
$ID = $_GET['ProductID'];
</code></pre>

<p>but the id which is passed through url is not getting saved. i tried to use SESSION and global but it doens get stored. Please help me how to get the id.</p>

<p>in my page2, i do like this </p>

<pre><code>&lt;?php
 if(isset($_GET['IsEdit']))  
 { ?&gt; 
 &lt;input type="submit" name = "update" value="UPDATE" onClick="return valid();"  /&gt; 
 &lt;?php }else { ?&gt;          
 &lt;input type="submit" name = "submit" value="ADD PRODUCT" onClick="return valid();"  /&gt; 
 &lt;?php } ?&gt;

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


 $ProductName = mysql_real_escape_string(htmlspecialchars($_POST['ProductName']));
    $ProductCode = $_POST['ProductCode'];
    $Manufacturer = $_POST['Manufacturer'];
    $Specification = $_POST['Specification'];
    $Description = $_POST['Description'];
    $CostPrice = $_POST['CostPrice'];
    $DisplayPrice = $_POST['DisplayPrice'];

    echo "Pr ID";
    echo $ID;
    $ProductImage = $_POST['ProductImage'];
 //{
 echo "2";
 if ($ProductName == '' || $ProductCode == ''|| $Manufacturer == '' || $Description == '' || $Specification == '' || $CostPrice == '' || $DisplayPrice == '') 
 {
 // generate error message
 $error = 'ERROR: Please fill in all required fields!';
 echo "3";
 //error, display form
 //renderForm('', $ProductID, $ProductName, $ProductCode, $Manufacturer, $Description, $Specification,'', $CostPrice, $DisplayPrice, $error);
 }
 else
 {
 // save the data to the database
 $sql = "UPDATE Products SET ProductName='$ProductName', ProductCode='$ProductCode', Manufacturer='$Manufacturer', Description='$Description', Specification='$Specification', CostPrice='$CostPrice', DisplayPrice='$DisplayPrice' WHERE ProductID=" . $_SESSION['ID'];
 echo $sql;
 mysql_query($sql) or die(mysql_error()); 

 // once saved, redirect back to the view page
 //header("Location: view.php"); 
 }

 //}
 }
</code></pre>

<p>and in <code>echo $sql</code> id is not displaying.</p>
