如何将两个php文件中的数据插入一个表到我的数据库?

时间:2016-03-19 13:07:57

标签: php html mysql

我的系统只有两个事务,即Registration.php和req.php。这两个事务数据保存在我的数据库中的新表中。 Registration.php是我的第一个transacton,然后是req.php。这个php文件是表单,它们都有一个链接到add.php的提交按钮。我的新表的字段分为两种形式。流程是首先执行Registration.php然后执行req.php。我的表new有一个名为new_id的主键及其自动增量。我的问题是,在执行两个表单后,只有Registration.php的数据保存在数据库表new中,req.php为空。问题是什么?我需要你的帮助。

这里是Registration.php代码:

<html>
<head>
<link rel="stylesheet" href="bootstrap/css/bootstrap.css"/>
<script type="text/javascript" src="jquery.js">
</script>
<script type="text/javascript" src="bootstrap/js/bootstrap.js">

</script>
<title>
REQUIRMENTS FORM    
</title>
<br>
<p align="center" style="font-size: 50">REQUIRMENTS FORM</p> 
</head>
<body>
<center>
<br>
<p align="center" style="font-size: 30">Registrar</p>
<form style="font-size: 20" action="add.php" method='post'>
 Form 138
<br>
<select name="form1">
<option value=""</option>
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
<br>
Form 137A
<br>
<select name="form2">
<option value=""</option>
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
<br>
2 X 2 ID
<br>
<select name="picture">
<option value=""</option>
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
<br>
NSO Birth Certificate
<br>
<select name="nso">
<option value=""</option>
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
<br>
Good Moral Certificate
<br>
<select name="gmc">
<option value=""</option>
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
<p align="center" style="font-size: 30">Library</p>
Library Card
<br>
<select name="lc">
<option value=""</option>
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
<br>
<br>
<p align="center" style="font-size: 30">Cashier</p>
<p><h4>You should have paid minimum of P2000.00-2500.00</h4></p>
<input type="text" name="cashier" class="Form-Control" width="100px" placeholder="Enter amount" id="cashier" required></input>
<button type="submit" style="font-size: 20" class="btn btn-primary btn-block" name="submit" value="save">SUBMIT</button>
<button  type="button" style="font-size: 20" class="btn btn-primary btn-block"><a href="newform.php?id=<?php echo $data->new_id ?>">Process Student Copy</button>
<input type="hidden" value="<?php echo $data->new_id ?>" name="id" >
</form>
</body>
</html>

这里是req.php代码:

<?php
mysql_connect("localhost","root");
mysql_select_db("enrollee");
$course=$_POST['new_course'];
$gender=$_POST['new_gender'];
$gender=$_POST['new_gender'];
$status=$_POST['new_status'];
$fname=$_POST['new_fname'];
$mname=$_POST['new_mname'];
$lname=$_POST['new_lname'];
$age=$_POST['new_age'];
$bp=$_POST['new_bp'];
$add=$_POST['new_add'];
$nat=$_POST['new_nat'];
$rel=$_POST['new_rel'];
$tel=$_POST['new_tel'];
$cel=$_POST['new_cel'];
$mail=$_POST['new_mail'];
form1=$_POST['form1'];
$form2=$_POST['form2'];
$picture=$_POST['picture'];
$nso=$_POST['nso'];
$gmc=$_POST['gmc'];
$lc=$_POST['lc'];
$cashier=$_POST['cashier'];

mysql_query("INSERT INTO new(new_id,new_course,new_gender,new_status,new_fname,new_mname,new_lname,new_age,new_bp,new_add,new_nat,new_rel,new_tel,new_cel,new_mail,form1,form2,picture,nso,gmc,lc,cashier))
                VALUES(NULL, '$course','$gender', '$status', '$fname','$mname','$lname','$age','$bp','$add','$nat','$rel','$tel','$cel','$mail','$form1','$form2','$picture','$nso','$gmc','$lc','$cashier')");         
    header("Location: read.php");
    ?>

这是add.php代码:

{{1}}

0 个答案:

没有答案