jimfog Posted September 12, 2013 Share Posted September 12, 2013 I have set up a script which accepts ajax requests regarding the deletion of an account. The first request goes to delete the account and if the user has data left in his/her account gets a warning. If he still wants to go for the deletion the second ajax request is sent at which point the problems begin. The script has a variable in it which is NEEDED for the second request. So when the first request is on its way I get Notice: Undefined index: deletestate... Here is the script: <?php session_start(); require 'admin_db_code.php';//ένα db connect είναι εδώ$sessionml=$_SESSION['valid_user'];$delpass=$_POST['delpass'];$deletestate=$_POST['deletestate'];if($deletestate==1) { } $output=delete_account($conn,$delpass,$sessionml); if($output=='0') {$success='0';} elseif($output=='1') {logout($conn); $success='1';} elseif($output=='2') {$success='2';} elseif($output=='3') {$success='3';} elseif($output=='4') {$success='4';} echo $success; ?> delete_account is suppose to be run on the first request-at which case we have the warning. But it does not since I get the notice for $deletestate...this variable gets sent with SECOND request at which will have no problem but unfortunately we cannot get at this step for the reasons already explained.SO THE MOMENT OF THE FIRST AJAX REQUEST $deletestate IS UNDEFINED. What can I do? I need this variable. It contains the answer of the user "yes delete my account" but it gets sent only in the second request. Link to comment Share on other sites More sharing options...
justsomeguy Posted September 12, 2013 Share Posted September 12, 2013 Use isset to check if a variable is set before checking the value of it. Link to comment Share on other sites More sharing options...
jimfog Posted September 12, 2013 Author Share Posted September 12, 2013 thanks Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now