Azad Shedge
Azad Shedge

Reputation: 15

how to redirect on another page?

http://example.com/example/[email protected]; i want to redirect this url to another page but same url showing browser link bar so how can i change url. my url code window.location.href="education_detail.php?uid=<?php echo htmlentities($user_id);?>";

Backend Code

<?php
        if(empty($amount)){
            $error[] =  "Please Enter Expected Amount";
        }
        elseif(empty($cheque_name)){
            $error[] =  "Please Enter Issue Cheque in Favour of";
        }
        if (count($error)) {
            echo "<i class='fa fa-exclamation'> ";
            echo implode('<br>', $error);
            echo "</i>";
        }
        else{
            $result=mysqli_query($conn, "UPDATE education SET amount='$amount', cheque_name='$cheque_name', purpose_amount='$purpose_amount', date='$date' WHERE id='$apply_id'")or die("Could not insert data: " .mysqli_error($conn));
                echo 1;
        }
    ?>

below is ajax Jquery code

$('.btn_education_step5').click(function(){            
    var formdata=new FormData($('#education_step5')[0]);
        $.ajax({
            url:'includes/backend_education_amount.php',
            method: "POST",
            async: false,
            cache: false,
            contentType: false,
            processData: false,
            data : formdata,
            success:function(answer_from_actionpage){
                if(answer_from_actionpage == 1){
                    window.location.href="education_detail.php?uid=<?php echo htmlentities($user_id);?>";                   
                }else{
                    $('.error').html(answer_from_actionpage);
                }
            }           
        })
});

Upvotes: 1

Views: 56

Answers (2)

davidethell
davidethell

Reputation: 12028

Without seeing the entire code of the backend script it is hard to determine what is wrong. It looks like you might be echoing back more than just the "1" response and so your success handler is not correctly seeing the response you want.

In your backend script when you echo "1" be sure to stop the script from executing at that point if anything below that code has any output like HTML or other PHP logic. I would change your echo to a die command to stop script execution and return a 1:

die(1);

Upvotes: 1

Ms.KV
Ms.KV

Reputation: 261

First confirm your echo htmlentities($user_id); is print different user_id.

Upvotes: 1

Related Questions