im試圖使用方法POST(其中數據庫的名稱是「firstdb」)和名爲「TAB1」的表將值從一個頁面發送到另一個頁面。 這裏是我的代碼:使用POST方法在頁面上傳遞值HTML
第一頁命名爲「addStud.php」。代碼:
<html>
<body>
<form action= "addStud_D.php" method="POST">
<center>
<fieldset>
Last Name : <input type = 'text' name ='LName'>
</br> </br>
First Name : <input type = 'text' name = 'FName'>
</br></br>
Date of birth : <input type = 'text' name = 'dat'>
</br></br>
<input type='submit' value='OK'>
</fieldset>
</center>
</form>
</body >
</html>
接收命名爲「addStud_D.php」數據的第二頁。代碼是:
<html>
<body>
<?php
$V1 = $_POST['LName'];
$V2 = $_POST['FName'];
$V3 = $_POST['dat'];
$db=mysql_connect('127.0.0.1','root','','firstdb')
or die('error connecting to MySQL server.');
mysql_select_db('firstdb');
mysql_query("INSERT INTO `firstdb`.`TAB1` (`ID`, `Last_Name`, `First_Name`,`date`)
VALUES (NULL,'$V1','$V2', '$V3')");
?>
</body>
</html>
仍然。這種方法是行不通的,這裏是錯誤:
Notice: Undefined index: LName in D:\Computer Scince\Web\EasyPHP-5.3.3.1\www\APP04\addStud_D.php on line 6
Notice: Undefined index: FName in D:\Computer Scince\Web\EasyPHP-5.3.3.1\www\APP04\addStud_D.php on line 7
Notice: Undefined index: dat in D:\Computer Scince\Web\EasyPHP-5.3.3.1\www\APP04\addStud_D.php on line 8
的第一個問題都是在同一個目錄下的文件? – Exprator
並將方法更改爲html中的方法 – Exprator