How to connect Database to HTML page
Hey,
I have created login page. I have created database as well and created user and their priviliges as well. I want to connect login.html page with database. But i do not know how to do this. Please anyone help me. I want to connect with DB because if a registered user come again data can be verified from DB if not move to Register.html page.
-
Hey, I am new to this platform. I designed a login page now i want to connect these credentials with Database. But i do not know how to connect with database. 0 -
First you have to create a database, a database user and a password. Login to cPanel, Go to MySQL database, create database there then go back and create a user. After that select the database and user then add permissions and you are good to go. 0 -
I have done all this but still there is an issue. Domain hosting said its script issue. 0 -
What is the error you are getting exactly? 0 -
I am not connection with database. I think i have issue in script. But i don't know how can i solve it. 0 -
I have two files login.php and server.php. I want as a new user come it should enter usrname and password then it should be store in database. As in future registered user come authenticate username and password from database then redirect to the 'dashboard.html'. But i do not know whats the issue with that code i am not redirecting the other page. Not having any value in database. Please guide me Login. php Login
Server.php)) { // receive all input values from the form $username = mysqli_real_escape_string($db, $_POST['username'>); $firstname = mysqli_real_escape_string($db, $_POST['firstname'>); $lastname = mysqli_real_escape_string($db, $_POST['lastname'>); $email = mysqli_real_escape_string($db, $_POST['email'>); $bankname = mysqli_real_escape_string($db, $_POST['bankname'>); $accountnumber = mysqli_real_escape_string($db, $_POST['accountnumber'>); $phonenumber = mysqli_real_escape_string($db, $_POST['phonenumber'>); $sponsor = mysqli_real_escape_string($db, $_POST['sponsor'>); $password = mysqli_real_escape_string($db, $_POST['password'>); // Finally, register user if there are no errors in the form if (count($errors) == 0) { $password = md5($password);//encrypt the password before saving in the database $query = "INSERT INTO users (username, firstname, lastname, email, bankname, accountnumber, phonenumber, sponsor, password) VALUES('$username', '$firstname', '$lastname', '$email', '$bankname', '$accountnumber', '$phonenumber', '$sponsor', '$password')"; mysqli_query($db, $query); $_SESSION['username'> = $username; $_SESSION['success'> = "You are now logged in"; header('Location: https://helperstree.com.ng/dashboard.html'); //echo ""; } } // ... // LOGIN USER if (isset($_POST['login_user'>)) { $username = mysqli_real_escape_string($db, $_POST['username'>); $password = mysqli_real_escape_string($db, $_POST['password'>); if (empty($username)) { array_push($errors, "Username is required"); } if (empty($password)) { array_push($errors, "Password is required"); } if (count($errors) == 0) { $password = md5($password); $query = "SELECT * FROM users WHERE username='$username' AND password='$password'"; $results = mysqli_query($db, $query); if (mysqli_num_rows($results) == 1) { $_SESSION['username'> = $username; $_SESSION['success'> = "You are now logged in"; header('Location: https://helperstree.com.ng/dashboard.html'); // echo ""; }else { array_push($errors, "Wrong username/password combination"); } } } ?>
0 -
You need to hire a PHP developer to look into your code then. This is not really a cPanel issue :( 0 -
You'd get the most help from looking up a tutorial on how to create this such as the following:
https://phppot.com/php/php-user-registration-form/
https://codewithawa.com/posts/complete-user-registration-system-using-php-and-mysql-database
0
Please sign in to leave a comment.
Comments
8 comments