PHP第二个标签不工作,怎么了?
当我试图注册一个用户名已经存在的用户时,它应该需要_ONCE(“registo.php”),但是它没有进入我的login.php,而是将标题位置重定向到“registo.php?p=registo?e=true”,所以问题出在“index.php”中,但我看不出有什么问题,有什么遗漏吗 register.php index.phpPHP第二个标签不工作,怎么了?,php,tags,Php,Tags,当我试图注册一个用户名已经存在的用户时,它应该需要_ONCE(“registo.php”),但是它没有进入我的login.php,而是将标题位置重定向到“registo.php?p=registo?e=true”,所以问题出在“index.php”中,但我看不出有什么问题,有什么遗漏吗 register.php index.php (需要一次)registo.php 新效用登记处 登记册 首先,这是错误的index.php?p=registo?success=1。只有第一个问号被视为传入
(需要一次)registo.php
新效用登记处
登记册
首先,这是错误的index.php?p=registo?success=1
。只有第一个问号被视为传入参数的指示。之后的每一个问号都被视为字面问号
$query = "SELECT username FROM login WHERE username = '$user'";
$result = mysqli_query($db, $query);
if (!$result) {
echo ' Database Error Occured ';
}
if (mysqli_num_rows($result) == 0) {
$sql = "INSERT INTO `login` (`id`,`username`,`password`) VALUES (NULL, '".$user."', '".$pass."');";
if(!mysqli_query($db, $sql)){
echo 'Não foi possivel salvar os dados!';
}else{
$_SESSION['message'] = 'success';
header("location: index.php?p=registo?success=1");
}
}else{header("location: index.php?p=registo?e=true");}
}else
{
echo 'Os campos não estão definidos!';
}
<div class="container">
<?php
if ( isset($_GET['p']) && $_GET['p']=='registo' || isset($_GET['e']) && $_GET['e']=='true')
{require_once "views/registo.php";
}
else{require_once "views/login.php";}
?>
</div>
<center>
<div class="box_css">
<form class = "form-signin" role = "form" action = "register.php" method = "post" style="max-width:50%">
<h4 class = "form-signin-heading">Registar um Novo Utilizador</h4>
<input type = "text" class = "form-control" name = "reg_username" placeholder = "Nome de Utilizador" required autofocus></br>
<input type = "password" class = "form-control" name = "reg_password" placeholder = "Password" required>
<button style="margin-top: 15px; margin-bottom: 15px;" class = "btn btn-lg btn-primary btn-block hvr-grow-shadow" type = "submit" name = "registo">Registar</button>
</form>
<a href="index.php" style="max-width:50%;" class="btn btn-lg btn-primary btn-block hvr-icon-back">Voltar</a>
</div>
</center>
You Should be pass parameters Like this:
Before : header("location: index.php?p=registo?success=1");
header("location: index.php?p=registo?e=true");
After : header("location: index.php?p=registo&success=1");
header("location: index.php&p=registoe=true");