Transfer of operations based on if else conditions
<p>Thanks in advance. I am writing this in great detail. So dont panic looking at the length of this message.</p>

<p>I have a page called retrievefieldex11.29.2.56.php. Fields that need to be considered for this problem here is the ID field (name = usersubmit) the Key(name = key) field. Now when the user enters his id( name = usersubmit) and if he does not enter the key value in the key field which I am checking by using this condition <code>if (($_SERVER['REQUEST_METHOD'] == 'POST') &amp;&amp; ($_POST['key'] == ""))</code>
It should be directed to the same page that is retrievefieldex11.29.2.56.php. And for this I am using the </p>

<pre><code>&lt;form name="retrieve.php" action="retrievefieldex11.29.2.56.php" method="POST"&gt;
</code></pre>

<p>Statement so that it postbacks to the same page and performs operations to retrieve records from the database and print it on the same page.</p>

<pre><code>Database code to retrieve rows
Print rows on the same page.
</code></pre>

<p>Now if the user enters into both id fields and the key field, I am using this statement for checking the condition.</p>

<pre><code>else if (($_SERVER['REQUEST_METHOD'] == 'POST') &amp;&amp; ($_POST['key']))
</code></pre>

<p>then the page should be redirected to another page where in the following operation is carried out. </p>

<pre><code>header( 'Location: Decryption.php' ) ;
</code></pre>

<p>In the Decryption.php page part of the code is as follows</p>

<p><code>$userId = $_POST['usersubmit'];</code> </p>

<p>[COLOR="red"]This value is not being fetched from the previous page.[/COLOR]. I need this page to be fetched from the previous page</p>

<p>Rest of the Database code to retrieve values from the table.</p>

<p>My problem is that when I am testing for the part where the user enters his id but not the key field the database operations are being performed. However when the user enters his id and the key, [COLOR="Red"]I am being redirected to the Decryption page but the ID value ( name = usersubmit [/COLOR]) is not being transferred from the previous page to the Decryption page. Please suggest me how do I deal this?</p>

<p>I hope that made sense. My whole problem would make further sense if you look at this whole program together. Please help. Thanks in advance. </p>

<p><strong>Total code</strong></p>

<pre><code>&lt;html&gt;
&lt;head&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;form name="retrieve.php" action="retrievefieldex11.29.2.56.php" method="POST"&gt;
Enter your ID&lt;input name="usersubmit" type="text"&gt; &lt;br&gt;

&lt;table&gt;&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Key size in bits: &lt;/b&gt;&lt;/td&gt;

&lt;td&gt;&lt;select name="keySize"&gt;
&lt;option value="128" selected="selected"&gt;128&lt;/option&gt;
&lt;option value="192"&gt;192&lt;/option&gt;
&lt;option value="256"&gt;256&lt;/option&gt;
&lt;/select&gt;&lt;/td&gt;
&lt;/tr&gt;

&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Key in hex: &lt;/b&gt;&lt;/td&gt;
&lt;td&gt;&lt;input type="text" size="66" name="key"&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Ciphertext in hex: &lt;/b&gt;&lt;/td&gt;
&lt;td&gt;&lt;input type="text" size="66" name="ciphertext"&gt;&lt;/td&gt;

&lt;/tr&gt;


&lt;/table&gt;
&lt;?php
mysql_connect("localhost","root","");
mysql_select_db("encryption") or die(mysql_error());
$userId = $_POST['usersubmit'];
if (($_SERVER['REQUEST_METHOD'] == 'POST') &amp;&amp; ($_POST['key'] == "")) 
{

 $query = mysql_query("select * from employee_details where id = '$userId'");
  if($row=mysql_fetch_assoc($query))
    {
     echo '&lt;tr&gt;';
     foreach($row as $value)
     echo '&lt;td&gt;'.$value.'&lt;/td&gt;';
     echo '&lt;/tr&gt;';
    }
  else
  echo "No rows returned";
  }
 else if (($_SERVER['REQUEST_METHOD'] == 'POST') &amp;&amp; ($_POST['key']))
 {


   header( 'Location: Decryption.php' ) ;

In decryption page

&lt;?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
mysql_connect("localhost","root","");
mysql_select_db("encryption") or die(mysql_error());
$userId = $_POST['usersubmit'];
$columname = "ciphertext";
$tablename = "employee_details";

 function getField($field, $tbl_name, $condition)
 {

 $result = mysql_query("SELECT $field FROM $tbl_name WHERE id = ".$condition);
 return @mysql_result($result, 0);
 }

 $myValue = getField($columname,$tablename,$userId);
 echo "$myValue";
 echo "&lt;br&gt;";

?&gt;


 }



?&gt;
&lt;br&gt;
&lt;input name="submit" type="submit" value="Submit"&gt;&lt;table&gt;
&lt;/table&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
