0

i am having an error on login form for the field which i carry from another page to login page from URL string, here i have kept a check as

if($_REQUEST['name_']!="")
{
$_SESSION['hidden']=$_REQUEST['name_']; 
}   

but i get a error as

Notice: Undefined index: name_ in C:\xampp\htdocs\youngants\login.php

What can i do to hide this error, as this error comes when the parameter name_ is not passed by user from contact from from home page,

when the user uses the contact from this error doesn't come on login form. but when a user directly comes to login page this error gets displayed.

below is my entire login code

<?php
if(isset($_SESSION["UserName"]))
{
    //Do not show protected data, redirect to login...
    //$fullname = $_REQUEST['name_'];
    //$_SESSION['hidden']=$fullname;
    header('Location: dashboard.php');
    exit();
}
        else        
        {

                                if($_REQUEST['name_']!="")
                                {
                                $_SESSION['hidden']=$_REQUEST['name_'];
                                      //echo $_SESSION['hidden'];   
                                }   

                                        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))  
                                        {  
                                            header("Location: dashboard.php?name_=".$_SESSION['hidden']."&subject_=".$_GET['subject_']."&phone_=".$‌​_GET['phon‌​e_']."&email_=".$_GET['email_']."&message_=".$_GET['message_']);
                                            $_SESSION['UserName']= $username; //here session is used and value of $user_email store in $_SESSION.  
                                        }  
                                        else 
                                        {  

                                          echo "<script>alert( 'Error in Logging Useer, Please try again later' )</script>";  
                                        }  
                                    }
        } 
?>  
chris85
  • 23,846
  • 7
  • 34
  • 51
  • @jbafford sorry can u plz elobrate i dnt get u – Chinmay Bapat Jan 11 '16 at 03:13
  • 1
    `if( isset($_REQUEST['name_']) && $_REQUEST['name_']!="" )` – VolkerK Jan 11 '16 at 03:15
  • I'd use the `!empty`. Note: `empty() does not generate a warning if the variable does not exist.`. Double check that the value isn't a false value for `empty` though http://php.net/manual/en/function.empty.php (e.g. `0`.). – chris85 Jan 11 '16 at 03:23

0 Answers0