Jump to content

chiefboz

New Members
  • Posts

    6
  • Joined

  • Last visited

chiefboz's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hello once again! On my server there exists a directory that I have used cPanel to protect (as it has some pdf files I want to keep from unauthorized users). For our purposes, let's say the directory is named "secure", the realm is "zone", and I have created a user with the name "Aladdin" and the password "magicwand". These are not real values, but let's just pretend they are. Here's what I want to have happen: User logs in to site account system (which I've built). User visits a page, say authorize.php, which essentially authorizes the user to the secure directory. User is redirected to secure/index.php without needing to enter a username and password. Is this possible? Here is my (modified) authorize.php file. <?php // perform login check (Is the user logged in to a site account?) - if yes, sets $loggedin to true if($loggedin) { $permission = $row['math']; // Retrieve permission from the database. if($permission == 0) { // If the user's account has not been authorized... header('Location: index.php?permissionDenied=true'); // redirect them to the main page and inform them } else { // You have permission! Proceed! header('Authorization: Basic '.base64_encode('Aladdin:magicwand')); header('Location: secure/index.php'); // obviously substituting in the full URL of the index page. } } With this code, the user is still prompted for the credentials of realm "zone" at secure/. Thanks for your help!
  2. Ok, awesome, I got it resolved by combining the functions. Thank you!
  3. Ok, switched them, but that's a string (not a mysqli) and so it's still throwing errors.
  4. The function parameter $q gives it a query. For example, in another file register.php, I have db_query("INSERT INTO user_accounts (firstname, lastname, email, username, reg_timestamp, verification_code, vcode_expire) VALUES ('$fn', '$ln', '$e1', '$un', $time, $v, $vcexp)"); where $fn, $ln, $e1 and $un are filled in by the user on a form. $time, $v and $vcexp are generated automatically. The code above is just a function for use in other files.
  5. Hello — This is probably one of the most common mysqli errors out there, but it has appeared on my webpage. The problem is on line 10. This file is used as a global functions file - so I can essentially use db_query(INSERT INTO...) in a different page and have the function run. For security reasons I have removed the actual usernames and such from the code, and it is pasted below. Any help would be greatly appreciated. <?php // Function to connect to the database. function db_connect() { $dbc = mysqli_connect('host','user','********','db'); } // Function to run database queries. function db_query($q) { global $dbc; $dbq = mysqli_query($dbc, $q); // ERROR OCCURS HERE if(!$dbq) { return false; } else { $r = mysqli_store_result($link); } } ?>
×
×
  • 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.