0

The problem i have is that whenever it inserts the data into the database it doesn't redirect the user to the invoice.php page. Please guys i really need your help.

This is the html code:

<form method="POST" action="">
<input type="text" name="resident_address" id="resident_address"/>
<input type="text" name="price" id="status"/>
<input type="hidden" name="status" id="status" value="0"/>
</form>

This is the jquery code:

var dataString = $('#applyform').serialize();
$.ajax({
                        type: "POST",
                        url: "applyform.php",
                        cache: false,
                        data: dataString,
                        beforeSend: function()
                        {
                            $(".apply_error").hide();
                        },
                        success: function(html) {

                            if (html == "true")
                            {
                                // You can redirect to other page here....
                                window.location.href = 'invoice.php';
                            }
                            else
                            {
                                //window.location.href = 'apply.php';
                                $("div.apply_error").html("Wrong details").show();

                            }
                        }                
                    }); 

this is the php which is the applyform.php:

if(isset($_POST['Submit']))
{
   $result = mysql_query("INSERT INTO mytable (resident_address, price, status) VALUES ('$addressfields', '$price', '$status')");

   if($result){
      echo "true";
   }

}
1
  • Maybe you have a mysql error. Are you checking the query is Ok? Commented Dec 15, 2014 at 10:12

1 Answer 1

1

you are not posting a POST var called "Submit" so your

if(isset($_POST['Submit']))

will always evaluate to false and your mysql query is never executed.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.