Jump to content

Wemperer

New Members
  • Posts

    5
  • Joined

  • Last visited

Wemperer's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Ok I was under the impression that SESSION relied on COOKIES. Apparently they CAN work together but session is sufficient enough.
  2. Is it because its not all in the same script? The cookie is set by index.php and it attempted to be accessed by testcookie.php. They're both in the same directory...
  3. Thank you so much! I still can't seem to make the second script recognize the cookie though.
  4. I'm trying to create a login script but I can't figure out how to pull the data out of a $_COOKIE and how cookies work with $_SESSION. Basically I have this //pull data from database $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; //store in the database strip for sql injection $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); //query database, check to see if username and password exist there / encrypt $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password=SHA('$mypassword')"; $result=mysql_query($sql); $count=mysql_num_rows($result); //if it exists, register the session with the username nad password, then set a cookie if($count==1) { $_SESSION("myusername"); $_SESSION("mypassword"); setcookie("username","$myusername",0); header("location:cookietest.php"); } else { echo "Wrong Username or Password"; } Then inside my cookietest.php.. if(isset($_SESSION['username'])) echo "session varible set and "; else echo "session varibale not set and "; if(isset($_COOKIE['username'])) echo "cookie is set"; else echo "cookie is not set"; Even thogh I can see int he browser that the cookie was created I get "session varible not set and cookie is not set"
  5. I've been trying to follow this tutorial: http://www.youtube.com/watch?v=YqPp8EzjCMY but I just can't get it to work. When I click a link, the URL updates with ?p=contactus or whatever but no content is loaded on the page or the page doesn't change. Messing around with the directory, the entire page will change if my files are all IN THE SAME FOLDER but I can't for the life of me figure out how this guys code only changes a portion of the page and how hes accessing php files in different folders.
×
×
  • 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.