Ir para conteúdo
Fórum Script Brasil
  • 0

Dúvida, Form Login.


3dmaniaco

Pergunta

Tranquilo Pessoal ?

Eu possuo um form de login, onde o formulario compara o username e a senha com o banco mysql, e caso seja afirmativo, redireciona para a pagina painel.php.

Mas eu gostaria que quando formulario fizesse o login, ele enviasse o ID do usuário que esta fazendo login, e envie pela url o parametro ID.

A url ficaria assim pagina.php?id=1

Esse é o meu formulário, de login, que eu fiz pelo dreamweaver cs4

<?php require_once('../Connections/Abyara.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

mysql_select_db($database_Abyara, $Abyara);
$query_RsListar = "SELECT * FROM cadastro ORDER BY id_cadastro ASC";
$RsListar = mysql_query($query_RsListar, $Abyara) or die(mysql_error());
$row_RsListar = mysql_fetch_assoc($RsListar);
$totalRows_RsListar = mysql_num_rows($RsListar);
?>
<?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['username'])) {
  $loginUsername=$_POST['username'];
  $password=$_POST['senha'];
  $MM_fldUserAuthorization = "";
  $MM_redirectLoginSuccess = "adicionar.php";
  $MM_redirectLoginFailed = "login.php";
  $MM_redirecttoReferrer = false;
  mysql_select_db($database_Abyara, $Abyara);
  
  $LoginRS__query=sprintf("SELECT username, senha FROM cadastro WHERE username=%s AND senha=%s",
    GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); 
   
  $LoginRS = mysql_query($LoginRS__query, $Abyara) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  if ($loginFoundUser) {
     $loginStrGroup = "";
    
    //declare two session variables and assign them
    $_SESSION['MM_Username'] = $loginUsername;
    $_SESSION['MM_UserGroup'] = $loginStrGroup;          

    if (isset($_SESSION['PrevUrl']) && false) {
      $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];    
    }
    header("Location: " . $MM_redirectLoginSuccess );
  }
  else {
    header("Location: ". $MM_redirectLoginFailed );
  }
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<form id="form1" name="form1" method="POST" action="<?php echo $loginFormAction; ?>">
  <table width="100" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td><label>
        <input type="text" name="username" id="username" />
      </label></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td><label>
        <input type="text" name="senha" id="senha" />
      </label></td>
    </tr>
    <tr>
      <td><input type="submit" name="button" id="button" value="Login" /></td>
    </tr>
  </table>
</form>
</body>
</html>
<?php
mysql_free_result($RsListar);
?>

Já tentei fazer de varias formas, mas não deu certo, como posso fazer ?

Desde já, muito obrigado.

Link para o comentário
Compartilhar em outros sites

3 respostass a esta questão

Posts Recomendados

  • 0

Primeiramente ESerra, obrigado pelo retorno.

ESerra, estou tentando alterar aqui, mas não estou conseguindo resolver, se não for pedir muito, você não me faria alteração, para eu entender a lógica, pois ainda estou aprendendo, e eu preciso fazer esse form para aprender.

Se puder colaborar, agradeço desde já.

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,1k
    • Posts
      651,8k
×
×
  • Criar Novo...