这是我的注册表格:
<p>Please fill out all fields</p><br>
<form method="POST" action="login/login.php">
<!-- name is the VARIABLE -->
Username: <input type="text" name="username"></br>
Password: <input type="password" name="password"></br>
Email: <input type="text" name="email"></br>
</form>
</br>
</br>
<form method="POST" action="login/process.php" "> </br>
<input type='submit' value='submit registration'/>
</form>
这是我的process.php文件:
<?php
print "<center>";
$Username = $_POST["username"];
$Password = $_POST["password"];
$Email = $_POST["email"];
?>
<?php
include "../shopdb/connection.php";
$query="INSERT INTO USERS (ID, Username, Password, Email) VALUES ('','$Username','$Password','$Email')";
mysql_query($query,$connect);
?>
我一直收到这个错误:
注意:未定义的索引:第3行的C:\ xampp \ htdocs \ IIS \ login \ process.php中的用户名
注意:未定义的索引:第4行的C:\ xampp \ htdocs \ IIS \ login \ process.php中的密码
注意:未定义的索引:第5行的C:\ xampp \ htdocs \ IIS \ login \ process.php中的电子邮件
您已成功连接到数据库。
(底部消息是我添加的连接脚本的一部分,用于显示我已连接到数据库)..
任何帮助都会很棒。
答案 0 :(得分:2)
您的提交按钮的格式与文本字段所在的表单不同。这应该有效:
<form method="POST" action="login/process.php">
<!-- name is the VARIABLE -->
Username: <input type="text" name="username"></br>
Password: <input type="password" name="password"></br>
Email: <input type="text" name="email"></br>
<input type='submit' value='submit registration'/>
</form>
顺便说一句,您应该检查变量是否存在之前:
if(isset($_POST['username'])){
echo 'Variable is set and I can use it!';
}
答案 1 :(得分:0)
您的submit
输入需要与其他输入位于同一<form>
。