Jump to content

how to display my success message


yobo

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/280761-how-to-display-my-success-message/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.