Link to home
Start Free TrialLog in
Avatar of manoj kumar
manoj kumarFlag for India

asked on

userid not inserted...........

$password=htmlspecialchars($password);
 $sql="SELECT * FROM userregister  WHERE username='$username' and password='$password'";
$result=mysql_query($sql)OR die("Error:".mysql_error());

$row=mysql_num_rows($result);
$userinfo=mysql_fetch_assoc($result);
 $role=$userinfo['role'];
 
 if($row==1){

     $_SESSION['login_user']=$username;
       $_SESSION["userid"] = $id;
  $queryString = "INSERT INTO  admin (userid, intime) VALUES ('{$row[id]}', NOW())";

afterlogin when i isert userid and login time in admin table,,logintime is inserted but userid is showning 0 for all the user:
My Table stucture is
Admin table :
id:
userid:
logintime:
logouttime:
my usertable contain :
id:
username:
password:
role:
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

try:

 $queryString = "INSERT INTO  admin (userid, intime) VALUES ('$id', NOW())";
Avatar of manoj kumar

ASKER

not working sql query same issue  is there
try echo it out and see what you get?

$queryString = "INSERT INTO  admin (userid, intime) VALUES ('$id', NOW())"; 
echo $queryString;

Open in new window

it inserted null,i donot understand why it nserted null help me
it inserted null,i donot understand why it nserted null help me
so in your existing codes, try check where you assign value to $id
i am giving the attachment .when user login it go to authenticate.php after suceesfully authentication user logintime is inserted into database...plz see my code
and my logout.php



<?php
include_once("database-config.php");
      session_start();
      

      $strDateNew=date("d-m-Y H:i:s");
 
      $queryString = "update admin set outtime=NOW()  WHERE  userid = '{$row[id]}' and intime='$strDateNew' ";
        $result1=mysql_query($queryString)OR die("Error:".mysql_error());
  echo "$queryString";
   if(session_destroy())
   {
    header('Location: index.php');
   }
      
   
      
?>
i think this area become problem in authenticate.php
$_SESSION['login_user']=$username;
       $_SESSION['userid'] = $row['id'];
 
$queryString = "INSERT INTO  admin (userid, intime) VALUES ('{$row[id]}', NOW())";
  $result1=mysql_query($queryString)OR die("Error:".mysql_error());
 $row1=mysql_num_rows($result1);
plz see
if $_SESSION['userid'] = $row['id']; is a valid statement in which $row['id'] contains a non-zero value, then you can try:

... VALUES ('".$row[id]."', NOW())";

$queryString = "INSERT INTO  admin (userid, intime) VALUES ('".$row[id]."', NOW())";

Open in new window

WHAT WAS THE OUTPUT FROM RYAN's REQUEST
$queryString = "INSERT INTO  admin (userid, intime) VALUES ('$id', NOW())"; 
echo $queryString;

Open in new window


Please post the result from that.

Now look at your code
$row=mysql_num_rows($result);
$userinfo=mysql_fetch_assoc($result);
 $role=$userinfo['role'];
 
 if($row==1){

     $_SESSION['login_user']=$username;
       $_SESSION["userid"] = $id;
  $queryString = "INSERT INTO  admin (userid, intime) VALUES ('{$row[id]}', NOW())";

Open in new window


$row=mysql_num_rows($result); // GET NUMBER OF ROWS
$userinfo=mysql_fetch_assoc($result); // GET THE USER DATA

BUT!!!!!
  $queryString = "INSERT INTO  admin (userid, intime) VALUES ('{$row[id]}', NOW())";
You are using the $row value and not the $userinfo value????
can u modlified my authenticate.php and send it
actually i am editing my code bbut same issue is there
You are using the $row value and not the $userinfo value????
nice catch Julian :)

so manoj probably forgot to put this line of code:

$id =$userinfo['id']; //assuming the field to get named as "id"

Open in new window


another possible way is using this statement directly:
$queryString = "INSERT INTO  admin (userid, intime) ".
               "SELECT id, Now() FROM userregister  WHERE username='$username' and password='$password' ";

Open in new window

Just change the $row['id'] in your query to $userinfo['id']
$password=htmlspecialchars($password);
$sql="SELECT * FROM userregister  WHERE username='$username' and password='$password'";
$result=mysql_query($sql)OR die("Error:".mysql_error());

$row=mysql_num_rows($result);
$userinfo=mysql_fetch_assoc($result);
 $role=$userinfo['role'];
 
 if($row==1){

     $_SESSION['login_user']=$username;
       $_SESSION["userid"] = $id;
  $queryString = "INSERT INTO  admin (userid, intime) VALUES ('{$userinfo[id]}', NOW())";

Open in new window

air it show:
Notice: Undefined variable: id in C:\xampp\htdocs\test\authenticate.php on line 27($_SESSION["userid"] = $id;)

Notice: Use of undefined constant id - assumed 'id' in C:\xampp\htdocs\test\authenticate.php on line 28($queryString = "INSERT INTO  admin (userid, intime) VALUES ('{$userinfo[id]}', NOW())";);
Thanks Ryan Chong and  Julian Hansen: for solving my issue
 thanks a lot
Missing quotes around the 'id' index.

$password=htmlspecialchars($password);
$sql="SELECT * FROM userregister  WHERE username='$username' and password='$password'";
$result=mysql_query($sql)OR die("Error:".mysql_error());

$row=mysql_num_rows($result);
$userinfo=mysql_fetch_assoc($result);
 $role=$userinfo['role'];
 
 if($row==1){

     $_SESSION['login_user']=$username;
       $_SESSION["userid"] = $id;
  $queryString = "INSERT INTO  admin (userid, intime) VALUES ('{$userinfo['id']}', NOW())";

Open in new window

my logout.php when user logout it store 0000-00-00 00:00:00
my logout.php
<?php
include_once("database-config.php");
      session_start();
      

      $strDateNew=date("d-m-Y H:i:s");
 
      $queryString = "update admin set outtime=NOW()  WHERE  userid = '$session[userid]'  and intime='$strDateNew' ";
        $result1=mysql_query($queryString)OR die("Error:".mysql_error());
  echo "$queryString";
   if(session_destroy())
   {
    header('Location: index.php');
   }
      
   
      
?> plz help me
i am modify my sql query to
$queryString = "update admin set outtime=NOW()  WHERE  userid = '{$userinfo['id']}'  and intime='$strDateNew' ";
I don't understand your code.

You have this
$strDateNew=date("d-m-Y H:i:s");

Open in new window

Then you have this
$queryString = "update admin set outtime=NOW()  WHERE  userid = '$session[userid]'  and intime='$strDateNew' ";

Open in new window

Where is intime being set in the Database?
I can't see that this query will EVER work.
$strDateNew will be set to '2018-01-12 12:02:01';
1 second later this value will change
Unless you set intime and then within 1 second (max) you run the query - it is not going to work.
sorry:
i will explain it bettrer
i  have logout page where user logout userlogout time will store in mysql database,so i am writing logout.php
<?php
include_once("database-config.php");
      session_start();
       $strDateNew=date("d-m-Y H:i:s");//declare the datatime
      $queryString = "update admin set outtime=NOW()  WHERE  userid = '{$userinfo['id']}'  and intime='$strDateNew' ";(//sql query if user click logout then logout time will store in databse with  which user login and logout))
 $result1=mysql_query($queryString)OR die("Error:".mysql_error());
   if(session_destroy())
   {
    header('Location: index.php');
   }
?>[/b]
PLEASE .... USE ... CODE ... TAGS!!!!!!!

Still does not make sense. I know what you are trying to do but the way you are doing it does not seem right.
This will set $strDateNew to the CURRENT TIME
 $strDateNew=date("d-m-Y H:i:s");//declare the datatime 

Open in new window

This will have NO EFFECT
$queryString = "update admin set outtime=NOW()  WHERE  
userid = '{$userinfo['id']}'  and 
intime='$strDateNew' ";

Open in new window

It is saying only update records where the intime is ALREADY SET TO THE CURRENT TIME (TO THE SECOND)

It is not going to work!
dear sir
how to solve it please send me code
regards
manoj
how to solve it please send me code
I need to know what you are expecting?

Are you storing a login / logout record for every login / logout event?

I would probably do something like this: NOTE: I am using HEREDOC notation here

$queryString = <<< QUERY
UPDATE
  `admin`
   SET `outtime`=NOW()
   WHERE 
     `userid` = '{$userinfo['id']}' AND 
     `outtime` is NULL
QUERY;

Open in new window

This assumes that your database is setup to put NULL into outtime when you create the record at login.

When you logout - it finds the record that matches the userid and where no outtime has been set.

However, this may be flawed in that there may be records from earlier sessions where a login was done but not a logout - so you need to get around those. You can do it like this
$queryString = <<< QUERY
UPDATE `admin` 
	SET
         `outtime`=NOW()
WHERE  
	`userid` = '{$userinfo['id']}' AND 
	`id` IN (
		SELECT max(`id`) 
		FROM `admin` 
		WHERE `userid` = '{$userinfo['id']}')
QUERY;

Open in new window

What this code does is finds the last record for the user based on record id and sets the outtime on that.

WARNING: NOTE: I have made the assumption that your admin table has an autoincrement column called id. If this is not the case then the above will not work.

PLEASE UPDATE THE ABOVE CODE ACCORDINGLY
This is my code
<?php
include_once("database-config.php");
      session_start();
       $strDateNew=date("d-m-Y H:i:s");//declare the datatime
      $queryString = "update admin set outtime=NOW()  WHERE  userid = '{$userinfo['id']}'  and intime='$strDateNew' ";
 $result1=mysql_query($queryString)OR die("Error:".mysql_error());
   if(session_destroy())
   {
    header('Location: index.php');
   }
?>[/b]
PLEASE, PLEASE, PLEASE Use code tags
User generated image
I don't know what you are asking in your last post. You don't seem to have used any of the suggestions I made in my last post.
Sorry sir:
actually how to use this tool some issue is there so i am give my attachment
this is my logout.php
<?php
include_once("database-config.php");
      session_start()
;
      
       $queryString ="UPDATE admin SET outtime=NOW() WHERE userid = '{$userinfo['id']}' AND id IN (SELECT max(`id`) FROM admin WHERE userid = '{$userinfo['id']}'";
      $result1=mysql_query($queryString)OR die("Error:".mysql_error());
      
    echo "$queryString";
   
?>
actually how to use this tool some issue is there so i am give my attachment
Manoj, it is very simple.
1. Paste your code in the comment box
2. Highlight the code (select it)
3. Press the CODE button.

I have no idea what you want me to do with your last post. You posted code but no comment so I don't know if it is working or if there was an error.

I suspect your problem is here
$userinfo['id']
You have not defined that anywhere. I am guessing you need to do this
<?php
session_start();
include_once("database-config.php");
$id = $_SESSION["userid"];      
$queryString ="UPDATE admin SET outtime=NOW() WHERE userid = '{$id}' AND id IN (SELECT max(`id`) FROM admin WHERE userid = '{$id}'";
$result1=mysql_query($queryString)OR die("Error:".mysql_error());

echo "$queryString";

Open in new window

It's give Error
Error:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
Here After Solving The Error Gain It Give


Error:You can't specify target table 'admin' for update in FROM clause
help me plzzzzzzzzzzzzzzzzzzzzzz
What was the query that was executed?

Dump it to the screen and post it here

Always show us what you tried to execute - otherwise you are asking us to guess - which is a bad idea
i am try to Excute ThisQuery $queryString ="UPDATE admin SET outtime=NOW() WHERE userid = '{$id}' AND id IN (SELECT max(`id`) FROM admin WHERE userid = '{$id}')";
but Eoor Is there say Error:You can't specify target table 'admin' for update in FROM clause
Change query to
$queryString = <<< QUERY
UPDATE
  `admin`
SET
  `outtime`=NOW()
WHERE
  `userid` = '{$id}' AND
  `id` = (SELECT `maxid` FROM (SELECT MAX(`id`) `maxid` FROM `admin` WHERE `userid` = '{$id}') AS A)
QUERY;

Open in new window

@manoj

you can provide the data dictionary of your tables with some sample data for better understanding.

if userid and id in table: admin are both unique, then we should use only either one for record updating.

what Julian provided earlier of statement below I guess should worked:

$queryString = <<< QUERY
UPDATE
  `admin`
   SET `outtime`=NOW()
   WHERE
     `userid` = '{$userinfo['id']}' AND
     `outtime` is NULL

QUERY;

have you tried above?
@Ryan
what Julian provided earlier of statement below I guess should worked:
It will but consider this situation.

User logs in - record is created and outtime is NULL intime is today 2018-01-13 12:00:00

User does not log out.

User logs in from different workstation.
A second record is created with intime 2018-01-13 15:00

Now there are two record in the database with outtime 2018-01-13 15:00

This may be ok from the users perspective but it may not.

By linking to the max(id) you should get the last record written which is the one you would want to map to.
@Julian

that's make sense... and we shall use max(id) to get last entry for that particular user.

@manoj

in some scenario, we could also introduce a "Session ID" (a unique key) to be generated and saved into db to represent/differentiate the current Session. And update record based on this value. This was what i have done for some web applications for my clients.
Good Morning Sir, Table for admin
CREATE TABLE IF NOT EXISTS `admin` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `userid` int(11) NOT NULL,
  `intime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `outtime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=206 ;


Table for User

CREATE TABLE IF NOT EXISTS `user` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `role` varchar(10) NOT NULL,
  `username` varchar(40) NOT NULL,
  `password` varchar(40) NOT NULL
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;

But Your Syntaxt Give Error As:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'outtime`=NOW() WHERE userid = '3' AND id = (SELECT `maxid` FROM (SELECT M' at line 1
Thank U sir:
Insted Of Showing Userid in FrontEnd Page I wants to Show Username

That Shoud Be This Like :
ID,      User_ID,      Logintime,      Logout_Time,
207      manoj      1/24/2018 10:23      1/24/2018 10:23
207      Kumar      1/24/2018 10:23      1/24/2018 10:23
In My Sql
IN Admin Table Logintime is Correct But LOgout Time Shot it 000-000-00-00 00:00:00 This Formmat Why
Insted Of Showing Userid in FrontEnd Page I wants to Show Username

That Shoud Be This Like :
ID,      User_ID,      Logintime,      Logout_Time,
207      manoj      1/24/2018 10:23      1/24/2018 10:23
207      Kumar      1/24/2018 10:23      1/24/2018 10:23
this is confusing if you're refer to table Admin, in the case you got:

  `userid` int(11) NOT NULL

your table expecting an integer value for userid while you trying to save it as char??
or userid in Admin is referring to the Id in user ?
so how can i display usnername in FronEnd Page So That  which user Hvae Login and Logot time Display in Proper Manner,Plz Suggest me ,So that Result Will Be UserFriendly Plz Help me
I want This Format Result :
id       username       intime                             outime
242       manoj         1/24/2018 10:23      1/24/2018 10:23
243              Kumar         1/24/2218 10:23      1/24/2018 10:22
sir plz help me
i am waiting for your Replay
can you answer my questions below first?

ID: 42434518

ID: 42434519
This is id.and it's Type is Double:
i cannot understad your Question Plz Explain Me
Let me try again.
1. Highlight your code
2. Click the CODE button not the B button.
Please please please please use the CODE button.

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'outtime`=NOW() WHERE userid = '3' AND id = (SELECT `maxid` FROM (SELECT M' at line 1
What was your full query - you have just posted the error you received for the query but to help you we need to see the FULL query.
I am Beginner Of Php from last 1 Month:So i am getting this problem :
Lets See This Code In Jsp,What I Am writing :
<%@ page import="java.sql.*,java.util.*,java.text.*,java.text.SimpleDateFormat" %>
<html>
<head>
<TITLE>Login Application</TITLE>
</head>
<body>
<br><br>
<table align="center" width="400px" border=0>
      <%
      if(session.getAttribute("username")!=null && session.getAttribute("username")!="")
      {
      %>
            <tr>
                  <td align="right" width="350"><a href="home.jsp">Home</a></td>
                  <td align="right"><a href="logout.jsp">Logout</a></td>
            </tr>
      <%
      }
      else
      {
      %>
      <tr>
            <td align="right" width="350"><a href="home.jsp">Home</a></td>
            <td align="right"><a href="login.jsp">Login</a></td>
      </tr>
      <%
      }
      %>
</table>

<table width="400px" align="center" border=0>

      <tr style="background-color:#D9B0D8;">
            <td align="center"><b>User Id</b></td>
            <td align="center"><b>Username</b></td>
            <td align="center"><b>Login</b></td>
            <td align="center"><b>Logout</b></td>
      </tr>
<%

System.out.println("MySQL Connect Example.");
Connection conn = null;
String url = "jdbc:mysql://localhost:3306/user_register";
String username = "root";
String userPassword = "";
String user = "";

try
{
      Class.forName("com.mysql.jdbc.Driver").newInstance();
      conn = DriverManager.getConnection(url,username,userPassword);
      Statement st = conn.createStatement();
      Statement st1 = conn.createStatement();
      String queryString = "select * from admin order by userid";
      ResultSet rs = st.executeQuery(queryString);
      ResultSet rs1=null;
      String queryStringuser="";
      SimpleDateFormat sdfDestination=null;
      int count=0;
      String strcolor = "";
      while(rs.next())
      {
            count = count%2;
            if(count==0)
            {
                  strcolor = "#D9D9D9";
            }
            else
            {
                  strcolor = "#EFEFEF";
            }
            count++;
            queryStringuser = "select * from userregister where id="+rs.getInt(2);
            rs1 = st1.executeQuery(queryStringuser);
            while(rs1.next())
            {
                  user  = rs1.getString(2);
            }

            String inStr="";
            String outStr="";
            java.util.Date date;
            String intime="";
            String outtime="";
            if((rs.getString(3)!=null && rs.getString(3)!=""))
            {
                  inStr = rs.getString(3).toString().substring(0,rs.getString(3).toString().indexOf("."));
                  try
                  {
                        date = new  SimpleDateFormat("yyyy-MM-dd hh:mm:ss").parse(inStr);
                        sdfDestination = new SimpleDateFormat("MMM dd, hh:mm:ss");
                        intime = sdfDestination.format(date);
                  }
                  catch (Exception e)
                  {
                        e.getMessage();
                  }
            }

            if((rs.getString(4)!=null && rs.getString(4)!=""))
            {
                  outStr = rs.getString(4).toString().substring(0,rs.getString(3).toString().indexOf("."));
                  try
                  {
                        date = new  SimpleDateFormat("yyyy-MM-dd hh:mm:ss").parse(outStr);
                        sdfDestination = new SimpleDateFormat("MMM dd, hh:mm:ss");
                        outtime = sdfDestination.format(date);
                  }
                  catch (Exception e)
                  {
                        e.getMessage();
                  }
            }
            %>
            <tr style="background-color:<%=strcolor%>;"><td align="center"><%=rs.getInt(2)%></td><td align="left" style="padding-left:10px;"><%=user%></td><td align="center"><%=intime%></td><td align="center"><%=outtime%></td></tr>
            <%
      }
      conn.close();
}
catch (Exception e)
{
      e.printStackTrace();
}
%>

i know java But In This Time I AM in Php:so i am getting this type of issue
Your one question is there in php hot to convert int to char :but in java it is possible because we can type cast int to char,
because Int 4 byte and char 2 so we can use winding if u converrt double to int it is possible in java use Narrowing
Please please please please use the CODE button.
I think you need read this as well: (click the [?] button in your comment editor)
http://support.experts-exchange.com/customer/portal/articles/2421387
Dear Julian
 Actually Application Working fine but i need some change to Display the Result:
User generated imageBut i Unable to do that:instead of username my result display userid:i donot want userid i want username
Thanks Jullian
Dear Ryan Chong
You Think That I donot Know php,it's Absolutely correct because i am java developer from 1.8 years,but this time this project is going to php:
and i donot have any project so i am doing in php:and i am getting this type of issue:Lets See This code In Java:<%@ page import="java.sql.*,java.util.*,java.text.*,java.text.SimpleDateFormat" %> <html> <head> <TITLE>Login Application</TITLE> </head> <body> <br><br> <table align="center" width="400px" border=0> <% if(session.getAttribute("username")!=null && session.getAttribute("username")!="") { %> <tr> <td align="right" width="350"><a href="home.jsp">Home</a></td> <td align="right"><a href="logout.jsp">Logout</a></td> </tr> <% } else { %> <tr> <td align="right" width="350"><a href="home.jsp">Home</a></td> <td align="right"><a href="login.jsp">Login</a></td> </tr> <% } %> </table> <table width="400px" align="center" border=0> <tr style="background-color:#D9B0D8;"> <td align="center"><b>User Id</b></td> <td align="center"><b>Username</b></td> <td align="center"><b>Login</b></td> <td align="center"><b>Logout</b></td> </tr> <% System.out.println("MySQL Connect Example."); Connection conn = null; String url = "jdbc:mysql://localhost:3306/user_register"; String username = "root"; String userPassword = ""; String user = ""; try { Class.forName("com.mysql.jdbc.Driver").newInstance(); conn = DriverManager.getConnection(url,username,userPassword); Statement st = conn.createStatement(); Statement st1 = conn.createStatement(); String queryString = "select * from admin order by userid"; ResultSet rs = st.executeQuery(queryString); ResultSet rs1=null; String queryStringuser=""; SimpleDateFormat sdfDestination=null; int count=0; String strcolor = ""; while(rs.next()) { count = count%2; if(count==0) { strcolor = "#D9D9D9"; } else { strcolor = "#EFEFEF"; } count++; queryStringuser = "select * from userregister where id="+rs.getInt(2); rs1 = st1.executeQuery(queryStringuser); while(rs1.next()) { user = rs1.getString(2); } String inStr=""; String outStr=""; java.util.Date date; String intime=""; String outtime=""; if((rs.getString(3)!=null && rs.getString(3)!="")) { inStr = rs.getString(3).toString().substring(0,rs.getString(3).toString().indexOf(".")); try { date = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").parse(inStr); sdfDestination = new SimpleDateFormat("MMM dd, hh:mm:ss"); intime = sdfDestination.format(date); } catch (Exception e) { e.getMessage(); } } if((rs.getString(4)!=null && rs.getString(4)!="")) { outStr = rs.getString(4).toString().substring(0,rs.getString(3).toString().indexOf(".")); try { date = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").parse(outStr); sdfDestination = new SimpleDateFormat("MMM dd, hh:mm:ss"); outtime = sdfDestination.format(date); } catch (Exception e) { e.getMessage(); } } %> <tr style="background-color:<%=strcolor%>;"><td align="center"><%=rs.getInt(2)%></td><td align="left" style="padding-left:10px;"><%=user%></td><td align="center"><%=intime%></td><td align="center"><%=outtime%></td></tr> <% } conn.close(); } catch (Exception e) { e.printStackTrace(); } %> I am Java Developer not php but project in java knot there so i am geeting issue:
ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks Ryan
It's Working Fine
I Am Trying to Change Password
This Is My Code For Changing The Password:
<?php
require_once 'database-config.php';
if(count($_POST)>0) {
	$_SESSION["id"]=$id;
$result = mysql_query("SELECT * from userregister WHERE id='" . $_SESSION["id"] . "'");
 $row=mysql_fetch_array($result);
  if($_POST["currentPassword"] == $row["password"]) {
  mysql_query("UPDATE userregister set password='" . $_POST["newPassword"] . "' WHERE id='" . $_SESSION["id"] . "'");
  $message = "Password Changed";
} else $message = "Current Password is not correct";
}
?>

Open in new window

But I am geeting Error:Undefined variable: id in C:\xampp\htdocs\change_password.php on line 4
But I am geeting Error:Undefined variable: id in C:\xampp\htdocs\change_password.php on line 4
this is quite obvious...  have you define variable $id before you refer to it?

$_SESSION["id"]=$id;

it seems that we are talking the same issue again. if you're using it, you need to define it first... like:
$id = "somevalue";

Open in new window

How to Solve it:i tried use Session id:but issue is there:same Error
I got it:and solved
Thanks For Suggesting me
best solutions