Hey there, this post would be another post under the I’m Stuck!!! series. I’d like you to know one of the things that was curious about and didn’t know that I was able to do it. And that thing is I actually knew how to make the form to change password. You know that thing when you have an account, and then it has the page where you can change your password, that’s the thing that I’m gonna share with you in this post. It’s very simple, the main idea that we’re gonna use is the UPDATE syntax. Yup, it’s that simple.
Since we need a database to store the login information, this is the database that I’ll be referring to :
Database name= company
Table name= staff
And the name of this page is password.php
Now the preparation’s all done, let’s head over to the fun part.
We are going to write ONLY 1 page of code, so don’t be that terrified.
<form action=”password.php” method=”POST”>
<input type=”text” name=”user”>
<input type=”text” name=”pass”>
<input type=”submit” name=”submit”>
$conn = mysqli_connect(“localhost”,”root”,””,”company”);
$user = $_POST[‘user’];
$pass = $_POST[‘pass’];
$update = “UPDATE staff SET StaffID=$pass WHERE Name=’$user'”;
echo “Successfully changed password”;
echo “Error” . mysqli_error($conn);
– This piece of code means if the submit button is pressed..
– If you didn’t declare the name of the submit input, it’ll return
as an error.
That is it for this post. The most IMPORTANT part is for you to code yourself. Have a fun time changing passwords!
Any inquiries, mail me at firstname.lastname@example.org