Jump to content

db530

Members
  • Posts

    25
  • Joined

  • Last visited

    Never

Everything posted by db530

  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.
  12. Can you please tell me where it would go then? I'm new to this.
  13. Here is my connect function, it calls mysql_select_db....Is there any other code I should post? function dbcon(){ global $host, $user, $pass, $db,$link; if(!($link=mysql_connect($host,$user,$pass))) { sprintf("Internal error %d %s",mysql_errno(),mysql_error()); return 0; } else { return 1; mysql_select_db($db); }
  14. Thanks. When I check for the error I get "No database selected", I have to use the IP as the host. It's right along with the username, password, and database. Any ideas?
  15. Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /data/16/1/57/83/1546246/user/1664829/htdocs/sub_category.php on line 118 Here is an example page: http://www.industrialpc.com/sub_category.php?cat_id=161 I take it there is something wrong with my MySQL db, any suggestions?
  16. I'm having an error connecting to the database for the admin section of my website and I think it relates to this topic. It's weird because I'm able to connect to the database for every other section of the site. Here is the error when I try to log in to the admin section: Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) in /data/16/1/57/83/1546246/user/1664829/htdocs/admin/functions.php on line 6 Database connectivity Error The function in question (line 6 is the if statement): function dbcon(){ global $host, $user, $pass, $db,$link; if(!($link=mysql_connect($host,$user,$pass) && mysql_select_db($db))) { sprintf("Internal error %d %s",mysql_errno(),mysql_error()); return 0; } else { return 1; } } Everything works fine in PHP4, its when I switched to PHP5 that I started getting errors. Any idea whats wrong?
  17. Anyone have any ideas why the data isn't showing up?
  18. hmm, well that got rid of the error messages but now it is just blank. Should I have some type of statement like echo for it to actually show up on there? this is just driving me nuts because it worked before. I appreciate the help
  19. I'm lost. Do you know how I can fix this?
  20. What do you mean use a URL for the include? Yes I want to include the generated version if this is what you mean: http://www.industrialpc.com/product_other_details.php?pid=774&d_type=details that should be in the box where the errors are coming up on http://www.industrialpc.com/product_info.php?pid=774 thanks for the response
  21. Alright, I have no idea why this won't work. I'm using PHP5, it worked fine on PHP4. I get this error when I'm trying to include another php script: Warning: include(product_other_details.php?pid=774&d_type=details) [function.include]: failed to open stream: No such file or directory in /data/16/1/57/83/1546246/user/1664829/htdocs/product_info.php on line 296 Warning: include() [function.include]: Failed opening 'product_other_details.php?pid=774&d_type=details' for inclusion (include_path='.:/usr/services/vux/php5/lib/php') in /data/16/1/57/83/1546246/user/1664829/htdocs/product_info.php on line 296 You can see for yourself at: http://www.industrialpc.com/product_info.php?pid=774 Here is the line (296) in the code: include "product_other_details.php?pid=$_GET[pid]&d_type=$dtype" ?>... that seems to be working because in the error it gives 'product_other_details.php?pid=774&d_type=details' whick works. Anyway, I've changed the .ini file so include is on, checked to make sure the page thats being included is there. Any other ideas? I'm totally lost, thanks for any help.
×
×
  • 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.