yobo Posted August 2, 2013 Share Posted August 2, 2013 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 Quote Link to comment https://forums.phpfreaks.com/topic/280761-how-to-display-my-success-message/ Share on other sites More sharing options...
cyberRobot Posted August 2, 2013 Share Posted August 2, 2013 Have you tried passing a GET variable with the header redirection? The addproduct.php page could then display the success message if the GET variable is detected. <?php header("Location: addproduct.php?sucess=1"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/280761-how-to-display-my-success-message/#findComment-1443142 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.