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
https://forums.phpfreaks.com/topic/68303-user-verification/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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