Redirect based on input values in PHP? -


i have 2 inputs, 1 named name , other pass. following pseudo code:

if name="name1" , pass="pass1" redirect profil.php 

i have 2 inputs, 1 named: "name", , other: "pass".

fetch fields using either post/get or sessions , use header(); redirection.

an example:

<form method = "post" action = ""> name:<input type = "text" name = "name"> pass:<input type = "text" name = "pass"> <input type = "submit" name = "sub" value = "submit"> </form> 

redirection:

<?php if(isset($_post['sub'])){ $name = $_post['name']; $pass = $_post['pass'];  if($name === 'name1' , $pass === 'pass1'){ header("location:profil.php"); }else echo "credentials not matched."; } ?> 

remember header() must called before other output (that is, before html code or echo).

php manual: header


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -