i am having some problems posting some values into a form when i click edit. i have checked to make sure that the variables contain the values that i want however they are not posting back to the form.
here is my code below.

if ($_GET['mode'] == 'edit')
{	
	$c=$_GET['id'];
	echo"$c";
	// editing an existing entity
	
	// check for value of id
	/*if (!$_GET['coursecode'])
	{
		echo "error: no coursecode specified, <a href=\"{$_SERVER['PHP_SELF']}\">click here to continue</a>";	
		exit;
	}*/
	
	
	if (!$_POST['submit'])
	{
	
			
					
					
					
					$con = mysql_connect("$hostname","$username","$password");
					if (!$con)
					  {
					  die('Could not connect: ' . mysql_error());
					  }
					  mysql_select_db("$database", $con);
					  
					// $sql= "SELECT  * FROM rules WHERE type='prerequisite' ";
					 //$result=mysql_query($sql);
					 
						
							
				
		// first access to form
		
				// checking if the record is in the database 
				 //$sql= "SELECT  * FROM rules WHERE type='prerequisite' ";
		//$q = "SELECT first_name,last_name,password FROM students WHERE id_no='$c' ";	
		//if ($result=mysql_query($sql))
		
		
			$q = "SELECT first_name,last_name,password FROM students WHERE id_no='$c' ";
	
		
		
		
		if (!$result = mysql_query($q) )
			{
				
				//extract($row);
				//$_POST['id']=$id_no;
				
				
			echo "error: user with id {$_GET['id']} does not exist, <a href=\"{$_SERVER['PHP_SELF']}\">click here to continue							 				</a>";	
			exit;	
			}
			else
			{
			$row = mysql_fetch_array($result, MYSQL_BOTH);
			 
				if (mysql_num_rows($result)!=0) {
					echo "Found Information!";
				}else{
					die("No Information Found!");
				}
			 
					//echo "<p>", $row['first_name'], "</p>";
				//echo "<p>", $row['last_name'], "</p>";
				//echo "<p>", $row['password'], "</p>";
 
				
				$_POST['id']=$c;
				$_POST['firstname']=$row['first_name'];
				$_POST['last_name']=$row['last_name'];
				$_POST['password']=$row['password'];
				$_POST['repassword']=$row['password'];
				
				//echo "<p>", $_POST['password'], "</p>";
			
			}
			print_form();
			
			
	}

can someone offer some assistance here please

i am having some problems posting some values into a form when i click edit. i have checked to make sure that the variables contain the values that i want however they are not posting back to the form.
here is my code below.

if ($_GET['mode'] == 'edit')
{	
	$c=$_GET['id'];
	echo"$c";
	// editing an existing entity
	
	// check for value of id
	/*if (!$_GET['coursecode'])
	{
		echo "error: no coursecode specified, <a href=\"{$_SERVER['PHP_SELF']}\">click here to continue</a>";	
		exit;
	}*/
	
	
	if (!$_POST['submit'])
	{
	
			
					
					
					
					$con = mysql_connect("$hostname","$username","$password");
					if (!$con)
					  {
					  die('Could not connect: ' . mysql_error());
					  }
					  mysql_select_db("$database", $con);
					  
					// $sql= "SELECT  * FROM rules WHERE type='prerequisite' ";
					 //$result=mysql_query($sql);
					 
						
							
				
		// first access to form
		
				// checking if the record is in the database 
				 //$sql= "SELECT  * FROM rules WHERE type='prerequisite' ";
		//$q = "SELECT first_name,last_name,password FROM students WHERE id_no='$c' ";	
		//if ($result=mysql_query($sql))
		
		
			$q = "SELECT first_name,last_name,password FROM students WHERE id_no='$c' ";
	
		
		
		
		if (!$result = mysql_query($q) )
			{
				
				//extract($row);
				//$_POST['id']=$id_no;
				
				
			echo "error: user with id {$_GET['id']} does not exist, <a href=\"{$_SERVER['PHP_SELF']}\">click here to continue							 				</a>";	
			exit;	
			}
			else
			{
			$row = mysql_fetch_array($result, MYSQL_BOTH);
			 
				if (mysql_num_rows($result)!=0) {
					echo "Found Information!";
				}else{
					die("No Information Found!");
				}
			 
					//echo "<p>", $row['first_name'], "</p>";
				//echo "<p>", $row['last_name'], "</p>";
				//echo "<p>", $row['password'], "</p>";
 
				
				$_POST['id']=$c;
				$_POST['firstname']=$row['first_name'];
				$_POST['last_name']=$row['last_name'];
				$_POST['password']=$row['password'];
				$_POST['repassword']=$row['password'];
				
				//echo "<p>", $_POST['password'], "</p>";
			
			}
			print_form();
			
			
	}

can someone offer some assistance here please

Why are you using both get and post while retrieving the data.

Use $_GET if your form method contains get
OR
Use $_POST if your form method contains post

i am using the get method to get the id from the url and i am using the post method in the form. i am not using the get method in any forms. it is just being used to get the id from the url and the mode of the form (ie new or edit )

that is unless you are using the following form action:

<form action="/?mode=edit&id=whatever" method="post">
<!-- enter form fields here -->
</form>

which is completely possible. I do it all the time and it works fine.

i am using the get method to get the id from the url and i am using the post method in the form. i am not using the get method in any forms. it is just being used to get the id from the url and the mode of the form (ie new or edit )

If you want to read anything from the query string, you need to use $_REQUEST

Otherwise follow the procedure as said by OS_dev

if i set the mode to edit then in the instance where the form is accessed for the first time the mode should be new
here is the code that i have thus far for what i am doing

<?php

include('header.php');


// switch depending on mode, mode defaults to new
if ($_GET['mode'] == 'edit')
{	
	$c=$_GET['id'];
	echo"$c";
	// editing an existing entity
	
	// check for value of id
	/*if (!$_GET['coursecode'])
	{
		echo "error: no coursecode specified, <a href=\"{$_SERVER['PHP_SELF']}\">click here to continue</a>";	
		exit;
	}*/
	
	
	if (!$_POST['submit'])
	{
	
			
					$hostname = "localhost";
					$username = "root";
					$password = "hayden";
					$database = "ecng3020";
					
					
					$con = mysql_connect("$hostname","$username","$password");
					if (!$con)
					  {
					  die('Could not connect: ' . mysql_error());
					  }
					  mysql_select_db("$database", $con);
					  
					// $sql= "SELECT  * FROM rules WHERE type='prerequisite' ";
					 //$result=mysql_query($sql);
					 
						
							
				
		// first access to form
		
				// checking if the record is in the database 
				 //$sql= "SELECT  * FROM rules WHERE type='prerequisite' ";
		//$q = "SELECT first_name,last_name,password FROM students WHERE id_no='$c' ";	
		//if ($result=mysql_query($sql))
		
		
			$q = "SELECT first_name,last_name,password FROM students WHERE id_no='$c' ";
	
		
		
		
		if (!$result = mysql_query($q) )
			{
				
				//extract($row);
				//$_POST['id']=$id_no;
				
				
			echo "error: user with id {$_GET['id']} does not exist, <a href=\"{$_SERVER['PHP_SELF']}\">click here to continue							 				</a>";	
			exit;	
			}
			else
			{
			$row = mysql_fetch_array($result, MYSQL_BOTH);
			 
				if (mysql_num_rows($result)!=0) {
					echo "Found Information!";
				}else{
					die("No Information Found!");
				}
			 
					//echo "<p>", $row['first_name'], "</p>";
				//echo "<p>", $row['last_name'], "</p>";
				//echo "<p>", $row['password'], "</p>";
 
				
				$_POST['id']=$c;
				$_POST['firstname']=$row['first_name'];
				$_POST['last_name']=$row['last_name'];
				$_POST['password']=$row['password'];
				$_POST['repassword']=$row['password'];
				
				//echo "<p>", $_POST['password'], "</p>";
			
			}
			print_form();
			
			
	}		
		// retrieve recored
		//$query = "SELECT * FROM courses WHERE course_coode =$_GET['coursecode']";
		
		//$result = ...;
		
		// if record does not exist
		/* if (... record not found ...)
		{
			echo "error: user with id {$_GET['id']} does not exist, <a href=\"{$_SERVER['PHP_SELF']}\">click here to continue</a>";	
			exit;
		}
		*/
		
		// put existing record into $_POST
		/* $_POST['name'] = $row[0];
		   $_POST['id'] = $row[1];
		*/
		//$_POST['name'] = "user";
		//$_POST['id'] = "1234";
	
	if ($_POST['submit'] == 'Save')
	{
		// user clicked save

		// validate submitted data
		$messages = validate_input();
		if (count($messages) > 0)
		{
			// invalid data, print form for resubmission
			print_form($messages);
		}
		else
		{
			// data was good, update entry
			
			/* code to save entry */
				$hostname = "localhost";
				$username = "root";
				$password = "hayden";
				$database = "ecng3020";
				
				$id=$_POST['id'];
				$firstname=$_POST['firstname'];
				$lastname=$_POST['lastname'];
				$password=$_POST['password'];
				$repassword=$_POST['repassword'];
				$entry=$_POST['year'];

		

				$con = mysql_connect("$hostname","$username","$password");
				if (!$con)
				  {
				  die('Could not connect: ' . mysql_error());
				  }
				
				mysql_select_db("$database", $con);
				
				$sql="UPDATE students SET first_name='$firstname',last_name='$lastname',password='$password',entry_year='$entry'																												
				 WHERE id_no='$id' ";	
				
				if (!mysql_query($sql,$con))
				  {
				  die('Error: ' . mysql_error());
				  }
				//quire_once('courses.php');
				//echo "1 record added";
				echo "user {$_POST['id']} updated, <a href=\"{$_SERVER['PHP_SELF']}\">click here to continue</a>";
				mysql_close($con);
		}
	}
	else
	{
		// user clicked cancel (catch all)
		echo "operation cancelled, <a href=\"{$_SERVER['PHP_SELF']}\">click here to continue</a>";
		
	}
}
else

{
	// creating a new entity
	$_GET['mode'] = 'new';
	
	if (!$_POST['submit'])
	{
		// first access to form
		$_POST[] = array();
		print_form();
	}
	elseif ($_POST['submit'] == 'Save')
	{
		// user clicked save
	
		// validate submitted data
		$messages = validate_input();
		if (count($messages) > 0)
		{

			// invalid data, print form for resubmission
			print_form($messages);
		}
		else
		{
			// data was good, save entry
			
			//* code to save entry *
					$hostname = "localhost";
					$username = "root";
					$password = "hayden";
					$database = "ecng3020";
					
					$id=$_POST['id'];
					$firstname=$_POST['firstname'];
					$lastname=$_POST['lastname'];
					$password=$_POST['password'];
					$repassword=$_POST['repassword'];
					$entry=$_POST['year'];
					
					if($password==$repassword)
					{
					
						$con = mysql_connect("$hostname","$username","$password");
						if (!$con)
						 {
							die('Could not connect: ' . mysql_error());
						}
					
						mysql_select_db("$database", $con);
					
						$sql="INSERT INTO students (id_no,first_name,last_name,password,entry_year)
						VALUES
						('$id','$firstname','$lastname','$password','$entry')";
					
						if (!mysql_query($sql,$con))
						 {
							 die('Error: ' . mysql_error());
						 }
						//require_once('student.php');
						echo "user {$_POST['id']} created, <a href=\"{$_SERVER['PHP_SELF']}\">click here to continue</a>";
						mysql_close($con);
					}
					else
					{
						echo"The Passwords do not match";
						exit();
					}
					
	
		}
	}
	else
	{
		// user clicked cancel (catch all)
		echo "operation cancelled, <a href=\"{$_SERVER['PHP_SELF']}\">click here to continue</a>";
	}
}	








function print_form($messages = array())
{

	print_header('my form');
	
	if ($_GET['id'])
		$id="&id={$_GET['id']}";
		// putting in the value  of coursecode
	
	echo <<<EOB
	
	<form action="{$_SERVER['PHP_SELF']}?mode={$_GET['mode']}$id" method="post">
		
				<p> ID Number:
				<input type="text" name="id" /></p><i>{$messages['id']}</i> <br/>
				<p>
				First Name: 
				<input type="text" name="firstname" /></p> <i>{$messages['firstname']}</i> <br/>
				<p>
				Last Name: 
				<input type="text" name="lastname" /></p><i>{$messages['lastname']}</i> <br/>
				<p>
				Password:       
				  <input type="password" name="password" /></p><i>{$messages['password']}</i> <br/>
				<p>
				Re enter Password: 
				<input type="password" name="repassword" /></p>
				<p>
				
				Select Your Entry Year
				<p> 
				  <select name="year">
					<option value="1999">1999</option>
					<option value="2000">2000</option>
					<option value="2001">2001</option>
					<option value="2002">2002</option>
					<option value="2003">2003</option>
					<option value="2004">2004</option>
					<option value="2005">2005</option>
					<option value="2006">2006</option>
					<option value="2007">2007</option>
					<option value="2008">2008</option>
					<option value="2009">2009</option>
					<option value="2010">2010</option>
					<option value="2011">2011</option>
					<option value="2012">2012</option>
					<option value="2013">2013</option>
					<option value="2014">2014</option>
					<option value="2015">2015</option>
					<option value="2016">2016</option>
					<option value="2017">2017</option>
					<option value="2018">2018</option>
					<option value="2019">2019</option>
					<option value="2020">2020</option>
				  </select>
				  
				  <p>
						<input type="submit" name="submit" value="Save" />
						<input type="submit" name="submit" value="Cancel" />
					</p>
					</form>
	
EOB;
	
	print_footer();


}


/* validate submitted data
   returns an array of error messages, indexed by variable name.
   returns an empty array if all data validated successfully

*/
function validate_input()
{
	$messages = array();
	
	if (!$_POST['id'])
		$messages['id'] = 'please submit an ID Number';
		
	if (!$_POST['firstname'] )
		$messages['firstname'] = 'please submit your First name';
	
	if (!$_POST['lastname'])
		$messages['lastname'] = 'please submit your Last Name';
	
	
	if (!$_POST['password'] )
		$messages['password'] = 'please submit a Password';
		
	if ($_POST['password'] < 0)
		$messages['password'] = 'please submit a valid Password';
		
	
		
	
	// can do database queries to validate against existing data
	
	return $messages;
}

?>


              <table border='1' align="center" class="twoColLiqLtHdr" table>
                  <?php
                $hostname = "localhost";
            $username = "root";
            $password = "hayden";
            $database = "ecng3020";
            
              //session_start();
            $con = mysql_connect("$hostname","$username","$password");
            if (!$con)
              {
              die('Could not connect: ' . mysql_error());
              }
              mysql_select_db("$database", $con);
            
            
            //$level = $_POST['level'];
            //$id=$_SESSION['username'];
            $stu="SELECT id_no,first_name,last_name FROM students";
                    
            if ($result_3=mysql_query($stu))
                
            echo '<h1><p>Student Accounts present in the Database</p></h1>';	
            echo "<tr><td>ID</a></td><td>First Name</td><td>Last Name</td></tr>";
            while ($row = mysql_fetch_row($result_3))
            {
            echo"<tr><td>$row[0]</td><td>$row[1]</td><td>$row[2]</td><td><a href='myform_student.php?mode=edit&id=$row[0]'>edit</a>
			</td></tr>";	
			
			

            }
            
            ?>
                  </table>

i am using the get method to get the id from the url and i am using the post method in the form. i am not using the get method in any forms. it is just being used to get the id from the url and the mode of the form (ie new or edit )

You can pass both values with post method also..

you can use hidden type to send id value..like

<input type='hidden' name='<?php echo $id ?>'>

and cn get to second page like

$id = $_POST['id'];
// and othr variables also

$name = $_POST['name'];

or if u want to use only get method then you can use it like this..

<a href='yourpage.php?id=<?php echo $id ?>'>Get ID</a>

in second page just call this id like

$id = $_GET['id'];

and can get another variable like this...

$name = $_POST['name'];
|
|

and so on..:)

hope this will help you...

reply here if its not workin for u...:)

