PDA

View Full Version : My ExtJS + PHP login not working :( + some IE problems.



TotoTitus
6 Aug 2010, 2:38 AM
Hello everyone,

I am doing a login form in ExtJS + PHP, but it does not work. (authentication failed each time). Also, i receive and 'access denied' error in IE each time.

Ext code:


<script type=text/javascript>
Ext.onReady(function() {

Ext.QuickTips.init();

var loginForm = new Ext.FormPanel({
url: 'login.php',
title: 'Login to goodTalk',
frame:true,
bodyStyle:'padding:5px 5px 0',
width: 252,
renderTo: 'innermost',
items: [{
xtype: 'box',
autoEl: {
html: "<div id='login-text'><h1>We don't want any!!!</h1></div>"
}
},{
xtype: 'textfield',
fieldLabel: 'User',
name: 'user',
allowBlank: false
},{
xtype: 'textfield',
fieldLabel: 'Password',
name: 'password',
allowBlank: false,
inputType: 'password'
}],
buttons: [{
text: 'Login',
handler: function() {
loginForm.getForm().submit({
//clientValidation: true,
success: function() {
Ext.Msg.alert('Good', 'Logged');
},
failure: function() {
Ext.Msg.alert('Warning', 'Could not log');
}
});
}
}]
});
});
</script>



and PHP code:



<?php

$user=$_REQUEST['user'];
$password=$_REQUEST['password'];

$dbhost="localhost";
$dbuser="root";
$dbpass="asdf";
$db="chat";

mysql_connect($dbhost,$dbuser,$dbpass) or die(mysql_error());
mysql_selectdb($db) or die(mysql_error());

$query="SELECT * FROM accounts WHERE name='$user' AND password='$password'";
$result=mysql_query($query) or die (mysql_error());

if(mysql_num_rows($result))
{
echo "{success: true}";
}
else
{
echo "{success: false}";
}
?>


I really have no idea what's going wrong, or why IE gives me an 'access' denied error, every time i try to use the login button. Moreso, IE points to the 8th line in my index.html file (where the Ext code is), into a block of CSS, so IE 7 is really of no use in debugging.
Firefox gives no errors, but it simply doesn't get to the success : function () {} part. Any help and suggestions (as this will be part of a larger project) is appreciated.

Condor
6 Aug 2010, 4:16 AM
1. In Firefox, install Firebug and use the Net tab to see what your server actually receives and sends back.
2. Debugging in IE8 works much better than using the Script Debugger with IE7.
3. Run your code through jslint.com. Trailing commas are the main reason for IE failures.

TotoTitus
6 Aug 2010, 4:58 AM
Hello,

Firebug reports nothing going on between server and script. It's all just blanks.
I have no trailing commas, as IE usually stops rendering anything on the page when it encounters them. (jslint.com told me nothing
about them).
What's happening? Why is no information going in between the server and the script? Login.php is in the same folder as index.html.

UPDATE: Tweaked the code a bit to find the source of the error. For some reason CONNECTION_FAILURE is detected. Anymore help on this? Localhost is up and running, Apache+MysqL.

Condor
6 Aug 2010, 5:11 AM
I have no idea...

(you are running this on your PHP server and not on the local filesystem I hope)

TotoTitus
6 Aug 2010, 5:50 AM
You are perfectly right.
The ONLY problem i had is that i opened the file 'raw', not typing 'localhost:\blabla' in the browser.
This was really stupid of me =P~
Thank you !