I have this form for resetting passwords:
<form action = "resetpwd.inc.php" method = "post" class = "form">
<div class = "input-group">
<input type = "text" name = "email" placeholder = "Enter your email:">
<span class = "icon">✉</span>
</div>
<div class = "input-group">
<button class = "submitbtn" type = "submit">Reset Password</button>
</div>
</form>
I also have a resetpwd.inc.php
file with the following code that handles the form submission:
if(isset($_POST["submitbtn"]))
My goal is to have this PHP code execute when I submit the form, however it isn’t doing that and it’s just refreshing the page.
2
Answers
You are trying to check if the key
submitbtn
exists within the$_POST
array, which only contains your form inputs, howeversubmitbtn
is a CSS class on the<button>
element rather than aname
attribute.To determine if a request made to the page is a POST request, you can check to see if the array is not empty:
You can then use
filter_input
to retrieve the form value from theusername
text input field, the identifier"username"
comes from thename="username"
you set in the<input>
element.Your form action will then redirect you to the
resetpwd.inc.php
page and send a POST request.I think that you could be missing name=” property on your button, right here you have:
Instead, try this: