Force the opening of a page

0

Next, I'm studying CRUD with PHP and I can not solve a problem ... How do I make PHP open another page if a condition is true?

In case it is a login, where after checking if login and password are correct, I want to redirect the site to another page.

*{margin:0px;padding:0px;}
.cabeca{
	background-color: #006666;
	height:60px;
}

.corpo{
	height:600px;
	background-color: ;
}
.form1{
	height:70px;
	width: 40%;
	margin:0px auto;
	margin-top:200px;
	border:1px solid #ccc;
	padding:30px;
	text-align:center;
}
<!doctype html>
<html lang="pt-br">
	<head>
		<title>N2</title>
		<meta charset="utf-8">
		<link rel="stylesheet" href="css/style.css">
	</head>

	<body>
		<nav class="cabeca">
		</nav>

		<section class="corpo">
			<div class="form1">
				<form action="" method="POST">
						Login <input type="text" name="login"><br>
						Senha <input type="password" name="senha"><br>
						<input type="submit" value="ok"><br>
				</form>
			</div>
		</section>

		<footer class="cabeca">
		</footer>
		
		<?php
			include("conexao.php");
			$login=$_POST["login"];
			$senha=$_POST["senha"];

			$l=mysqli_query($con,"select nome_user from user where cod_user=1");
			$s=mysqli_query($con,"select senha_user from user where cod_user=1");

			$resl=mysqli_fetch_array($l);
			$resS=mysqli_fetch_array($s);




			if($resl[0]==$login && $resS[0]==$senha){
				//abrir uma pagina caso a condição esteja verdadeira;
			
			}
			else{

			}
						
		?>
	</body>
</html>
    
asked by anonymous 12.11.2018 / 09:40

1 answer

0

You can use the header :

header('Location: http://www.example.com/');

In your case:

if($resl[0]==$login && $resS[0]==$senha){
        header('Location: http://teu_dominio/tua_pagina.html/');
}
    
12.11.2018 / 11:55