if i set the mode to edit then in the instance where the form is accessed for the first time the mode should be new
here is the code that i have thus far for what i am doing

<?php

include('header.php');


// switch depending on mode, mode defaults to new
if ($_GET['mode'] == 'edit')
{	
	$c=$_GET['id'];
	echo"$c";
	// editing an existing entity
	
	// check for value of id
	/*if (!$_GET['coursecode'])
	{
		echo "error: no coursecode specified, <a href=\"{$_SERVER['PHP_SELF']}\">click here to continue</a>";	
		exit;
	}*/
	
	
	if (!$_POST['submit'])
	{
	
			
					$hostname = "localhost";
					$username = "root";
					$password = "hayden";
					$database = "ecng3020";
					
					
					$con = mysql_connect("$hostname","$username","$password");
					if (!$con)
					  {
					  die('Could not connect: ' . mysql_error());
					  }
					  mysql_select_db("$database", $con);
					  
					// $sql= "SELECT  * FROM rules WHERE type='prerequisite' ";
					 //$result=mysql_query($sql);
					 
						
							
				
		// first access to form
		
				// checking if the record is in the database 
				 //$sql= "SELECT  * FROM rules WHERE type='prerequisite' ";
		//$q = "SELECT first_name,last_name,password FROM students WHERE id_no='$c' ";	
		//if ($result=mysql_query($sql))
		
		
			$q = "SELECT first_name,last_name,password FROM students WHERE id_no='$c' ";
	
		
		
		
		if (!$result = mysql_query($q) )
			{
				
				//extract($row);
				//$_POST['id']=$id_no;
				
				
			echo "error: user with id {$_GET['id']} does not exist, <a href=\"{$_SERVER['PHP_SELF']}\">click here to continue							 				</a>";	
			exit;	
			}
			else
			{
			$row = mysql_fetch_array($result, MYSQL_BOTH);
			 
				if (mysql_num_rows($result)!=0) {
					echo "Found Information!";
				}else{
					die("No Information Found!");
				}
			 
					//echo "<p>", $row['first_name'], "</p>";
				//echo "<p>", $row['last_name'], "</p>";
				//echo "<p>", $row['password'], "</p>";
 
				
				$_POST['id']=$c;
				$_POST['firstname']=$row['first_name'];
				$_POST['last_name']=$row['last_name'];
				$_POST['password']=$row['password'];
				$_POST['repassword']=$row['password'];
				
				//echo "<p>", $_POST['password'], "</p>";
			
			}
			print_form();
			
			
	}		
		// retrieve recored
		//$query = "SELECT * FROM courses WHERE course_coode =$_GET['coursecode']";
		
		//$result = ...;
		
		// if record does not exist
		/* if (... record not found ...)
		{
			echo "error: user with id {$_GET['id']} does not exist, <a href=\"{$_SERVER['PHP_SELF']}\">click here to continue</a>";	
			exit;
		}
		*/
		
		// put existing record into $_POST
		/* $_POST['name'] = $row[0];
		   $_POST['id'] = $row[1];
		*/
		//$_POST['name'] = "user";
		//$_POST['id'] = "1234";
	
	if ($_POST['submit'] == 'Save')
	{
		// user clicked save

		// validate submitted data
		$messages = validate_input();
		if (count($messages) > 0)
		{
			// invalid data, print form for resubmission
			print_form($messages);
		}
		else
		{
			// data was good, update entry
			
			/* code to save entry */
				$hostname = "localhost";
				$username = "root";
				$password = "hayden";
				$database = "ecng3020";
				
				$id=$_POST['id'];
				$firstname=$_POST['firstname'];
				$lastname=$_POST['lastname'];
				$password=$_POST['password'];
				$repassword=$_POST['repassword'];
				$entry=$_POST['year'];

		

				$con = mysql_connect("$hostname","$username","$password");
				if (!$con)
				  {
				  die('Could not connect: ' . mysql_error());
				  }
				
				mysql_select_db("$database", $con);
				
				$sql="UPDATE students SET first_name='$firstname',last_name='$lastname',password='$password',entry_year='$entry'																												
				 WHERE id_no='$id' ";	
				
				if (!mysql_query($sql,$con))
				  {
				  die('Error: ' . mysql_error());
				  }
				//quire_once('courses.php');
				//echo "1 record added";
				echo "user {$_POST['id']} updated, <a href=\"{$_SERVER['PHP_SELF']}\">click here to continue</a>";
				mysql_close($con);
		}
	}
	else
	{
		// user clicked cancel (catch all)
		echo "operation cancelled, <a href=\"{$_SERVER['PHP_SELF']}\">click here to continue</a>";
		
	}
}
else

