我想将 URL 字符串数据从 login.php 传递到 dashboard.php 这里我只有一个登录身份验证,而 URL 中存在的数据是从 homepage.php 表单携带到通过 URL 字符串登录的,我想继续这个字符串到仪表板
从dashboard.php 重定向到用于登录会话的代码:
<?php
if(!$_SESSION["UserName"])
{
//Do not show protected data, redirect to login...
$FullName = $_REQUEST["name_"];
$Subject = $_REQUEST["subject_"];
$Phone = $_REQUEST["phone_"];
$Email = $_REQUEST["email_"];
$Message = $_REQUEST["message_"];
header("Location: login.php?name_=$FullName&subject_=$Subject&phone_=$Phone&email_=$Email&message_=$Message");
}
?>
重定向后 login.php 中显示的 URL 字符串:
http://localhost/youngants/login.php?name_=Sharayu%20Bhave&subject_=hello&phone_=9876543210&email_=bhave.sharayu@gmail.com&message_=hh
用户登录并重定向到 dashbord.php 后,我得到一个空白的 URL 字符串并且不显示数据,见下文:-
http://localhost/youngants/dashboard.php?name_=&subject_=&phone_=&email_=&message_=
我的登录代码通过 header() 再次传递相同的 URL,见下文:-
if(isset($_POST['login']))
{
$username=$_POST['Username'];
$user_pass=$_POST['password'];
$encrypt_pass = md5($user_pass);
$check_user="select * from tbl_logindetails WHERE UserName='".$username."' AND Password='".$encrypt_pass."'";
$run=mysqli_query($connection,$check_user);
if(mysqli_num_rows($run))
{
//echo "<script>window.open('www.google.com','_self')</script>";
header("Location: dashboard.php?name_=$FullName&subject_=$Subject&phone_=$Phone&email_=$Email&message_=$Message");
$_SESSION['UserName']= $username; //here session is used and value of $user_email store in $_SESSION.
}
else
{
echo "<script>alert( 'Error in Registering Useer, Please try again later' )</script>";
}
}
我从中获取数据的 html 表单:-
<form class="form ajax-contact-form" method="" action="dashboard.php">
<div class="alert alert-success hidden" id="contact-success">
<span class="glyphicon glyphicon-ok "></span>
<strong>Success!</strong> Thank you for your message.
</div>
<div class="alert alert-danger hidden" id="contact-error">
<span class="glyphicon glyphicon-remove "></span>
<strong>Error!</strong> Oops, something went wrong.
</div>
<div class="row col-p10">
<div class="col-sm-6">
<label class="mb10">
<input type="text" name="name_" id="name_" required class="form-control" placeholder=" Full Name * ">
</label>
</div>
<div class="col-sm-6">
<label class="mb10">
<input type="text" name="subject_" id="subject_" required class="form-control" placeholder=" Subject *">
</label>
</div>
</div>
<div class="row col-p10">
<div class="col-sm-6">
<label class="mb10">
<input type="text" name="phone_" id="phone_" class="form-control" placeholder=" Phone">
</label>
</div>
<div class="col-sm-6">
<label class="mb10">
<input type="email" name="email_" id="email_" required class="form-control" placeholder=" Email Address *">
</label>
</div>
</div>
<label>
<textarea name="message_" id="message_" cols="30" rows="10" required class="form-control" placeholder=" Message *"></textarea>
</label>
<div class="mb40"></div>
<div class="clearfix">
<!-- Enter your google site key here for captcha -->
<div class="pull-right xs-pull-left xs-box">
</div>
<div class="pull-left">
<button type="submit" class="btn btn-icon btn-e" value="submit" name="submit"><i class="icon icon_mail_alt"></i> Sumbit</button>
</div>
</div>
</form>
我想要将上面的 URL 从 login.php 带回dashboard.php 并在dashboard.php 上显示这些数据。请注意,我只有用户 ID 在登录时通过身份验证,其中 URL 链接携带来自 homepage.php 的数据。