即使已设置submit_registration_form_button,也将用户重定向到

我正在为我的网站创建注册系统。创建新帐户时,用户应看到一条消息,即“成功创建了一个新帐户”;如果无法创建该帐户,则用户应看到一条消息,显示“无法创建新帐户”。


我这样做的目的是,如果用户不按index.php上的“提交表单”按钮,他们就会尝试输入


websitename.com/verify_registration_form.php


在搜索栏中,它们被重定向到index.php


我的问题是,无论用户是否按下了提交表单按钮,该用户都将重定向到index.php。


这是index.php上的注册表格


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



<input type="username" id="user_name" name="user_name placeholder="Username" required>



<input type="password" id="user_pass_word" name="user_pass_word" placeholder="Password" required>



<input type="email" id="user_email" name="user_email" placeholder="Email" required>



<input type="submit" id="submit_registration_form_button" name="submit_registration_form_button" value="Sign Up">



</form>

这是我的verify_registration_form.php文件中的表单验证


肥皂起泡泡
浏览 131回答 1
1回答

慕工程0101907

这将检查用户是否已发布请求:&nbsp; &nbsp; if($_SERVER['REQUEST_METHOD'] != 'POST')&nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; //user didn't press the register button&nbsp; &nbsp; }&nbsp; &nbsp; else&nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; //user pressed the register button&nbsp; &nbsp; }
打开App,查看更多内容
随时随地看视频慕课网APP