Home  >  Article  >  Backend Development  >  What should I do if php cannot transmit the form?

What should I do if php cannot transmit the form?

藏色散人
藏色散人Original
2019-11-07 09:43:562210browse

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(&#39;config.php&#39;); ?><?phpmysql_select_db("data");$words=$_post[&#39;words&#39;];if($words){$query="insert into chat(chtime,nick,words,face)values(now(),&#39;$nick&#39;,&#39;$words&#39;,&#39;$face&#39;)";//插入SQL语句mysql_query($query,$link_ID); //发送留言到数据库header("refresh:0; URL=&#39;show.php&#39;"); }
?>

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(),&#39;$nick&#39;,&#39;$words&#39;,&#39;$face&#39;)";//插入SQL语句
mysql_query($query,$link_ID); //发送留言到数据库
header("refresh:0; URL=&#39;show.php&#39;"); }
?>

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn