PDA

View Full Version : Having issues.



ConnorStr
28 Aug 2009, 6:06 AM
I need help, Im new to javascript in general and Im having problems with
Ext.onReady(function(){
Ext.QuickTips.init();
// Create a variable to hold our EXT Form Panel.
// Assign various config options as seen.
var login = new Ext.FormPanel({
labelWidth: 80,
url: '/action.php?op=login',
frame: true,
title: 'SoldiersNet Satellite Login',
defaultType: 'textfield',
monitorValid: true,
// Specific attributes for the text fields for username / password.
// The "name" attribute defines the name of variables sent to the server.
items: [{
fieldLabel: 'Email',
name: 'loginEmail',
allowBlank: false
}, {
fieldLabel: 'Password',
name: 'loginPassword',
inputType: 'password',
allowBlank: false
}],
// All the magic happens after the user clicks the button
buttons: [{
text: 'Login',
formBind: true,
// Function that fires when user clicks the button
handler: function(){
login.getForm().submit({
method: 'POST',
waitTitle: 'Please Wait...',
waitMsg: 'Validating Credentials...',
success: function(){
Ext.Msg.alert('Login Success', 'Your logged in, you are now being redirected to your desktop.');
var redirect = '/';
window.location = redirect;
},
failure: function(form, action){
if (action.failureType == 'server') {
obj = Ext.util.JSON.decode(action.response.responseText);
Ext.Msg.alert('Login Failed!', obj.errors.reason);
}
else {
Ext.Msg.alert('Warning!', 'Authentication server is unreachable : ' + action.response.responseText);
}
login.getForm().reset();
}
});
}
}]
});
// This just creates a window to wrap the login form.
// The login object is passed to the items collection.
var win = new Ext.Window({
id: 'login-win',
layout: 'fit',
width: 300,
height: 150,
shadow: true,
closable: false,
resizable: false,
plain: false,
animCollapse: false,
shim: false,
border: false,
constrainHeader: true,
items: [login]
});
win.show();
}); No mater what is passed in the username fields it always returns the
Ext.Msg.alert('Login Success', 'Your logged in, you are now being redirected to your desktop.'); though it doesn't log anyone in due to the sessions not setting. Any help would be greatly appreciated. I also think it will help me on other problems that I am having also.

VinylFox
28 Aug 2009, 6:16 AM
We need to know what your JSON response looks like, ie:


{
success: false,
errors: {
clientCode: "Client not found",
portOfLoading: "This field must not be null"
}
}

You using FireBug?

ConnorStr
28 Aug 2009, 6:19 AM
We need to know what your JSON response looks like, ie:


{
success: false,
errors: {
clientCode: "Client not found",
portOfLoading: "This field must not be null"
}
}You using FireBug?


if($db->query("SELECT * FROM users WHERE email='".$_POST['loginEmail']."' AND password='".md5($_POST['loginPassword'])."'")>1){ while($row=$db->fetch_array()){ $_SESSION['uid'] =$row["id"]; //session id $_SESSION['pass']=md5($password); //session pass $_SESSION['lvl'] =$row['level']; //session level } $ldate=time(); if($db->query("UPDATE users SET last_login='".$ldate."', last_ip='".$_SERVER['REMOTE_ADDR']."' WHERE id='".$_SESSION['uid']."'")){ $result["success"] = true; }else{ $result["success"] = false; $result["errors"]["reason"] = "Couldn't update the database."; } }else{ $result["success"] = false; $result["errors"]["reason"] = "Couldn't find your information in the database."; } echo json_encode($result); Yes I am. I can give you a dummy login if you want to try it. Sorry for the format, Im having issues with the fourm...

VinylFox
28 Aug 2009, 6:37 AM
The actual response body from FireBug is what we need to be able to help.