{
	// creating a new entity
	$_GET['mode'] = 'new';
	
	if (!$_POST['submit'])
	{
		// first access to form
		$_POST[] = array();
		print_form();
	}
	elseif ($_POST['submit'] == 'Save')
	{
		// user clicked save
	
		// validate submitted data
		$messages = validate_input();
		if (count($messages) > 0)
		{

			// invalid data, print form for resubmission
			print_form($messages);
		}
		else
		{
			// data was good, save entry
			
			//* code to save entry *
					$hostname = "localhost";
					$username = "root";
					$password = "hayden";
					$database = "ecng3020";
					
					$id=$_POST['id'];
					$firstname=$_POST['firstname'];
					$lastname=$_POST['lastname'];
					$password=$_POST['password'];
					$repassword=$_POST['repassword'];
					$entry=$_POST['year'];
					
					if($password==$repassword)
					{
					
						$con = mysql_connect("$hostname","$username","$password");
						if (!$con)
						 {
							die('Could not connect: ' . mysql_error());
						}
					
						mysql_select_db("$database", $con);
					
						$sql="INSERT INTO students (id_no,first_name,last_name,password,entry_year)
						VALUES
						('$id','$firstname','$lastname','$password','$entry')";
					
						if (!mysql_query($sql,$con))
						 {
							 die('Error: ' . mysql_error());
						 }
						//require_once('student.php');
						echo "user {$_POST['id']} created, <a href=\"{$_SERVER['PHP_SELF']}\">click here to continue</a>";
						mysql_close($con);
					}
					else
					{
						echo"The Passwords do not match";
						exit();
					}
					
	
		}
	}
	else
	{
		// user clicked cancel (catch all)
		echo "operation cancelled, <a href=\"{$_SERVER['PHP_SELF']}\">click here to continue</a>";
	}
}	








