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'>";
$submitinfo=$_POST['klrpomth'].$_POST['questionid'].$_POST['answer'].$_POST['matchnum'].
$_POST['keywords01'].$_POST['keywords02'].$_POST['keywords03'].$_POST['keywords04']
.$_POST['keywords05'].$_POST['keywords06'].$_POST['keywords07'].$_POST['keywords08']
.$_POST['keywords09'].$_POST['keywords10'].$_POST['keywords11'].$_POST['keywords12']
.$_POST['keywords13'].$_POST['keywords14'].$_POST['keywords15'].$_POST['keywords16']
.$_POST['botname'];
//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.

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.

commented: Nice job +8
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.