PDA

View Full Version : Javascript failure



knutsford-software
4 Dec 2009, 9:15 AM
I am getting the following Javascript error message when submitting the Password reset form








Error: missing } in XML expression
Source File: http://www.easypack.net/lib/js/currentext/ext-all.js
Line: 100, Column: 10
Source Code:
{success:false,message:'Sorry but those registration details can not be found.'}




This is my code



public function PasswordthankyouMessage()
{
return "Your password has been updated as requested";
}

public function Reset_Password($bDisplay) {

$arrTemp = explode("/",$_SERVER['PHP_SELF']);
$iURL = sizeof($arrTemp);
global $sContent,$sTitle,$oCustomer;

if ( $iURL>=4 ) {
$iStage = $arrTemp[3];
$sAction= ($iURL==5) ? $arrTemp[4] : null;
switch($iStage) {

case ('new'):
if ( $sAction == null ) {
$sContent = $this->setPassword();
}
else {
$sContent = $this->storePassword();
}
break;
case ('passwordthankyou'):

$sContent = $this->PasswordthankyouMessage();
break;
}
if ( sizeof($arrTemp) >= 5) {
$bDisplay = false;
}
}
}

private function setPassword() {
$email = $this->oUtils->getVal('email','');
$old_password = $this->oUtils->getVal('old_password','');
$new_password = $this->oUtils->getVal('new_password','');
$sReturn = "Ext.onReady(function(){
var pForm =new Ext.FormPanel({
el:'formholder'
, height:'auto'
, width:525
, labelWidth:180
, bodyBorder:false
, border:false
, buttonAlign:'right'
, url:'/portal/reset_password/new/store'
, bodyStyle:'border:1px #b0b0b0 solid;padding:10px;'
, defaults:{xtype:'textfield'
, width:300}
, items:[{
xtype:'textfield'
, fieldLabel: 'Email Address'
, name: 'email'
, vtype:'email'
, allowBlank:false
, blankText :'Email address required'
, msgTarget:'under'";
if ($email != '' ) $sReturn.=", value:'".$email."'";

$sReturn.="
} ,{
fieldLabel: 'Old password',
name: 'old_password'
, allowBlank : false
, blankText :'Old password required'
, msgTarget:'under'";
if ($old_password != '' ) $sReturn .= ", value:'" . old_password."'";
$sReturn.="
} ,{
fieldLabel: 'New password',
name: 'new_password'
, vtype:'password'
, allowBlank : false
, blankText :'New password required'
, msgTarget:'under'";
if ($new_password != '' ) $sReturn .= ", value:'" . new_password."'";
$sReturn.="
}]
, buttons:[{handler:function(){
pForm.getForm().submit({
success:function(){
document.location='/portal/reset_password/passwordthankyou';
}
, failure : function(form,action){
if ( action.result) {

Ext.MessageBox.alert('action.result.message');
}
else {
Ext.MessageBox.alert('There was a problem.','Please ensure you have filled in all required fields');
}
}
});
}
,
text:'Change password >>'
, minWidth:100

}
]
});
pForm.render(); });";

return "<br><h2 class='password'>Please enter your new password details</h2><div class='centered'><div id='formholder'></div><script type='text/javascript'>".$sReturn."</script></div";

}


private function storePassword() {
$email = $this->oUtils->getVal('email','');
$new_password = $this->oUtils->getVal('new_password','');
$old_password = $this->oUtils->getVal('old_password','');
$sql = "SELECT account_number " . "FROM easypack_logins " . "WHERE auth_login = '" . $email . "' AND auth_key = password('" . $old_password ."')";

if ($this->oDB->query($sql)) {
if ( $this->oDB->numRows() == 1) {
$sql = "update easypack_logins set auth_key = password('" . $new_password . "') WHERE auth_login = '" . $email . "' AND auth_key = password('" . $old_password . "')";

if ($this->oDB->query($sql)) {
return "{success:true,message:'Your password has been updated as requested.'}";
break;
}
else {
return "{success:false,message:'There has been a problem with updating you password. We apologise for the inconvenience.'}";
break;
}
}
else {
return "{success:false,message:'Sorry but those registration details can not be found.'}";
break;
}
}
else {
return "{success:false,message:'There has been a problem with updating you password. We apologise for the inconvenience.'}";
break;
}



I have no idea why. I have based it some existing code further up the page which works. Can any one see why please. It is a site taht I ahve taken over and it looks as thought it is based on version 2



Thanks