jnrng
06-24-2014, 06:12 AM
I am new to php, mysql, I have 2 tables (table1 and table2) and wish to move data from table1 to table2 such that when a user filled in a reg_number in the form field and clicks the submit button it executes the code and opens a fresh page named "register.php.
I am having problem with this code as it fails to execute and returning blank page. Please help me in resolving this problem.
here is the form:
<form action="discharge.php" method="post">
<p>INSERT STUDENT'S REGISTRATION NUMBER
<input type="text" name="reg_number" value="">
</p>
<p>
<input type="submit" value="Submit">
</p>
</form>
and
here is my discharge.php code:
<?php
include('connect.php');
// username and password sent from form
$reg_number=$_POST["reg_number"];
$sql="INSERT INTO table2 (reg_number, surname,first_name, othername, gender)
SELECT reg_number, surname,first_name, othername, gender FROM table1 WHERE reg_number='$reg_number'";
DELETE * FROM table1 WHERE reg_number='$reg_number'";
$result=mysql_query($sql);
if(!$result)
{
header ("location:register.php");
}
?>
I am having problem with this code as it fails to execute and returning blank page. Please help me in resolving this problem.
here is the form:
<form action="discharge.php" method="post">
<p>INSERT STUDENT'S REGISTRATION NUMBER
<input type="text" name="reg_number" value="">
</p>
<p>
<input type="submit" value="Submit">
</p>
</form>
and
here is my discharge.php code:
<?php
include('connect.php');
// username and password sent from form
$reg_number=$_POST["reg_number"];
$sql="INSERT INTO table2 (reg_number, surname,first_name, othername, gender)
SELECT reg_number, surname,first_name, othername, gender FROM table1 WHERE reg_number='$reg_number'";
DELETE * FROM table1 WHERE reg_number='$reg_number'";
$result=mysql_query($sql);
if(!$result)
{
header ("location:register.php");
}
?>