
Jun 3rd, 2007, 09:57
|
|
Junior Member
|
|
Join Date: May 2007
Location: bahrain
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
|
Problem with insert into the database
Hi
I don't know what's wrong with this code it doesn't insert into the table
- Code: Select all
<?php
session_start();
if( isset($_SESSION['ses_name']) )
{
}
else
{
// error page
include("anauthorized.html");
exit();
}
?>
<?php
$iid = $_SESSION['ses_name'];
echo"<body background='logo_02.gif'>";
$i=0;
$r=mysql_connect("localhost","groupd_abc","passcba","groupd_datab1");
$x=mysql_select_db("groupd_datab1");
//echo $r."<br>";
//echo $x."<br>";
echo " <br><br><br><br>";
$super= mysql_query("SELECT SUPERID FROM INSTRUCTOR where INSID=$iid");
$sup=@mysql_fetch_array($super);
if ($sup['SUPERID']==NULL)
{
$q="select * from PENDING_STUDENT";
$x=mysql_query($q);
//$fe=mysql_fetch_array($x);
echo"<center><table border='1'>" ;
echo"<tr>
<th><input type='checkbox'></th>
<th>NAME </th>
<th>ID</th>
<th>EMAIL </th>
<th>MAJOR</th>
<th>accept</th>
</tr>";
while($fe=@mysql_fetch_array($x))
{
print "<form action=\"accpend.php\" method=\"post\">";
echo "<tr>";
echo "<th><input type='checkbox' value='1' name='ch3'></th>";
echo"<td>".$fe['NAME']."</td>";
print "<td><input type='textbox'name='id' value=".$fe['SID']." ></td>\n";
//echo"<td>". $fe['SID']."</td>";
echo "<td>".$fe['EMAIL']."</td>";
echo "<td>".$fe['MAJOR']."</td>";
print "<td><input type=\"submit\" name=\"submit\" value=\"accept\"></td>";
echo "</tr>";
print "</form>\n";
}
echo"</table>";
}
mysql_close($r);
?>
accepend. php code
- Code: Select all
<?php
/* $name=$_post['name'];
$em=$_post['EMAIL'];
$ip=1234;
$id=$_post['id'];
echo $ip;
echo $em;
echo $id;
echo $name;*/
<A href="mailto:$r=@mysql_connect("localhost","groupd_abc","passcba","groupd_datab1">$r=@mysql_connect("localhost","groupd_abc","passcba","groupd_datab1");
<A href="mailto:$ff=@mysql_select_db("groupd_datab1">$ff=@mysql_select_db("groupd_datab1");
$id=$_post['id'];
echo $id;
if(!$con)
{
die("not working sorry " . mysql_error());
}
else
{
$q="select * from PENDING_STUDENT where SID=".$id;
$x=@mysql_query($q);
if($_post['ch3']=1)
{
while($j=@mysql_fetch_array($x))
{
$name=$_post['name'];
$em=$_post['EMAIL'];
$ip=1234;
$id=$_post['id'];
echo $ip;
$sql="insert into INSTRUCTOR(NAME,SID,SPASSWORD,EMAIL) values('$name','$id','$ip','$em')";
$x=@mysql_query($sql);
$fff="DELETE FROM PENDING_STUDENT WHERE SID='$id'";
$jx=mysql_query($fff);
echo $x;
if($x)
{
echo"the student where add it , own the system ";
}
else
echo mysql_error();
}
//echo mysql_error();
}
else
echo mysql_error();
mysql_close($r);
}
?>
Thanks 
|