I have a page \"index.php\" where i have a link called \"add_users.php\". In \"add_users.php\", I accept user information and come back to the same page \"index.php\" where
Priyanka,
You are on the right track. What you are trying to implement is actually a well known pattern used in web-developing called the POST/Redirect/GET pattern. (Pattern is a bit of a buzz word now-a-days, so maybe paradigm is a better word for this).
A common implementation of this pattern/paradigm is to simply have only one point of entry.
By doing this, add_user.php could now look like this (it's still not the most elegant, but hopefully it will give you an idea of how to go about implementing it):
Thank you
You details have been submitted succesfully.
So, how it basically works is this:
?message=success appended to the url then simply show a clean form.?message=success
?message=success appended to it only show a thank you message, don't show the form.Hopefully this, along with the example I gave you, makes enough sense.
Now, the reason you were getting the infamous Warning: headers already sent message is explained in this answer I gave to another question about why certain php calls are better to put at the top of a script (actually, it doesn't necessarily have to be on top, but it has to be called before ANY output (even (accidental) whitespace) is being output).