HTML向php提交表单后弹出404怎么解决?

WBOY
Release: 2016-06-23 13:28:30
Original
1567 people have browsed it

HTML代码

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>注册</title></head><body> <div>   <form action="zhuce.php" method="post">     <table width="200" border="1">  <tr>    <td>用户名:</td>    <td><input type="text" name="name" /></td>  </tr>  <tr>    <td>密  码:</td>    <td><input type="password" name="password" /></td>  </tr>  <tr>    <td>性  别:</td>    <td><p>      <label>        <input type="radio" name="sex" value="boy" id="sex_0" />        男</label>      <label>        <input type="radio" name="sex" value="g" id="sex_1" />        女</label>    </p></td>  </tr>  <tr>    <td><input type="submit" name="button" id="button" value="提交" /></td>    <td><input type="reset" name="button2" id="button2" value="重置" /></td>  </tr></table>   </form> </div></body></html>
Copy after login

php代码
<?php/** * Created by PhpStorm. * User: Administrator * Date: 2015/8/15 * Time: 16:28 *///连接服务器define("mysql_host","localhost");define("mysql_user","root");define("mysql_pw","");function connectdb(){    $conn=mysql_connect(mysql_host,mysql_user,mysql_pw);//连接MySQL服务器    if(!$conn){        die("服务器连接失败");    }    mysql_select_db("test",$conn);//选择test表单    return $conn;}?>
Copy after login
<?php/** * Created by PhpStorm. * User: Administrator * Date: 2015/8/16 * Time: 15:02 */if(!isset($_POST['name'])){    die('user name not define');}if(!isset($_POST['password'])){    die('user password not define');}if(!isset($_POST['sex'])){    die('user sex not define');}$name=$_POST['name'];if(empty($name)){    die('user name not empty');}$password=$_POST['password'];if(empty($password)){    die('user password not empty');}$sex=$_POST['sex'];if(empty($sex)){    die('user sex not empty');}require_once 'connect_server.php';connectDb();mysql_query("insert into users(name,password,sex) VALUES ('$name','$password','$sex')");header("location:index.php");
Copy after login

数据库
有什么解决办法吗?


回复讨论(解决方案)

404时,URL地址是什么?

404表示页面不存在。
打印提交的地址看看是否正确。

zhuce.php 看看是否存在。

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template