Answers for "login php"

PHP
1

console.log in php

/*
console.log in php
*/

<?php
	function consoleLog($message) {
		echo '<script type="text/javascript">' .
          'console.log(' . $message . ');</script>';
	}

	consoleLog('Hello, greppers!');
?>
Posted by: Guest on May-11-2020
2

login PHP

<?php
session_start();// come sempre prima cosa, aprire la sessione 
include("db_con.php"); // Include il file di connessione al database
$_SESSION["username"]=$_POST["username"]; // con questo associo il parametro username che mi è stato passato dal form alla variabile SESSION username
$_SESSION["password"]=$_POST["password"]; // con questo associo il parametro username che mi è stato passato dal form alla variabile SESSION password
$query = mysql_query("SELECT * FROM users WHERE username='".$_POST["username"]."' AND password ='".$_POST["password"]."'")  //per selezionare nel db l'utente e pw che abbiamo appena scritto nel log
or DIE('query non riuscita'.mysql_error());
// Con il SELECT qua sopra selezione dalla tabella users l utente registrato (se lo è) con i parametri che mi ha passato il form di login, quindi
// Quelli dentro la variabile POST. username e password.
if(mysql_num_rows($query)>0){        //se c'è una persona con quel nome nel db allora loggati
$row = mysql_fetch_assoc($query); // metto i risultati dentro una variabile di nome $row
$_SESSION["logged"] =true;  // Nella variabile SESSION associo TRUE al valore logge
header("location:prova.php"); // e mando per esempio ad una pagina esempio.php// in questo caso rimanderò ad una pagina prova.php
}else{
echo "non ti sei registrato con successo"; // altrimenti esce scritta a video questa stringa di errore
}
?>
Posted by: Guest on May-28-2021
3

how to make a working login system using code

<!DOCTYPE html>
<html>
<head>
	<title>Login</title>
	<script>
  firebase.initializeApp(firebaseConfig);
  const auth = firebase.auth();
  function signUp(){
    var email = document.getElementById("email");
    var password = document.getElementById("password");
    const promise = auth.createUserWithEmailAndPassword(email.value, password.value);
    promise.catch(e => alert(e.message));
    alert("Signed Up");
  }
  function signIn(){
    var email = document.getElementById("email");
    var password = document.getElementById("password");
    const promise = auth.signInWithEmailAndPassword(email.value, password.value);
    promise.catch(e => alert(e.message));
  }
  function signOut(){
    auth.signOut();
    alert("Signed Out");
  }

auth.onAuthStateChanged(function(user){
    if(user){
      var email = user.email;
      alert("Signed in as " + email);
      //Take user to a different or home page

      //is signed in
    }else{
      alert("No Active User");
      //no user is signed in
    }
  });g
	</script>
