I am trying to design a login and account creation form for a project. How would
ID: 3800126 • Letter: I
Question
I am trying to design a login and account creation form for a project. How would I store the usernames and passwords entered by the user(s) for validation purposes?
Here is the code for the login page that I have so far. The format works fine, it just doesn't do anything yet.
{
<!DOCTYPE html>
<html>
<head>
<title> Login </title>
<link rel="stylesheet" type="text/css" href="SDWebpage.css">
</head>
<body>
<form action="/action_page.php">
<div class="container">
<legend>Login Form</legend>
<table>
<tbody>
<tr>
<td>
<label>Email:</label>
</td>
<td>
<input type="text" placeholder="Enter Email" name="uname" required>
</td>
</tr>
<tr>
<td>
<label>Password:</label>
</td>
<td>
<input type="password:" placeholder="Enter Password" name="psw" required>
</td>
</tr>
<tr>
<td>
<button type="button" class="login">Login</button>
</td>
<td>
<span class = "new acct">New user? <a href="#">Create Account</a></span>
</td>
</tr>
<tbody>
</table>
</div>
<div class="container">
<button type="button" class="cancelbtn">Cancel</button>
<span class="psw">Forgot <a href="#">password?</a></span>
</div>
</form>
</body>
</html>
}
Explanation / Answer
since you are submiting your form to a php page that is action_page.php
you can get values entered in your form on this page using php syntax and name of HTML element.
$variable_name=$_GET['html_element_name'];
for example you can get password by typing following syntax:
$pass=$_GET['psw'];
by doing this you can assign the password entered in the html form to variable "pass" on your php page.
and then you can check or validate that password as per your requirements.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.