I want to pass the URL string data to dashboard.php from login.php here I have just a login auth whereas the data present in the URL is been carried from homepage.php form to login via URL string, I want to carry forward this string to dashboard
The code which gets redirected from dashboard.php for login session for login:
<?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");
}
?>
URL String shown in login.php after redirect:
http://localhost/youngants/login.php?name_=Sharayu%20Bhave&subject_=hello&phone_=9876543210&[email protected]&message_=hh
After the user logs in and redirects to dashbord.php I get a blank URL string and data is not displayed, see below :-
http://localhost/youngants/dashboard.php?name_=&subject_=&phone_=&email_=&message_=
My login code where I pass the same URL again via header(), see below :-
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>";
}
}
My html form from which i take data :-
<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>
I want is to take the above URL from login.php back to dashboard.php and display this data there on dashboard.php. Note, I have only the user id pass auth on login where the URL link carries data from homepage.php.
on login, when redirecting to dashboard your URL is
those variables dont exist. you need to use
$_GET['name_']
etc, the names used in the url