<style type="text/css">
	body{
	background-color: #55d6aa;
}
h1{
	background-color: #ff4d4d;
	margin: 10px auto;
	text-align: center;
	color: white;
}
#formContainer{
	background-color: white;
	box-shadow: 0 12px 16px 0 rgba(0,0,0,0.24), 0 17px 50px 0 rgba(0,0,0,0.19);

	width: 25%;
	height: 45;
	margin: 10px auto;
}
#header{
	width: 100%;
	height: 10px;
	background: black;
}
#email{
	width: 70%;
	height: 40px;
	display:block;
	margin: 25px auto;
	border: none;
	outline: none;
	border-bottom: 2px solid black;
}
#password{
	width: 70%;
	height: 40px;
	display: block;
	margin: 10px auto;
	border: none;
	outline: none;
	border-bottom: 2px solid black;
}
#signUp{
	background-color: #ff4d4d;
	color: white;
	border: none;
	font-weight: bold;
	padding: 15px 32px;
	border-radius: 10px;
	text-align: center;
	text-decoration: none;
	display: inline-block;
	font-size: 13px;
	margin-top: 20px;
	margin-left: 50px;
}
#signIn{
	background-color: #32ff7e;
	color: white;
	font-weight: bold;
	border: none;
	padding: 15px 35px;
	border-radius: 10px;
	text-align: center;
	text-decoration: none;
	font-size: 13px
}
#signOut{
	background-color: #FFA500;
	color: white;
	border: none;
	padding: 12px 32px;
	border-radius: 10px;
	text-align: center;
	text-decoration: none;
	display: inline-block;
	font-size: 13px;
	margin-top: 9px;
	margin-left: 74px;
	font-weight: bold;
}
button: hover{
box-shadow: 0 12px 16px 0 rgba(0,0,0,0.24), 0 7px 50px 0 rgba(0,0,0,0,.19);
}
</style>
</head>
<body>
	<h1>Login Here</h1>
	<div id="formContainer">
		<div id="header"> </div>
  <input type="email" placeholder="Email" id="email">
  <input type="password" placeholder="Password" id="password">

 <button onclick="signUp()" id="signUp"> Sign Up </button>
  <button onclick="signIn()" id="signIn"> Sign In </button>
  <button onclick="signOut()" id="signOut"> Sign Out </button>
Continue</a>
</body>
</html>
Posted by: Guest on November-30-2020
0

Login HTML PHP

<?php 
session_start();
$pdo = new PDO('mysql:host=localhost;dbname=test', 'root', '');
 
if(isset($_GET['login'])) {
    $email = $_POST['email'];
    $passwort = $_POST['passwort'];
    
    $statement = $pdo->prepare("SELECT * FROM users WHERE email = :email");
    $result = $statement->execute(array('email' => $email));
    $user = $statement->fetch();
        
    //Überprüfung des Passworts
    if ($user !== false && password_verify($passwort, $user['passwort'])) {
        $_SESSION['userid'] = $user['id'];
        die('Login erfolgreich. Weiter zu <a href="geheim.php">internen Bereich</a>');
    } else {
        $errorMessage = "E-Mail oder Passwort war ungültig<br>";
    }
    
}
?>
<!DOCTYPE html> 
<html> 
<head>
  <title>Login</title>    
</head> 
<body>
 
<?php 
if(isset($errorMessage)) {
    echo $errorMessage;
}
?>
 
<form action="?login=1" method="post">
E-Mail:<br>
<input type="email" size="40" maxlength="250" name="email"><br><br>
 
Dein Passwort:<br>
<input type="password" size="40"  maxlength="250" name="passwort"><br>
 
<input type="submit" value="Abschicken">
</form> 
</body>
</html>
Posted by: Guest on May-05-2021
-1

login php

<?php 
session_start();
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Login</title>
</head>
<body>
    <form action="" method="POST">
        <input type="password" name="password">
        <button type="submit" name="submit">Login</button>
    </form>
    <?php 
    if(isset($_POST['submit'])){
        if(password_verify($_POST['password'], '$2y$10$sejeRNYZGaoPh1EwfcuO1.hxl/uepQOh9SITWWgeej86vnMt26KIa')){
                        $_SESSION['login'] = true;
          header("Location: http://localhost");
        }
    }
?>
</body>
</html>
Posted by: Guest on December-17-2020
-1

php login

/* na primeira linha usaremos o “action=ope.php” para que o formulário repasse 
as informações para a página ope.php */
<form method="post" action="ope.php" id="formlogin" name="formlogin" >
<fieldset id="fie">
<legend>LOGIN</legend><br />
<label>NOME : </label>
// o campo “name” dentro do input e importante, 
// pois será ele que armazenará os dados digitados . 
<input type="text" name="login" id="login"  /><br />
<label>SENHA :</label>
<input type="password" name="senha" id="senha" /><br />
<input type="submit" value="LOGAR  "  />
</fieldset>
</form>
Posted by: Guest on June-23-2020

Browse Popular Code Answers by Language