Jump to content

Login system gives blank page


ibnclaudius

Recommended Posts

ajax_login.php gives a blank page...

 

login.php

<form method="post" action="ajax_login.php">

Matrpicula: <input type="text" name="userEnrollment" maxlength="32"><br>

Senha: <input type="password" name="userPass" maxlength="32"><br>

<input type="submit">

</form>

 

ajax_login.php

<?


session_start();


include 'class/network.php';



$D = new network;



$D->userEnrollment = mysql_real_escape_string($_POST['userEnrollment']);

$D->userPassword = hash('sha512', $_POST['userPass']);



$D->userLogin();

echo "$_SESSION['userEnrollment']";



?>

 

class/network.php

<?



class network {



	var $userID,

		$userEnrollment,

		$userPass,

		$dbHost,

		$dbUser,

		$dbName,

		$dbPass,

		$dbUserTable;



	function dbInfo() {

		$this->dbHost = 'localhost';

		$this->dbUser = 'user';
		$this->dbPass = 'pass';

		$this->dbName = 'dbname';

		$this->dbUserTable = 'usertable';

	}



	function userLogin() {

		$dbLink = mysql_connect($this->dbHost, $this->dbUser, $this->dbPass);

		if(!$dbLink) die("Could not connect to database: " . mysql_error());



		mysql_select_db($this->dbName);



		$query = "SELECT * FROM $this->dbUserTable WHERE userEnrollment = \"$this->userEnrollment\" AND userPass = \"$this->userPass\" LIMIT 1";

		$result = mysql_query($query);



		if(!$result) {

			echo "Fail.";

		} else {

			$row = mysql_fetch_array($result))

			session_regenerate_id();

				$_SESSION['userEnrollment'] = $this->userEnrollment;

			session_write_close();

		}



		mysql_close($dbLink);

	}




}

?>

Link to comment
Share on other sites

You have a fatal parse error in -

Parse error: syntax error, unexpected ')' in your_path\class\network.php on line 66

 

When developing and debugging php code you MUST have php's error_reporting set to E_ALL and display_errors set to ON in your master php.ini so that php will help you by reporting and displaying all the errors that it detects.

Link to comment
Share on other sites

Oh, I didnt restart it. Now I see the erros.

 

I fixed the ')' problem and change this:

var $userID,

		$userEnrollment,

		$userPass,

		$dbHost,

		$dbUser,

		$dbName,

		$dbPass,

		$dbUserTable;

to:

public $userID;

	public $userEnrollment;

	public $userPass;

	public $dbHost;

	public $dbUser;

	public $dbName;

	public $dbPass;

	public $dbUserTable;

 

Now seems to be correct, I got this error because I dind set dbInfo yet:

Warning: mysql_real_escape_string(): Access denied for user 'www-data'@'localhost' (using password: NO) in /var/www/portal_escolar/system/ajax_login.php on line 9 Warning: mysql_real_escape_string(): A link to the server could not be established in /var/www/portal_escolar/system/ajax_login.php on line 9 Warning: mysql_connect(): Access denied for user 'www-data'@'localhost' (using password: NO) in /var/www/portal_escolar/system/class/network.php on line 68 Could not connect to database: Access denied for user 'www-data'@'localhost' (using password: NO)

 

I'll set it and give feedback soon.

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.