Login page in php | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

Login page in php

How it is possible to create a login page with PHP without a database? Is that even make sense? I mean, I'll set an if function that check if that checks if the user types the password that Iā€™ll set. Like if the user enters in the text box ā€test123ā€ it's will display the text ā€you are logged inā€ and if the user wrong, it's will display the text ā€wrong passwordā€

16th Jan 2020, 8:03 AM
šŸ‡®šŸ‡± Mutedly šŸ‡®šŸ‡±
šŸ‡®šŸ‡± Mutedly šŸ‡®šŸ‡± - avatar
5 Respostas
+ 1
šŸ‡®šŸ‡± Atanimo Develop šŸ‡®šŸ‡± If you want to use phpmyadmin then you need an database creation at that phpmyadmin in MySQL and then connect that database with your page like this way <form action='logini.php' method='POST'> <input type='text' name='user' /> <input type='password' name='pass' /> <input type='submit' name='sentForm' /> </form> <?php $con = mysqli_connect('dbserver', 'dbusername', '', 'dbname') or die(mysql_error()); if (isSet($_POST['sentForm'])) { $user = $_POST['user']; $pass = sha1($_POST['pass']); $query = mysqli_query($con, "SELECT * FROM `users` WHERE `username`='$user' AND `password`='$pass'") or die(mysql_error()); echo $user.$pass; if (mysqli_num_rows($query) > 0) { $_SESSION['user'] = $user; echo 'Successful login.'; }else{ echo 'Failed login.'; } mysqli_close($con); } ?>
16th Jan 2020, 1:20 PM
DishaAhuja
DishaAhuja - avatar
+ 1
šŸ‡®šŸ‡± Atanimo Develop šŸ‡®šŸ‡± It's only basic php where you can use if else statements and password validation then put echo all statement which you need to print. For password validation you can simply use basic php by same logics which we apply in C, C++ or in any other language. If you have tried code and need any feedback over that then link the thread I'll try to help and improve on that. Frankly php is used for server side scripting for client and server tiring. For the following approach you can use Javascript in place of php which would be more efficient.
16th Jan 2020, 1:04 PM
DishaAhuja
DishaAhuja - avatar
+ 1
šŸ‡®šŸ‡± Atanimo Develop šŸ‡®šŸ‡± You don't want to store the data of login user if you don't do that then their is no way for knowing who has login in the system. And your webpage will be just an demonstration of an login page in html which is an static website
16th Jan 2020, 1:17 PM
DishaAhuja
DishaAhuja - avatar
+ 1
šŸ‡®šŸ‡± Atanimo Develop šŸ‡®šŸ‡± For creating login page the best php way is by creating session and initialise that session and use that for login users. Here are some information about session https://www.sololearn.com/learn/PHP/1842/?ref=app
16th Jan 2020, 1:21 PM
DishaAhuja
DishaAhuja - avatar
0
DishaAhuja What do you mean? And if I want to use like phpmyadmin? I will be able to use PHP to do that? I'll explain again, I want to set up a text area and register section. the users only will be able to log in only they register on the register page. How do I do that?
16th Jan 2020, 1:12 PM
šŸ‡®šŸ‡± Mutedly šŸ‡®šŸ‡±
šŸ‡®šŸ‡± Mutedly šŸ‡®šŸ‡± - avatar