Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.