mysql 404错误发布

时间:2016-06-22 13:50:57

标签: php mysql

我正在建立一个简单的在线艺术商店。该网站的一部分是注册功能,允许用户注册。我正在使用MySQL作为数据库。注册页面具有用户填写基本信息的表单。 php脚本位于一个名为" registerAction.php"的单独的php文件中。但是,当按下提交按钮时,我收到404错误,说无法找到带有php脚本的文件。

以下是注册表格的代码部分:

<table class="registerField">
        <form method="post" action="registerAction.php" >
        <tr>
            <td class="query">
                Username:
            </td>
            <td>
                <input type="text" class="field" name="UserName">
            </td>
            <td class="help">Longer than 5 characters, cannot start with a number.</td>
        </tr>

        <tr>
            <td class="query">
                Name:
            </td>
            <td>
                <input type="text" class="field" name="RealName"
            </td>
            <td class="help">Your Name </td>

        </tr>

        <tr>
            <td class="query">
                Password:
            </td>
            <td>
                <input type="password" class="field" name="Password">
            </td>
            <td class="help">Longer than 6 characters.</td>
        </tr>

        <tr>
            <td class="query">
                Confirm password:
            </td>
            <td>
                <input type="password" class="field" name="RePassword">
            </td>
            <td class="help">Re-enter password.</td>
        </tr>
        <tr>
            <td> </td>
            <td><input type ="submit" value="Submit</td>
        </tr>
        </form>
    </table>

这是registerAction.php的代码:

<?php
$con=mysqli_connect('localhost','root','','Users');

$UName=$_POST['UserName'];
$RName=$_POST['RealName'];
$Password=$_POST['Password'];
$RePassword=$_POST['RePassword'];

if(!$con){
    echo "CONNECTION ERROR";
}

if(!mysqli_select_db($con,'Users')){
    echo "DATABASE ERROR";
}


$sql="INSERT INTO Users (UserName,Password,RealName) VALUES('$UName','$Password','RName')";

if(mysqli_query($con,$sql)){
echo"ERROR";
}else{
    echo"REGISTRATION SUCCESSFUL";
}

为什么浏览器找不到registerAction.php文件?注册表单和registrationAction.php都在同一个文件夹中。如果它有任何意义,我使用XAMPP for MySQL,编码在PHPStorm中完成。

非常感谢任何帮助。

1 个答案:

答案 0 :(得分:0)

 <form method="post" action="registerAction.php">

根据您的代码,registerAction.php文件必须与您的注册表单文件位于同一文件夹中