Jump to content

Recommended Posts

A problem facing i am made some php scripting in localhost(IIS) all the scripting runing but now we install apache server in my machine here php session value are not pass to another page and not giving output

 

here i paste my login scripting

 

<?php

ob_start();

session_start();

 

if($_POST["submit"]!="")

{

$adminame = 'admin@technologies.com';

$adminpass= 'mypassword';

$a=$_POST['username'];

$p=$_POST['password'];

if($adminame==$a && $adminpass==$p)

{

header("location:admin.php");

}

else

{

$link=mysql_connect("localhost","root","");

if(!$link) die("can not connect to mysql");

mysql_select_db("timesheet",$link);

if($_POST["submit"]!="")

{

$username1=$HTTP_POST_VARS['username'];

$password1=$HTTP_POST_VARS['password'];

 

  $sql="select username,password from login where username=='".$_POST['username']."' and

password=='".$_POST['password']."' ";

$result=mysql_query($sql,$link);

 

$row = mysql_fetch_array( $result );

$username = $row['username'];

$password = $row['password'];

 

header("location:bookentry.php");

//$tot=mysql_num_rows($result);

if($username!=$username1 && $password!=$password1)

{

$msg="invalid username or password ";

//z<hr>

//include "notmember.php";

header("Location:memberlogin.php");

}

if($username==$username1 && $password==$password1)

{

$_SESSION['username'] = mysql_result($result, 0, 'username');

echo $_SESSION['username'];

//include "untitled-4.php";

header("location:bookentry.php");

}

 

}

}

}

?>

Link to comment
https://forums.phpfreaks.com/topic/65925-session-problem/
Share on other sites

try this

<?php
ob_start();
session_start();
$adminame = 'admin@technologies.com';
$adminpass= 'mypassword';
$link=mysql_connect("localhost","root","");
if(!$link) die("can not connect to mysql");
mysql_select_db("timesheet",$link);

if($_POST["submit"]!="")
{
$a=$_POST['username'];
$p=$_POST['password'];

if($adminame==$a && $adminpass==$p)
{
	header("location:admin.php");
}

}//end of submit

		if($_POST["submit"]!="")
		{
			$username1=$HTTP_POST_VARS['username'];
			$password1=$HTTP_POST_VARS['password'];

			$sql="select username,password from login where username='".$_POST['username']."' and
			password='".$_POST['password']."' ";
			$result=mysql_query($sql,$link);

			$row = mysql_fetch_array( $result );
			$username = $row['username'];
			$password = $row['password'];

			header("location:bookentry.php");
			//$tot=mysql_num_rows($result);
				if($username!=$username1 && $password!=$password1)
					{
					$msg="invalid username or password ";
					//z//include "notmember.php";
					header("Location:memberlogin.php");
					}
				if($username==$username1 && $password==$password1)
					{
					$_SESSION['username'] = mysql_result($result, 0, 'username');
					echo $_SESSION['username'];
					//include "untitled-4.php";
					header("location:bookentry.php");
					}

		}//end of http submit



?>

Link to comment
https://forums.phpfreaks.com/topic/65925-session-problem/#findComment-329560
Share on other sites

i am login and bo to another page but there i am unable to print name of username which is same table in database 3 columns are (1 username 2 password 3 name ) now i am printing name

 

code is

 

<?php

ob_start();

session_start();

echo $_SESSION['username'];

$link=mysql_connect("localhost","root","");

if(!$link) die("can not connect to mysql");

mysql_select_db("timesheet",$link);

/////////////////////////////////////////fetch/////////////////////////////

$sql1="select name from login where username='".$_SESSION['username']."' ";

$result1=mysql_query($sql1,$link);

$query1=mysql_fetch_array($result1);

 

?>

 

and want to print here name

<form><input name="name" type="text" value=" <?=query1[2]; ?>" size="25" readonly="true"></form>

Link to comment
https://forums.phpfreaks.com/topic/65925-session-problem/#findComment-329575
Share on other sites

