Heim > Artikel > Backend-Entwicklung > 请问一个简单的投票页面,post如何写
请教一个简单的投票页面,post怎么写
以前写过一个简单的投票功能,作用是php post值 如果和数据库内容一致,则count+1 截图如下
<form method="post" action="check.php"> <br /><input type="text" name="test"> <br /><br /><input type="hidden" name="action" value="send"> <br /><input type="submit" name="Submit" value="提交"> <br /></form> <br /><br /><?php<br />$conn = mysql_connect("127.0.0.1:8889","root","root"); <br />$action = $_POST['action']; <br />if($action == 'send'){ <br />$test = $_POST['test']; <br /><br />mysql_select_db("test3",$conn); <br />$sql = ("update tll set count=count+1 where tl01='$test'");<br />$result = mysql_query($sql,$conn); <br />} <br />?>
<br /><form method="post" action="check.php"> <br /><input type="text" name="test[]"> <br /><br /><input type="text" name="test[]"> <br /><br /><input type="text" name="test[]"> <br /><br /><input type="hidden" name="action" value="send"> <br /><input type="submit" name="Submit" value="提交"> <br /></form> <br /><br /><?php<br />$conn = mysql_connect("127.0.0.1:8889","root","root"); <br />$action = $_POST['action']; <br />if($action == 'send'){ <br />$test = $_POST['test[]']; <br /><br />mysql_select_db("test3",$conn); <br />$sql = ("update tll set count=count+1 where tl01='$test'");<br />$result = mysql_query($sql,$conn); <br />} <br />?>的话就完全行不通了 ,实在不懂,请大神帮忙看下改下代码,十分感谢!
$conn = mysql_connect("127.0.0.1:8889","root","root"); <br />$action = $_POST['action']; <br />if($action == 'send'){ <br /> $test = join("','", $_POST['test']);<br /> <br /> mysql_select_db("test3",$conn); <br /> $sql = ("update tll set count=count+1 where tl01 in ('$test')");<br /> $result = mysql_query($sql,$conn); <br />}