我正在尝试通过GET方法将一些值从HTML表单传递到另一个PHP文件。但是当我点击提交时,它会显示该PHP文件的代码,而不是在浏览器中运行该文件。请查看我的快照
我也附上了我的代码: 表格:
<form action="input.php" method="GET">
<div id="form">
<h2>REGISTRATION NO.<br> <inenter code hereput type="text" name="reg_no"><br></h2>
<h2>BOARD<br> <input type="text" name="board"><br></h2>
<h2>YEAR<br> <input type="text" name="year"><br></h2>
Choose Type <select name="type">
<option value="hsc">H.S.C</option>
<option value="A level">A Level</option>
<option value="Foreigner">Foreigner</option>
</select><br/><br/>
<input type="submit" value="Submit"><br /><br>
</div>
</form>
对于Receiver php文件:
<?php
$reg_no =(int) $_GET['reg_no'];
$board = $_GET['board'];
$year = (int)$_GET['year'];
$type = (int) $_GET['type'];
//$student_type =(char) $_GET['type'];
$con = mysql_connect("localhost","root");
if (!$con)
{
die('Could not connect' . mysql_error());
}
else
{
printf("Database Connection succed");
}
mysql_select_db("dblabproject",$con);
function checkRegistration()
{
}
mysql_query
("INSERT INTO`student_reg` (`reg_no`, `board`, `year`)
VALUES ('$reg_no', '".$_GET['board']."', '$year')
");
?>
答案 0 :(得分:3)