I would like help so I can log in using Cpf or cnpj

Asked

Viewed 120 times

0

<?php

// *** Validate request to login to this site.
if (!isset($_SESSION)) {
  session_start();
}

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
  $_SESSION['PrevUrl'] = $_GET['accesscheck'];
}

if (isset($_POST['cnpj'])) {
  $loginUsername=$_POST['cnpj'];
  $password=sha1($_POST['senha']);
  $MM_fldUserAuthorization = "usu_nivel";
  $MM_redirectLoginSuccess = "painel.php";
  $MM_redirectLoginFailed = "erro.php";
  $MM_redirecttoReferrer = false;
  mysql_select_db($database_config, $config);

  $LoginRS__query=sprintf("SELECT cnpj, senha, usu_nivel FROM users WHERE cnpj=%s AND senha=%s",
  GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));

  $LoginRS = mysql_query($LoginRS__query, $config) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  if ($loginFoundUser) {

    $loginStrGroup  = mysql_result($LoginRS,0,'usu_nivel');
    $loginStrGroup2  = mysql_result($LoginRS,0,'nivel_empresa');

    if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
    //declare two session variables and assign them
    $_SESSION['MM_Username'] = $loginUsername;
    $_SESSION['MM_UserGroup'] = $loginStrGroup;
    $_SESSION['nivel_empresa'] = $loginStrGroup2;


    if (isset($_SESSION['PrevUrl']) && false) {
      $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];  
    }
    header("Location: " . $MM_redirectLoginSuccess );
  }
  else {
    header("Location: ". $MM_redirectLoginFailed );
  }
}
?>
  • Hello, where is your question exactly? Mistakes happen? If so, put them along with your question. You can edit your question using the button above or this link: http://answall.com/posts/63372/edit To learn more about the site, I recommend doing the tour: http://answall.com/tour

  • this code I made in Dreamweaver and I am with a login screen, except that this code there is only to enter with cnpj, I already have a register of individuals. Now I want to enter with both (CNPJ and CPF). IE, Cpf will be part of cnpj.

  • 1

    @Maurodenison edits your question with the requested information, instead of posting in the comments, as it facilitates the reading and understanding of your problem. Take advantage, and add what problem you are encountering, as well as error message, etc.

  • Vinicius, I just want you to help me find a solution so that I can enter with Cpf and user password, because cnpj and company password I can already enter, I just want a help because I’m not getting. That’s why I put this code.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.