ibnclaudius Posted December 9, 2011 Share Posted December 9, 2011 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 More sharing options...
Drummin Posted December 9, 2011 Share Posted December 9, 2011 First try replacing all short tags with full, i.e. <?php instead of <? Link to comment https://forums.phpfreaks.com/topic/252795-login-system-gives-blank-page/#findComment-1296049 Share on other sites More sharing options...
Pikachu2000 Posted December 9, 2011 Share Posted December 9, 2011 Then remove the double quotes here: echo "$_SESSION['userEnrollment']"; Link to comment https://forums.phpfreaks.com/topic/252795-login-system-gives-blank-page/#findComment-1296062 Share on other sites More sharing options...
ibnclaudius Posted December 9, 2011 Author Share Posted December 9, 2011 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... Link to comment https://forums.phpfreaks.com/topic/252795-login-system-gives-blank-page/#findComment-1296092 Share on other sites More sharing options...
PFMaBiSmAd Posted December 9, 2011 Share Posted December 9, 2011 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 https://forums.phpfreaks.com/topic/252795-login-system-gives-blank-page/#findComment-1296108 Share on other sites More sharing options...
ibnclaudius Posted December 9, 2011 Author Share Posted December 9, 2011 I changed the pnp.ini, but i still can't see the errors. Link to comment https://forums.phpfreaks.com/topic/252795-login-system-gives-blank-page/#findComment-1296164 Share on other sites More sharing options...
PFMaBiSmAd Posted December 9, 2011 Share Posted December 9, 2011 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. Link to comment https://forums.phpfreaks.com/topic/252795-login-system-gives-blank-page/#findComment-1296165 Share on other sites More sharing options...
ibnclaudius Posted December 9, 2011 Author Share Posted December 9, 2011 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 https://forums.phpfreaks.com/topic/252795-login-system-gives-blank-page/#findComment-1296168 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.