我在获取URL参数时遇到问题。
错误如下:
注意:未定义索引:链接到 第3行的C:\ xampp \ htdocs + Gesol \ modulos \ login \ form.php
URL的外观如下: http://localhost:82/+Gesol/login/form/ingreso?link=/+Gesol/outdoors-servicios/form/8780
会话代码:
if ($gl_to == "ver"): //VERIFICA QUE EXISTA SESSION
if (!isset($_SESSION['id']) or !isset($_SESSION['empresa']) or !isset($_SESSION['user']) or !isset($_SESSION['nombre']) or !isset($_SESSION['email']) or !isset($_SESSION['gesol'])):
if (isset($Gl_config_cms_url)){
$link = $_SERVER['REQUEST_URI'];
header("Location: ".$Gl_config_cms_url."login/form/ingreso?link=$link");
exit();
}else{
header("Location: ./login/form/ingreso");
exit();
}
endif;
endif;
登录表单代码:
<?php
$link = $_GET['link'];
echo $link;
exit;
session_start();
require_once ("../../../global/-gl-abre-conexion-gesol.php");
require_once ("../../global/gl-funciones.php");
$Gl_accion="INQ"; require_once("../../modulos/configuracion/XML-config.php");
#--- Revisa si esta entrando desde https solo si el sitio tiene https activo en la url
if(substr($Gl_config_cms_url,0,5)=="https"):
if (!isset($_SERVER['HTTPS'])):
header("Location: ".$Gl_config_cms_url."login/form/ingreso");
endif;
endif;
#--- Valida Usuarios
$Gd_error = "";
if (!empty($_POST))
{
if (isset($_POST['user']) and isset($_POST['pass']))
{
require("SQL-login.php");
if ($Gl_existe_user=="N")
{
$Gd_error = "Nombre de usuario y/o contraseña no válido. <br/> ¿<a href='./login/lost/password'>Has olvidado tu contraseña</a>? ";
}else{
$Gl_usuario = $Gd_user_id;
require("../../modulos/usuarios/SQL-tb_gesol_acceso.php");
if ($Gl_existe_miplusAcceso=="S")#---Valida si el usuario tiene acceso a pantallas
{
$gl_to = "crear";
require("../../global/gl-session.php");
header("Location: ".$Gl_config_cms_url."panel/home/");
exit();
}else{
$Gd_error = "Usuario sin privilegios para ingresar al CMS, favor contacte a su proveedor.";
}
}
}else{
$Gd_error = "Ingrese Usuario y contraseña para ingresar al sistema.";
}
}else{
$gl_to = "revisa";
require_once("../../global/gl-session.php");
}
#--- Maneja fondos segun hora del día
$Gd_hora = date("H"); $Gd_fondo = "dia";
if ($Gd_hora>=6)
$Gd_fondo = "dia";
if ($Gd_hora>=13)
$Gd_fondo = "tarde";
if ($Gd_hora>=20 or ($Gd_hora>=1 and $Gd_hora<=5))
$Gd_fondo = "noche";
#---
?>
<!DOCTYPE html>
<html lang="es" class="lockscreen lockscreen-<?=$Gd_fondo?>">
<head>
<meta charset="UTF-8">
<title>GESOL | CRM</title>
<meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
<meta name="description" content="Sistema de Gestión de Solicitudes GESOL">
<meta name="author" content="Tecnología Aplicada y Comunicaciones TAYCO.cl">
<meta name="Generator" content="GESOL" />
<meta name="robots" content="noindex">
<meta name="googlebot" content="noindex">
<link href="<?=$Gl_config_cms_url?>css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
<link href="<?=$Gl_config_cms_url?>css/Gesol.css" rel="stylesheet" type="text/css" />
<link href="<?=$Gl_config_cms_url?>css/images/favicon.ico" rel="shortcut icon">
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="form-box" id="login-box">
<div class="header"><img src="<?=$Gl_config_cms_url?>css/images/logo-gesol-login.png"></div>
<form action="./ingreso" method="post">
<div class="body bg-gray">
<div class="form-group">
<input type="text" name="user" class="form-control" placeholder="Usuario" required="" />
</div>
<div class="form-group">
<input type="password" name="pass" class="form-control" placeholder="Contraseña" required=""/>
</div>
<!--
<div class="form-group">
<input type="checkbox" name="remember_me"/> Recordar
</div>
-->
</div>
<div class="footer">
<button type="submit" class="btn bg-light-blue btn-block">Ingresar</button>
<p class="text-center"><a href="<?=$Gl_config_cms_url?>login/lost/password">Olvide mi Contraseña</a></p>
</div>
</form>
<?php if ($Gd_error!=""):?>
<br/>
<div class="callout callout-danger">
<h4>MIPLUS ERROR</h4>
<p><?=$Gd_error?></p>
</div>
<?php endif;?>
<div class="margin text-center copyright">
<span>MADE WITH <i class="fa fa-heart"></i> IN CHILE BY <b>TAYCO.cl</b></span>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
<script src="<?=$Gl_config_cms_url?>js/bootstrap.min.js" type="text/javascript"></script>
<?php if ($Gd_error!=""):?>
<script src="https://code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
<script type="text/javascript">
$(function() {
$(".form-box").effect("shake");
});
</script>
<?php endif;?>
</body>
</html>
<?php
require_once ("../../../global/-gl-cierra-conexion-gesol.php"); ?>
如您所见,我正在尝试获取包含我需要的URL的“?link = $ link”。 (/+Gesol/outdoors-servicios/form/8780)
答案 0 :(得分:1)
快速解答:
<form action="./ingreso" method="post">
您无法通过$ _GET获得链接,您可能会像$ _POST ['link']一样获得链接(如果您通过<input>
对象将其设置在表单内部。
替代答案
如果您想真正使用$ _GET变量获取它,则应将其编写为:
<form action="./ingreso?link=http://whatyouwanttowrite..." method="post">
您没有从表单发送POST变量链接。您可以像这样手动设置
<input type="hidden" name="link" value="https://www.google.com">
那么您可以通过$ _POST
获得它替代解决方案 使用结合了$ _GET和$ _POST变量的$ _REQUEST。
$link = $_REQUEST['link'];
抑制错误:
您可以输入@来抑制错误。像$link = @$_GET['link'];
答案 1 :(得分:0)
首先显示您的登录表单? 如果是这样,则表格第3行上的$ _GET ['link']不可用。 使其处于混乱状态
答案 2 :(得分:0)
因为它找不到您的$ _GET ['link'],但是在您的表单请求之后您看不到此消息。下面的代码可以帮助您。如Shane所说。
if(isset($_GET['link']))
{
something here...
}