I have such a question, I created a form for registration and then to enter. So, for registration, you need to enter your mail password, phone number and surname. Here is the code:
<?php include_once('dbcon.php'); $error = false; if(isset($_POST['buttonreg'])){ $name = $_POST['name']; $name = strip_tags($name); $name = htmlspecialchars($name); $tel = $_POST['tel']; $tel = strip_tags($tel); $tel = htmlspecialchars($tel); $email = $_POST['email']; $email = strip_tags($email); $email = htmlspecialchars($email); $password = $_POST['password']; $password = strip_tags($password); $password = htmlspecialchars($password); //encrypt password with md5 $password = md5($password); //insert data if no error if(!$error){ $sql = "insert into users(name,tel, email ,password) values('$name','$tel', '$email', '$password')"; if(mysqli_query($conn, $sql)){ header('location: index.php'); }else{ echo 'Error '.mysqli_error($conn); } } } ?> And you can enter using mail and password:
<?php session_start(); include_once('dbcon.php'); $error = false; if(isset($_POST['buttonlogin'])){ $email = trim($_POST['email']); $email = htmlspecialchars(strip_tags($email)); $password = trim($_POST['password']); $password = htmlspecialchars(strip_tags($password)); if(!$error){ $password = md5($password); $sql = "select * from users where email='$email' "; $result = mysqli_query($conn, $sql); $count = mysqli_num_rows($result); $row = mysqli_fetch_assoc($result); if($count==1 && $row['password'] == $password){ $_SESSION['email'] = $row['email']; header('location: home.php'); }else{ $errorMsg = '<center><p>Doğru olmayan email/şifrə daxil etmisiniz</p></center>'; } } } ?> I want to, after someone has logged in there, the first name is displayed there, the phone number for example, etc. help me be blogged!
home.php? - Yaroslav Molchan