I have a simple form like this :
<form method="post" name="change_pass" id="change_pass" action="change_pass2.php">
<input type="hidden" id="uid" value="<?php echo $userid ?>">
<div id="dialog" style="display:none">
<input type="text" name="pass" id="pass">Password :
<input type="text" name="conf_pass" id="conf_pass">Confirm Password:
</div>
</form>
<div id="weak" style="display:none" title="Weak password">
<p >Please make sure your password is atleast 8 characters</p>
</div>
<div id="mismatch" style="display:none" title="Failure">
<p>Password mismatch</p>
</div>
</body>
</html>
I am using jquery ui’s dialog function to create a dialogue form like this,
$(function(){
$('#dialog').dialog({
title : 'You must change your password',
modal : true,
closeOnEscape: false,
dialogClass: 'no-close',
resizable: false,
draggable: false,
buttons: {
'Change Password' : function() {
if ( $('#pass').val().length < 8 || $('#pass').val() == 'dantours') {
$('#weak').dialog();
}
else if ( $('#pass').val() != $('#conf_pass').val()){
$('#mismatch').dialog();
}
else
$('#change_pass').submit();
}
}
});
});
But on the change_pass2.php page, the $_POST array is empty. I’ve been bagging my head against the monitor trying to figure this out.
jQuery dialog will move the dialog to the end of the body, which is outside the form scope, as stated here. So there won’t be any data posted.
You need to do this: