just give code for user table and register.html and
finish the code here.
Perform these tasks first:
(a) Create a table in your MySQL database called users that has two
varchar(255) fields called
username and password, and an auto_increment int field called id.
Give the username field the
UNIQUE attribute.
(b) Create an html input form called register.html that has two
fields to input username and password.
The id field is auto increment, so it will not have to be input.
The POST action of this form should call
register.php.
I have shown a version of register.php below.
Register
require_once "config.php";
echo "
";
echo "Connected successfully
";
echo "
";
// Processing form data when form is submitted
if($_SERVER['REQUEST_METHOD'] == 'POST'){
// Get submitted values
$user = trim($_POST['username']);
$passwd = trim($_POST['passwd']);
//Create a prepared statement
$sql ="insert into users(username, password) values (?,?)" ;
$stmt = mysqli_prepare($link, $sql);
// Bind variables to the prepared statement as parameters
mysqli_stmt_bind_param($stmt, "ss", $param_username,
$param_passwd);
//Set variables
$param_username=$user;
$param_passwd=$passwd;
mysqli_stmt_execute($stmt);
$rows_inserted= mysqli_stmt_affected_rows($stmt);
echo "Inserted ".$rows_inserted." rows";
}
?>
2. Create a homepage called welcome.html, it will display a
welcome message as below.
Welcome!
If you haven't registered, please click register.
Register here!
If you've registered, please log in.
Login here!
</body>
</html>
The html code is provided but it is not finished. Please use
“username” and “password”
for the two input boxes, respectively.
Login
If you are a registered user, please log in
//finish the code here
6. Right now, you should have register.html, register.php,
login.html, login.php and welcome.index
Welcome! If you haven't registered, please click register. Register here! If you've registered, please log in. Login here! You can use the following html code:
If you are a registered user, please log in Username: Password: Login
just give code for user table and register.html and finish the code here. Perform these tasks first: (a) Create a table
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
just give code for user table and register.html and finish the code here. Perform these tasks first: (a) Create a table
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!