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
https://forums.phpfreaks.com/topic/252795-login-system-gives-blank-page/
Share on other sites

I changed:

 

<? to <?php

 

echo "$_SESSION['userEnrollment']"; to echo $_SESSION['userEnrollment'];

 

$D = new network; to $D = new network();

 

But ajax_login.php still gives me a blank page, even with no dbInfo setted. Should give a MySQL error...

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.

Did you restart your server so that the change to the php.ini will take effect? Also, is the php.ini that you are changing the one that php is using? The Loaded Configuration File line in the output from a phpinfo statement is the php.ini that php is using.

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.

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.