I have been programing a php online bot with an admin panel. It mainly works good an all but my forms are double posting. So the way I have designed the form is that the user enters the data. Then clicks the submit button which sends the data to MySQL. Then anybody can view that data through a viewer I have made. The problem with this system is that when I submit the form data, the data not only goes to MySQL but the data is also posted just after the button on the php page as well. Below is the code I use for the form.

echo "<form method='post'>";
//form fields
echo "<input type='submit' value='Submit ' name='dataappend' onclick='$submitinfo'></form>";

When those variables inside $submitinfo are sent, there is an if statement that detects if they are sent and forwards the data to MySQL.
Also note that the $_POST variable can contain html codes (eg <b></b>) and it is only when html is used in the $_POST variable that the data is posted into the page.
So is there I way to both send the data to MySQL (as it already does) and for the data NOT to be posted inside the page where it can be viewed by the user. Also I would prefer not to send the variables to the url bar as there is so much in the $_POST variable.

8 Years
Discussion Span
Last Post by cwarn23

Once again I have solved my own topic. I found that html can do php's posting job. That is when you have a form which posts information, you do not need the $_POST variable inside the form as the html part (method=post) already posts the info. So that makes php's $_POST function act similar to a $_GET function. So the code I first posted can be replaced with the following:

echo "<form method='post'>";
//variable deleted

//form fields
echo "<input type='submit' value='Submit ' name='dataappend'></form>";

Note that the onclick event has also been deleted and the submitting process works just as good as before but without displaying the double submit.

Nice job
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.