Warning: Supplied argument is not a valid MySQL result resource in c:\apache\htdocs\abhishek\timesheet\testse.php on line 17

 

<?php

ob_start();

session_start();

 

$link=mysql_connect("localhost","root","");

if(!$link) die("can not connect to mysql");

mysql_select_db("timesheet",$link);

/////////////////////////////////////////fetch/////////////////////////////

$sql1="select name from login where username='".$_SESSION['username']."' ";

$result1=mysql_query($sql1,$link);

$query1=mysql_fetch_array($result1);

echo "<table border=1>

<tr>

<th>YOUR NAME</th>

 

</tr>";

while($row = mysql_fetch_array($result))

{

 

  echo "<tr><td>";

  echo $row['name'];

    echo "</td></tr>";

  }

echo "</table>";

mysql_close($link);

?>

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/65925-session-problem/#findComment-329623
Share on other sites

plz help as soon as possible

 

<?php

ob_start();

session_start();

 

$link=mysql_connect("localhost","root","");

if(!$link) die("can not connect to mysql");

mysql_select_db("timesheet",$link);

/////////////////////////////////////////fetch/////////////////////////////

$sql1="select name from login where username='".$_SESSION['username']."' ";

$result1=mysql_query($sql1,$link);

//$query1=mysql_fetch_array($result1);

echo "<table border=1>

<tr>

<th>YOUR NAME</th>

 

</tr>";

while($row = mysql_fetch_array($result1))

{

 

  echo "<tr><td>";

  echo $row['name'];

    echo "</td></tr>";

  }

echo "</table>";

mysql_close($link);

?>

 

 

 

 

gives result beboo

Link to comment
https://forums.phpfreaks.com/topic/65925-session-problem/#findComment-330590
Share on other sites

If it's not keeping session data and this is a new php install on apache, you need to make sure that the account that the internet guest is using has write access to the location of the session data that is specified in the php.ini.  That will keep you from saving any session data.

 

Have you set reporting errors to the highest level in php.ini to help determine additional error output for this?

Link to comment
https://forums.phpfreaks.com/topic/65925-session-problem/#findComment-330617
Share on other sites

this is my my php ini setting plz check

 

[session]

; Handler used to store/retrieve data.

session.save_handler = files

 

; Argument passed to save_handler.  In the case of files, this is the path

; where data files are stored. Note: Windows users have to change this

; variable in order to use PHP's session functions.

session.save_path = /tmp

 

; Whether to use cookies.

session.use_cookies = 1

 

 

; Name of the session (used as cookie name).

session.name = PHPSESSID

 

; Initialize session on request startup.

session.auto_start = 0

 

; Lifetime in seconds of cookie or, if 0, until browser is restarted.

session.cookie_lifetime = 0

 

; The path for which the cookie is valid.

session.cookie_path = /

 

; The domain for which the cookie is valid.

session.cookie_domain =

 

; Handler used to serialize data.  php is the standard serializer of PHP.

session.serialize_handler = php

 

; Percentual probability that the 'garbage collection' process is started

; on every session initialization.

session.gc_probability = 1

 

; After this number of seconds, stored data will be seen as 'garbage' and

; cleaned up by the garbage collection process.

session.gc_maxlifetime = 1440

 

; Check HTTP Referer to invalidate externally stored URLs containing ids.

session.referer_check =

 

; How many bytes to read from the file.

session.entropy_length = 0

 

; Specified here to create the session id.

session.entropy_file =

 

;session.entropy_length = 16

 

;session.entropy_file = /dev/urandom

 

; Set to {nocache,private,public} to determine HTTP caching aspects.

session.cache_limiter = nocache

 

; Document expires after n minutes.

session.cache_expire = 180

 

; use transient sid support if enabled by compiling with --enable-trans-sid.

session.use_trans_sid = 1

 

url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"

Link to comment
https://forums.phpfreaks.com/topic/65925-session-problem/#findComment-330665
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.