[英]Insert variable into Header Location PHP 1
The question is: How do i insert the variable $conf_url as a part of the link in line 16: header('Location:' $conf_url.'index_back.php'); 问题是:如何在第16行的链接中插入变量$ conf_url作为标题的一部分:header('Location:'$ conf_url.'index_back.php');
<?php
session_start();
include("conexao.php");
$email = $_POST['email'];
$senha = $_POST['senha'];
$query1 = mysqli_query($con, "SELECT * FROM usuario WHERE email = '$email' AND senha = '$senha'");
$row = $query1->fetch_row();
$_SESSION["iduser"] = $row[0];
$_SESSION["nome"] = $row[2];
$_SESSION["sobrenome"] = $row[3];
$_SESSION["img"] = $row[8];
if($query1->num_rows == 1){
header('Location:' $conf_url.'index_back.php');
//echo "<meta http-equiv='refresh' content='0, url= $conf_url/index_back.php'>";
}else{
$_SESSION['error'] = 'Email e/ou senha invalido(s).';
header('Location: '$conf_url'.'/login.php);
//echo "<meta http-equiv='refresh' content='0, url= $conf_url/login.php'>";
}
?>
config.php
<?php
$conf_url = "http://localhost/production/";
?>
你可以这样做
header("Location: " .$conf_url. "/login.php");
You have simply missed the '.' 您只是错过了'。'。 concatenation mark in both of your
header()
functions, and also messed up the string literals. 两个
header()
函数中的连接标记,也弄乱了字符串文字。
if($query1->num_rows == 1){
header('Location:' . $conf_url . '/index_back.php');
}else{
$_SESSION['error'] = 'Email e/ou senha invalido(s).';
header('Location: ' . $conf_url . '/login.php');
}
Or using variable expansion in double quotes. 或在双引号中使用变量扩展。
if($query1->num_rows == 1){
header("Location: $conf_url/index_back.php");
}else{
$_SESSION['error'] = 'Email e/ou senha invalido(s).';
header("Location: $conf_url/login.php");
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.