Jump to content

User Verification


rhyspaterson

Recommended Posts

Hey guys,

 

Making some modifications to my knowledge base. At the moment it doesn't support multiple users so i'm just writing some quick and dirty code until the next major release (4 months ish). Everything is working fine expect this below code. It has something to do with opening the .csv file but im not quite sure what it is. The syntax looks fine to me. When the function is called the page hangs and then shows blank. Hmm.

 

	// If the user is trying to authenticate and suceeds, let them in
	if (isset($_POST['frontendUser']) && isset($_POST['frontendPass'])) {

		// create shorter variables
		$username = $_POST['frontendUser'];
		$password = $_POST['frontendPass'];

		$row = 1;
		$handle = fopen("userList.csv", "r");

		// open the file and read it into an array
		while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
			$num = count($data);

			// check the username and password agains the $_POST variables
			if (($data[0] == $username)&&($data[1] == $password)){
				// it's a match

				$_SESSION['frontendUser'] = $GLOBALS['frontendUser'];
				$_SESSION['frontendPass'] = $GLOBALS['frontendPass'];
				if (isset($_POST['frontendRemember'])
					&& isset($_POST['frontendRemember']) == 1) {
					// Allow the user to be remembered for 2 weeks (i.e. 14 days)
					$cookielength = time()+60*60*24*14;
					setcookie($GLOBALS['cookiePrefix'].'akb_f_u', $GLOBALS['frontendUser'], $cookielength);
					setcookie($GLOBALS['cookiePrefix'].'akb_f_p', $GLOBALS['frontendPass'], $cookielength);
				}
				return true;
			}
		}
		fclose($handle);
	}

 

Any suggestions? Cheers :D

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.