In my program, I am trying to get the value submitted by a form and use in a sql query to retrive results and then again use the $_GET["name"] value for feeding data to the database. The following code is not propagating value inside while loop $_GET["name"]
<?php
session_start();
$id = $_GET["name"];
echo "<h2> Hello ".$id." </h2>" ;
if((isset( $_POST['dept'])))
{
echo "<h2><center>You have sected ". $_POST['dept'] ." !!</center></h2>";
$dept_ = $_POST['dept'];
$options = $_POST['course'];
foreach($options as $option) //loop through the checkboxes
{
$uid="root";
$pass="root";
$db = mysql_connect("localhost:3036",$uid,$pass);
if(!$db) die("Error connecting to MySQL database.");
mysql_select_db("sync" ,$db);
$result = mysql_query("SELECT DISTINCT `name`,`password`,INET_NTOA( `ip` ) FROM detail Where id = '$_GET["name"]' ;") or die(mysql_error());
if(mysql_num_rows($result) > 0):
while($row = mysql_fetch_assoc($result)):
$name = $row['name'];
$password = $row['password'];
$ip = $row['INET_NTOA( `ip` )'];
echo $name ; // NOT PRINTING ANYTHING
echo $password ; // NOT PRINTING ANYTHING
echo $_GET["name"] ; // NOT PRINTING ANYTHING
$sql1_Qu = "INSERT INTO registration (id,password,ip,name,course) VALUES ('$_GET["name"]','$password',INET_ATON('$ip'),'$name','$option')";
//$sql1_Qu = "INSERT INTO registration (id,password,ip,name,course) VALUES ('$id','$password',INET_ATON('$ip'),'$name','$option')";
$resu = mysql_query($sql1_Qu) or die('Could not connect: ' . mysql_error());
endwhile;
endif;
}
}
?>
This is only printing at the 4th line but not propagating the value inside while loop, which contains database query.
Please suggest some way to solve the issue ... Thanks in advance