GB_001 Posted December 6, 2007 Share Posted December 6, 2007 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 https://forums.phpfreaks.com/topic/80456-solved-session-variables-are-not-transferring/ Share on other sites More sharing options...
rajivgonsalves Posted December 6, 2007 Share Posted December 6, 2007 you forgot to put session_start(); in your Login page Link to comment https://forums.phpfreaks.com/topic/80456-solved-session-variables-are-not-transferring/#findComment-407919 Share on other sites More sharing options...
revraz Posted December 6, 2007 Share Posted December 6, 2007 session_start() should also be the first thing after your PHP tags. Link to comment https://forums.phpfreaks.com/topic/80456-solved-session-variables-are-not-transferring/#findComment-407965 Share on other sites More sharing options...
GB_001 Posted December 7, 2007 Author Share Posted December 7, 2007 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 https://forums.phpfreaks.com/topic/80456-solved-session-variables-are-not-transferring/#findComment-409114 Share on other sites More sharing options...
revraz Posted December 7, 2007 Share Posted December 7, 2007 Are you UPDATING or Inserting a new row? You are mixing mysql commands. Link to comment https://forums.phpfreaks.com/topic/80456-solved-session-variables-are-not-transferring/#findComment-409119 Share on other sites More sharing options...
GB_001 Posted December 8, 2007 Author Share Posted December 8, 2007 It's a syntax error, even if I change it to updating it still gives me the same error. Link to comment https://forums.phpfreaks.com/topic/80456-solved-session-variables-are-not-transferring/#findComment-409833 Share on other sites More sharing options...
revraz Posted December 8, 2007 Share Posted December 8, 2007 Because you are using WHERE with INSERT So what do you want to do, INSERT a new row or UPDATE an existing one? Link to comment https://forums.phpfreaks.com/topic/80456-solved-session-variables-are-not-transferring/#findComment-409835 Share on other sites More sharing options...
Stooney Posted December 8, 2007 Share Posted December 8, 2007 try this: $query="UPDATE Ysers SET Picture='$MM' WHERE email='$MN' AND password='$PN' LIMIT 1"; Link to comment https://forums.phpfreaks.com/topic/80456-solved-session-variables-are-not-transferring/#findComment-409838 Share on other sites More sharing options...
GB_001 Posted December 10, 2007 Author Share Posted December 10, 2007 Thankyou it worked. Link to comment https://forums.phpfreaks.com/topic/80456-solved-session-variables-are-not-transferring/#findComment-410933 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.