Jump to content

db530

Members
  • Posts

    25
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

db530's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Ok I was able to get it to pull the userid in the checklogin but I can't get it on the other page.
  2. I understand the query fine just not this whole _SESSION thing...
  3. so when I do $row['userid'] does that get the value in the field 'userid' I'm confused
  4. Here's my code on the login check page <?php $host="*******"; // Host name $username="*******"; // Mysql username $password="*******"; // Mysql password $db_name="*******"; // Database name $tbl_name="members"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("Cannot connect to database..."); mysql_select_db("$db_name")or die("Cannot select database..."); // username and password sent from form $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; // To protect MySQL injection (more detail about MySQL injection) $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); $sql="SELECT userid FROM $tbl_name WHERE name='$myusername' AND password='$mypassword'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row $row = mysql_fetch_assoc($result); // Store user id in session variable $_SESSION['userid'] = $row['userid']; if($count==1){ // Register $myusername, $mypassword and redirect to file "login_success.php" session_register("myusername"); session_register("mypassword"); header("location:draft.php"); //echo "$_SESSION[user]"; } else { echo "Wrong Username or Password"; } ?> </body> </html>
  5. Thanks what was UserData supposed to be?
  6. Thanks, can you give me an example how to do this please?
  7. I'm still pretty new to PHP and actually haven't done it in a while so I'm a little rusty but here's my problem: I have a login screen (that works) that goes to a screen with a form. I need to be able to get the user id of the user that's logged in so I can use it to query the database and insert the data in the form into the correct row of the table. I know it's a pretty simple thing to do I'm just blanking right now. Can anyone point me in the right direction?
  8. PFMaBiSmAd, it looks like I got it! Thanks a lot for the help!
  9. Thanks for the reply. By trying to do something I mean add a product or a category to the database. I'm pretty sure it's built off of OScommerce. As for a little while, I mean about 10 seconds. Usually happens when I click a link such as add a product it'll start to go for a few seconds then send me back to the log in screen. I have a folder "tmp" on my domain space. I know that's the default though so I guess it could be a folder on the entire server too. Can you tell me specifically how to do this? Thanks again.
  10. I don't think that's it although I will have to change that. It's usually only a few seconds. Any other ideas? Thanks for the reply NEW PHP INFO Session Support enabled Registered save handlers files user sqlite Registered serializer handlers php php_binary wddx Directive Local Value Master Value session.auto_start Off Off session.bug_compat_42 On On session.bug_compat_warn On On session.cache_expire 1200 1200 session.cache_limiter nocache nocache session.cookie_domain no value no value session.cookie_httponly Off Off session.cookie_lifetime 0 0 session.cookie_path / / session.cookie_secure Off Off session.entropy_file no value no value session.entropy_length 0 0 session.gc_divisor 100 100 session.gc_maxlifetime 1440 1440 session.gc_probability 1 1 session.hash_bits_per_character 4 4 session.hash_function 0 0 session.name PHPSESSID PHPSESSID session.referer_check no value no value session.save_handler files files session.save_path /tmp /tmp session.serialize_handler php php session.use_cookies On On session.use_only_cookies On On session.use_trans_sid 0 0
  11. I have an admin section to my site, when I log in it will usually work fine for a little while then usually when I try to do something it logs out. I assume it's because it's not seeing the session: session_start(); if (!isset($_SESSION['ad_logged_in'])){ header("Location:login.php"); //redirects to login exit(0); } I don't see anything in the .ini file that would stop it but I don't know much about sessions: Session Support enabled Registered save handlers files user sqlite Registered serializer handlers php php_binary wddx Directive Local Value Master Value session.auto_start Off Off session.bug_compat_42 On On session.bug_compat_warn On On session.cache_expire 180 180 session.cache_limiter nocache nocache session.cookie_domain no value no value session.cookie_httponly Off Off session.cookie_lifetime 0 0 session.cookie_path / / session.cookie_secure Off Off session.entropy_file no value no value session.entropy_length 0 0 session.gc_divisor 100 100 session.gc_maxlifetime 1440 1440 session.gc_probability 1 1 session.hash_bits_per_character 4 4 session.hash_function 0 0 session.name PHPSESSID PHPSESSID session.referer_check no value no value session.save_handler files files session.save_path /tmp /tmp session.serialize_handler php php session.use_cookies On On session.use_only_cookies Off Off session.use_trans_sid 0 0 Can anyone PLEASE give me some advice? I think I've got the problem narrowed down but I know very little about sessions so I don't know what to do. Thanks in advance.
×
×
  • 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.