Hi
I have two different types of users one is student the other is staff. Right now in the staff account the staff can search student from the database. What I want to do is that when the search result returns the staff can click on the add button to store copy of this student's data to another database table.
Right now I am not able to add copy of the student record into another table because:
1.there is the foreign key constraint
2.I know the code in the data.php(see below) is incorrect.
I would grateful if you could point out what I need to do? Thanks
Here is the code in the Staff Account;
<?php
if(isset($_POST['find'])){
if(empty($_POST['find'])){
$nameErr = "Missing";}
else{
//$find = $_POST['find'];
$results=getStudent();
echo "<table>
<tr>
<th>Username</th>
<th>First Name</th>
<th>Surname</th>
</tr>";
while ($row = mysql_fetch_array($results)){
echo "<tr>";
echo "<form action=data.php method=post>";
echo "<td>" .$row['username']."</td>";
echo "<td>".$row['firstname']."</td>";
echo "<td>".$row['surname']."</td>";
echo "<input id=addS name=adds type=submit/></form></td>";
echo "<tr/>";
}
echo"</table>";
}
}
?>
Here is the code in the data.php
<?php
if(isset($_POST['adds'])){
$_row['username'] = $_POST['username'];
$_row['firstname'] = $_POST['firstname'] ;
$_row['surname'] = $_POST['surname'] ;
//inserting data order
$order = "INSERT INTO studentgroup
(username,firstname,surname)
VALUES
('$_POST[username]',
'$_POST[firstname]','$_POST[surname]')";
$result = "select * from studentgroup";
if(!mysqli_query($con,$order)){
die('Error:'. mysqli_error($con));
}
header ("Location: staffAccount.php");
}
}
?>