Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

Weird Session issues

$
0
0

Good day, I am having a weird issue with my sessions first of all I have different pages like so:

 

index.php (login screen)

checklogin.php

login_success.php

 

My login_success.php page works fine it will gather the information from the database and display it.

 

On that page I have 2 links 1 is Update and the other one is Upload Pic.

 

When I go to update.php it is returning me all the right information in my input boxes.

 

but If i select the Upload Pic link i have no more session variable.

 

Upload.php that is loaded when upload Pic is clicked (echo $_SESSION['pusername']; will not even return anything)

<?
session_start();
if(!isset($_SESSION['pusername']) ){
	echo "not set";
}

echo $_SESSION['pusername'];
?>
<html>
<body>

<form action="upload_file.php" method="post" enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file"><br>
<input type="submit" name="submit" value="Submit">
</form>

</body>
</html>

the update.php page when i click the link. this one works perfectly

<?
session_start();
if(!isset($_SESSION['pusername']) ){
	echo "not set";
		
}

ob_start();
$host = "";
$username = "";
$password = "";
$db_name = "";
$tbl_name = "";


mysql_connect("$host","$username","$password") or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select db");

$puser = $_SESSION['pusername'];
$sql = "UPDATE $tbl_name SET Pub_companyName = '$_POST[myusername]',Pub_companyEmail = '$_POST[myemail]', Pub_companyWebsite = '$_POST[mywebsite]' WHERE Pub_User = '$puser'";
$result=mysql_query($sql) or die(mysql_error());

$result = mysql_query($sql);

if(!$result){
	die("Error running $sql:" . mysql_error());
}
header("location:/test/functions/login_success.php");
echo " 1 item added ";
?>




Viewing all articles
Browse latest Browse all 13200

Trending Articles