Confirm Code and go to login page

Asked

Viewed 44 times

1

Friends I’m new in PHP + sql help me here :


  --
-- Estrutura da tabela `verified_user`
--

 CREATE TABLE IF NOT EXISTS `verified_user` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `email` text NOT NULL,
  `password` text NOT NULL,
  PRIMARY KEY (`id`)
 ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ;

-- --------------------------------------------------------

--
 -- Estrutura da tabela `verify`
--

 CREATE TABLE IF NOT EXISTS `verify` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `email` text NOT NULL,
  `password` text NOT NULL,
 `code` text NOT NULL,
 PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=29 ;

From the Table above I’m making the call below to try to get the code registered code corresponding, validate , once validated redirect the user to another index2.php page ,,, how can I do this simply in php ? help me if you can

 <form method="post" action="verification.php">
 <input type="text" name="email">
 <input type="password" name="code">
 <input type="submit" name="register" Value="Register">
 </form>

1 answer

0


Create a page called "Verification.php" and put the code below. It will connect to your Database and will select the data registered in the database. Switch the mysql_select_db line there and change the 'do_bank name' to your bank name. don’t forget to leave it in quotes

<?php
//Forma simples
$server = mysql_connect('localhost',root,'');
if($server){
    $banco = mysql_select_db('nome_do_seu_banco');
}
//CAPTURA OS DADOS INFORMADOS NO FORMULÁRIO
$email = $_POST['email'];
$code = $_POST['code'];

$sql = "SELECT * FROM verify WHERE email = '$email' and code = '$code'" ;
$result = mysql_query($sql);
$total = mysql_num_rows($result);

if($total>0){
    //SE ENTROU AQUI, SINAL DE QUE FOI ENCONTRADO 1 REGISTRO PELO MENOS COM O EMAIL E CODIGO DIGITADOS
    //E SE ENCONTROU, SINAL QUE DIGITOU CERTO
    // AI CRIA A SESSÃO E VAI PRA SUA PAGINA;
    session_start();
    $_SESSION['email'] = $email;
    header("location: index2.php"); 
}else{
    //SE ENTROU AQUI, DADOS INCORRETOS, VOLTA PRA PAGINA INDEX
    header("location: index.php");

}

?>
  • thanks friend, I returned the error in the following lines , could you guide me ? Warning: mysql_query(): Access denied for user 'nobody'@'localhost' (using password: NO) in /home/West/public_html/query/confirma.php on line 40 Warning: mysql_query(query): A link to the server could not be established in /home/West/public_html/query/confirma.php on line 40 Warning: mysql_num_rows() expects Parameter 1 to be Resource, Boolean Given in /home/West/public_html/query/confirma.php on line 41

  • $result = mysql_query($sql); $total = mysql_num_rows($result);

  • I decided here thanks very much friend

Browser other questions tagged

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