Click here to Skip to main content
15,797,984 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I succesfuly made the Signup system with the connection to mysql to add new user on the database (username email, name, password hashed) with errors coming with that, but when it comes to the login when I try to submit user information to connect nothing happen and I really don't know why

here is the code :
  $serverName = '***';
  $dbUsername = '***';
  $dbPassword = '***';
  $dbName = '***'; 
  $dbPort = ***;

 $conn = mysqli_connect($serverName,$dbUsername,$dbPassword,$dbName);
  //$mysqli = new mysqli(****);

  echo $conn->host_info;

  echo ' tentative de connection' ;
  if ($conn->connect_error) {
    echo 'Errno: '.$conn->connect_errno;
    echo '<br>';
    echo 'Error: '.$conn->connect_error;
function uidExist($conn, $username, $email)
 $sql = "SELECT * FROM users WHERE userUid = ? OR usersEmail = ? ;";
 $stmt = mysqli_stmt_init($conn);
   header("location: ../signup.php?error=stmtfailed");
 mysqli_stmt_bind_param($stmt,"ss",$username, $email);

 $resultData= mysqli_stmt_get_result($stmt); 

 if($row = mysqli_fetch_assoc($resultData))
  return $row;
   $result = false;
   return $result;


function emptyImputLogin ($username, $pwd){

  $result = "";
  if(empty($username)||empty($pwd)) {
    $result = true;
  }else {
    $result = false;
  return $result;

function loginUser($conn,$username,$pwd){
  $uidExist = uidExist($conn, $username, $username);

  if ($uidExist === false){
    header("location: ../login.php?error=wronglogin");
  $pwdHashed = $uidExist["userPwd"];
  $checkPwd = password_verify($pwd, $pwdHashed);
  if($checkPwd === false){
    header("location : ../login.php?error=wronglogin");
  else if ($checkPwd === true){
    $_SESSION["userid"] = $uidExist["usersid"];
    $_SESSION["useruid"] = $uidExist["userUid"];
    header("location : ../index.php");

ini_set('display_errors', '1');
if (isset($_POST["submit"])){ 

  $username = $_POST["uid"];
  $pwd = $_POST["pwd"];

  require_once '';
  require_once '';

  if(emptyImputLogin( $username, $pwd) !== false ){
    header("location: ../login.php?error=emptyinput "); 

  else {
  header("location: ../login.php");

<?php require 'header.php';?>
<?php require 'includes/';?>
<?php require 'includes/';?>

  <body class="container-fluid" style="background-image: url('empty-photographer-studio-background-abstract-background-texture-of-beauty-dark-and-light-clear-blue-cold-gray-snowy-white-gradient-flat-wall-and-floor.jpg')">
    <h1 class="pullUp m-3 text-center"> The Pull up Theory </h1>

    <!-- Navigation -->

    <section class="signup_form">
      <h2> Log in !</h2>
      <form action="includes/" method="post">
          <input type="text" name="uid" placeholder=" Username">
          <input type="password" name="pwd" placeholder=" Votre mot de passe">
          <button type="submit" name="submit"> Log In </button>
        if($_GET["error"] == "emptyinput"){
          echo "<p class='text-center text-info'> tous les champs doivent être remplis<p>";
        else if ($_GET["error"] == "wronglogin"){
          echo "<p class='text-center text-info'> mot de passe ou nom utilisateur incorrecte <p>";

  include_once "footer.php";


  <h1 class="pullUp m-3 text-center"> The Pull up T</h1>
    <div class=" col-4 col-sm-5 col-xs-6 title mt-2"><a class="navbar-brand text-warning" href="#">
      The Pull Up T <svg xmlns="" width="30" height="30" fill="currentColor" class="bi bi-lightning-charge-fill text-warning" viewBox="0 0 16 16">
      <path d="M11.251.068a.5.5 0 0 1 .227.58L9.677 6.5H13a.5.5 0 0 1 .364.843l-8 8.5a.5.5 0 0 1-.842-.49L6.323 9.5H3a.5.5 0 0 1-.364-.843l8-8.5a.5.5 0 0 1 .615-.09z">
          <svg xmlns="" 
="" width="16" height="16" fill="currentColor" class="bi bi-three-dots-vertical text-warning" viewBox="0 0 16 16">
            <path d="M9.5 13a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0zm0-5a1.5 1.5 0 1 1-3 0 
            1.5 1.5 0 0 1 3 0zm0-5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0z">
      <div class="collapse navbar-collapse" id="navbarSupportedContent">
        <ul class="navbar-nav mr-auto">
          <li class="nav-item active">            <a class="nav-link text-warning" href="index.php">Accueil(current)</a>
          </li>          <li class="nav-item">            <a class="nav-link text-warning" href="Apropos.php">A propos</a>
          </li>                                <a class="nav-link text-warning" href="profile.php"> Profile page</a>
              echo "<li class="nav-item">                      <a class="nav-link text-warning" href="logout.php">Log out</a>
              echo "<li class="nav-item">                      <a class="nav-link text-warning" href="signup.php"> Sign up</a>
                     </li> ";
              echo "<li class="nav-item">                      <a class="nav-link text-warning" href="login.php">Log in</a>
          <li class="nav-item">            <a class="nav-link text-warning" href="contact.php">Contacts</a>
          </li>        </ul>

What I have tried:

I checked if I put session_start(),added error_reporting(E_ALL);
ini_set('display_errors', '1') to help me see what happen but the error message is :
"Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log."
Updated 29-Sep-22 6:57am
Member 15627495 30-Sep-22 11:03am    
$dbport is defined without double quote , look at the db parameters. $dbport = "value";

an internal serv error is 500. no display , because of server run crash.

It's a faulty syntax , quotes missing.
Jordan Nkunga 30-Sep-22 13:46pm    
Thanks for you anwser, I put double quote but still the same errors
Member 15627495 30-Sep-22 16:50pm    
enclose every time you write
<?php .......;;;; ?>

your php require often close tags

    header("location : ../login.php?error=wronglogin",true);    exit(true);

when you use a native php function, check the official website about it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900