function print_form($messages = array())
{

	print_header('my form');
	
	if ($_GET['id'])
		$id="&id={$_GET['id']}";
		// putting in the value  of coursecode
	
	echo <<<EOB
	
	<form action="{$_SERVER['PHP_SELF']}?mode={$_GET['mode']}$id" method="post">
		
				<p> ID Number:
				<input type="text" name="id" /></p><i>{$messages['id']}</i> <br/>
				<p>
				First Name: 
				<input type="text" name="firstname" /></p> <i>{$messages['firstname']}</i> <br/>
				<p>
				Last Name: 
				<input type="text" name="lastname" /></p><i>{$messages['lastname']}</i> <br/>
				<p>
				Password:       
				  <input type="password" name="password" /></p><i>{$messages['password']}</i> <br/>
				<p>
				Re enter Password: 
				<input type="password" name="repassword" /></p>
				<p>
				
				Select Your Entry Year
				<p> 
				  <select name="year">
					<option value="1999">1999</option>
					<option value="2000">2000</option>
					<option value="2001">2001</option>
					<option value="2002">2002</option>
					<option value="2003">2003</option>
					<option value="2004">2004</option>
					<option value="2005">2005</option>
					<option value="2006">2006</option>
					<option value="2007">2007</option>
					<option value="2008">2008</option>
					<option value="2009">2009</option>
					<option value="2010">2010</option>
					<option value="2011">2011</option>
					<option value="2012">2012</option>
					<option value="2013">2013</option>
					<option value="2014">2014</option>
					<option value="2015">2015</option>
					<option value="2016">2016</option>
					<option value="2017">2017</option>
					<option value="2018">2018</option>
					<option value="2019">2019</option>
					<option value="2020">2020</option>
				  </select>
				  
				  <p>
						<input type="submit" name="submit" value="Save" />
						<input type="submit" name="submit" value="Cancel" />
					</p>
					</form>
	
EOB;
	
	print_footer();


}


