php無法傳輸form的值怎么辦?
錯(cuò)誤代碼;
html頁代碼: <form action="show.php" target="mainFrame" method="post"> <input type="text" name="words" cols="200"/><input type="submit" value="發(fā)言"/> php頁代碼: <?php require_once('config.php'); ?><?phpmysql_select_db("data");$words=$_post['words'];if($words){$query="insert into chat(chtime,nick,words,face)values(now(),'$nick','$words','$face')";//插入SQL語句mysql_query($query,$link_ID); //發(fā)送留言到數(shù)據(jù)庫header("refresh:0; URL='show.php'"); } ?>
解決辦法:
php是區(qū)分大小寫的,用$_POST看看。
另外一個(gè),html部分,看不到form的結(jié)束符。
<form method="post" action="show.php" enctype="application/x-www-form-urlencoded" name="form1" id="form1"> <input type="text" name="words" value="" /> <input type="submit" value="發(fā)言"/> </form> <?php mysql_select_db("data"); $words = $_POST["words"]; if($words){ $query="insert into chat(chtime,nick,words,face)values(now(),'$nick','$words','$face')";//插入SQL語句 mysql_query($query,$link_ID); //發(fā)送留言到數(shù)據(jù)庫 header("refresh:0; URL='show.php'"); } ?>
照上面的完善一上,如果還不行,在mysql_select_db("data");前面加一個(gè) print_r($_POST); 看能輸出什么數(shù)據(jù)。