Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

how to display my success message

$
0
0

Hey All,

 

I am having some issues my data gets added to the database ok but since I am using a header redirection (to clear the $_post variable) my success message is not displayed or my error if there is an error.

 

Basically I would like my message to be displayed just above the form to say success it worked or error if it did not.

 header("Location: addproduct.php");
		echo ' <div class="span9" id="content">
		<div class="alert alert-success">
    			<div id="success"><p>Product has been added to the database</p></div>
    		</div>
    		</div>';
		exit;

the above code is a snippet of my main code I am also using ajax to help with this.

 

my simple ajax code

$('#btnSave').click(function() {
    $.post($("#addproduct").attr("action"), data, function(info){ $("#success").html(info); });
    clearInput());
    });

$("#addproduct").submit( function() {
    return false;
});

function clearInput() {
    $("#addproduct :input").each( function() {
       $(this).val(''); 
    });
    
}

Many Thanks

 

J


Viewing all articles
Browse latest Browse all 13200

Trending Articles