Home > Article > Backend Development > What should I do if php cannot transmit the form?
#What should I do if php cannot transmit the form value?
Error code;
html页代码: <form action="show.php" target="mainFrame" method="post"> <input type="text" name="words" cols="200"/><input type="submit" value="发言"/> 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); //发送留言到数据库header("refresh:0; URL='show.php'"); } ?>
Solution:
php is case-sensitive, use $_POST to check.
Another one, in the html part, the end character of the form cannot be seen.
<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="发言"/> </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); //发送留言到数据库 header("refresh:0; URL='show.php'"); } ?>
Follow the above steps to improve it. If it still doesn’t work, add a print_r($_POST); in front of mysql_select_db("data"); to see what data can be output.
For more PHP related knowledge, please visit PHP Chinese website!
The above is the detailed content of What should I do if php cannot transmit the form?. For more information, please follow other related articles on the PHP Chinese website!