Hello everyone,
I am doing a login form in ExtJS + PHP, but it does not work. (authentication failed each time) . Here's the code:
ExtJS part:
<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 part:
<?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}";
}
?>
Yeah i know, SQL entry isn't sanitized, but i'm not really into that right now. Could somebody please tell me why it's not working? Also, i am looking forward to extending the project further, what else functionality should i add beside SQL sanitizing ?
Thanks.