How to make a session message appear only when trying to register?

Asked

Viewed 22 times

1

<?php
session_start();
$pdo = new PDO('mysql:host=localhost;dbname=login','root','');
$email = $_POST['email'];
$senha = $_POST['senha'];
$insert = $pdo->prepare('insert into tb_login (email,senha)VALUE (:email,:senha)');
$insert->bindValue(':email',$email);
$insert->bindValue(':senha',$senha);
$insert->execute();
if($insert->rowCount()==0){
    $_SESSION['msg']='Já existe uma conta com esse E-mail ';
    header('location:cadastro.php');
}
else if($insert->rowCount()>0){
    $_SESSION['msg']='Cadastrado com sucesso';
    header('location:cadastro.php');

}
  • Already solved, put an unset and now only appears the message when I click the button.

No answers

Browser other questions tagged

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