gpt4 book ai didi

php - mysql 404错误帖子

转载 作者:行者123 更新时间:2023-11-29 20:51:56 24 4
gpt4 key购买 nike

我正在建立一个简单的在线艺术品商店。该网站的一部分是注册功能,允许用户注册。我使用 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 中完成的。

任何帮助将不胜感激。

最佳答案

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

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

关于php - mysql 404错误帖子,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37970105/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com