/* validate submitted data
   returns an array of error messages, indexed by variable name.
   returns an empty array if all data validated successfully

*/
function validate_input()
{
	$messages = array();
	
	if (!$_POST['id'])
		$messages['id'] = 'please submit an ID Number';
		
	if (!$_POST['firstname'] )
		$messages['firstname'] = 'please submit your First name';
	
	if (!$_POST['lastname'])
		$messages['lastname'] = 'please submit your Last Name';
	
	
	if (!$_POST['password'] )
		$messages['password'] = 'please submit a Password';
		
	if ($_POST['password'] < 0)
		$messages['password'] = 'please submit a valid Password';
		
	
		
	
	// can do database queries to validate against existing data
	
	return $messages;
}

?>


              <table border='1' align="center" class="twoColLiqLtHdr" table>
                  <?php
                $hostname = "localhost";
            $username = "root";
            $password = "hayden";
            $database = "ecng3020";
            
              //session_start();
            $con = mysql_connect("$hostname","$username","$password");
            if (!$con)
              {
              die('Could not connect: ' . mysql_error());
              }
              mysql_select_db("$database", $con);
            
            
            //$level = $_POST['level'];
            //$id=$_SESSION['username'];
            $stu="SELECT id_no,first_name,last_name FROM students";
                    
            if ($result_3=mysql_query($stu))
                
            echo '<h1><p>Student Accounts present in the Database</p></h1>';	
            echo "<tr><td>ID</a></td><td>First Name</td><td>Last Name</td></tr>";
            while ($row = mysql_fetch_row($result_3))
            {
            echo"<tr><td>$row[0]</td><td>$row[1]</td><td>$row[2]</td><td><a href='myform_student.php?mode=edit&id=$row[0]'>edit</a>
			</td></tr>";	
			
			

            }
            
            ?>
                  </table>

You have to change this line...

<form action="{$_SERVER['PHP_SELF']}?mode={$_GET['mode']}$id" method="post">

into this line

<form action="{$_SERVER['PHP_SELF']}?mode=$id" method="post">

and can get id into nw page like

$id = $_GET;

// other variables like..

$name = $_POST['name'];

hope this will help u..:)

pbcomput
can u explain in more detail what u said in ur last post please
thanks alot for ur comments

pbcomput
can u explain in more detail what u said in ur last post please
thanks alot for ur comments

First you tell me that now you get value in $id or not ?? i think u got value in $id...

now your ans...:)

Yes..i told u to replace your form tag

<form action="{$_SERVER['PHP_SELF']}?mode={$_GET['mode']}$id" method="post">

with

<form action="{$_SERVER['PHP_SELF']}?mode=$id" method="post">

when u pass any variable through addressbar or link or url u not need to specify the GET method..it will automatically become get method when u pass it through url.

in your form tag u specified the GET method that's why u didnt got any result..in $id...

so just remove that GET method..and it will be working..:)

still have query ??? just ask me again ...:) i m here to help u...:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.