Jump to content

[SOLVED] Session variables are not transferring.


GB_001

Recommended Posts

My session variables don't seem to be transferring for more than 2 pages.

 

 

Variables only travel between my login code and my member page code, but not through my upload code.

 

Login:

 

<?php

ob_start();


$connect=mysql_connect("localhost","gb_GB","*******")or die(mysql_error());
mysql_select_db("gb_USERInfo",$connect)or die(mysql_error());


$email=$_POST['email'];
$pword= md5($_POST['password']); 
$error="0";

$query="SELECT * FROM Ysers WHERE email='$email' AND password = '$pword' ";
$result=mysql_query($query)or die(mysql_error());

if(mysql_num_rows($result)==0){

$error="Sorry, but either the username or password you entered is not valid.";

}else{

$_SESSION['email']="$email";
$_SESSION['password']="$pword";
setcookie("email","$email",time()+360000);
setcookie("password",md5("$pword"),time()+360000);
include "memberspage.php";

}

if(!empty($error)){

include "Man.html";
print $error;
print $pword;

}


?>

 

Memberpage:

 

<?php
@mysql_connect("localhost", "gb_GB", "********") or die(mysql_error());
@mysql_select_db("gb_USERInfo") or die(mysql_error());
session_start();
if($email&&$pword != NULL){
include('Images.php');
$query="SELECT * FROM Ysers WHERE email = '$email' AND password='$pword'";
$result = mysql_query($query)or die (mysql_error());
$row=mysql_fetch_assoc($result);
$Fname=$row['firstname'];
$Lname=$row['lastname'];
$Ame=$row['aboutme'];
$Irests=$row['interests'];
echo "First Name:";
echo " ";
echo $Fname;
echo "<br>";
echo "Last Name:";
echo " ";
echo $Lname;
echo "<br>";
echo "About"; 
echo ":"; 
echo " "; 
echo $Ame;
echo "<br>";
echo "Interests:";
echo " ";
echo $Irests;
echo "<br>";

}
?>

 

Upload code:

 

 

<?php
@mysql_connect("localhost", "gb_GB", "**********") or die(mysql_error());
@mysql_select_db("gb_USERInfo") or die(mysql_error());

Session_start();

$path = "/home/gb/public_html/Images/";

$imgName = $HTTP_POST_FILES['userfile']['name'];

$max_size = 250000;
if (!isset($HTTP_POST_FILES['userfile'])) exit;
if (is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'])) {
if ($HTTP_POST_FILES['userfile']['size']>$max_size) { echo "The file is too big<br>"; exit; }
if (($HTTP_POST_FILES['userfile']['type']=="image/gif") || ($HTTP_POST_FILES['userfile']['type']=="image/pjpeg") || ($HTTP_POST_FILES['userfile']['type']=="image/jpeg") || ($HTTP_POST_FILES['userfile']['type']=="image/png")) {

$ext = strrchr($imgName, "."); 
$Newname = md5(rand() * time()) . $ext; 

$res = copy($HTTP_POST_FILES['userfile']['tmp_name'], $path .

$HTTP_POST_FILES['userfile']['name']. $Newname);
$MM = $HTTP_POST_FILES['userfile']['name']. $Newname; 

if (!$res) { echo "upload failed!<br>n"; exit; } else { echo "upload sucessful<br>n"; }
echo "File Name: ".$HTTP_POST_FILES['userfile']['name']."<br>n";
echo "File Size: ".$HTTP_POST_FILES['userfile']['size']." bytes<br>n";
echo "File Type: ".$HTTP_POST_FILES['userfile']['type']."<br>n";
} else { echo "Wrong file type<br>n"; exit; }
}
$my_file = $HTTP_POST_FILES['userfile']['name'];

$MN=$_SESSION['email'];
$PN= $_SESSION['password'];
$query = "INSERT INTO Ysers (Picture) where  email ='$MN'  AND password= '$PN'
VALUES ('$MM')";

mysql_query($query) or die(mysql_error());
mysql_close();

?>

Link to comment
Share on other sites

Thankyou, I have one more question pertaining to my

upload code. I'm getting a MySQL 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 'where email ='' VALUES ('c2e94927f3861d3b1c29704fde06e425.jpga6241d57e6d45e6309' at line 1

Link to comment
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.