Reputation: 25
i´ve got a little problem with my php code. The code contains a form that reloads the document. But after the reaload I cant read the POST data. Here is the HTML code:
<form action="config_page.php" method="post">
... some Inputs
<input type="submit" value="Save" name="config_btn" class="submitbtn_2">
</form>
On top of config_page.php ive got this PHP code:
if(isset($_POST["config_btn"])){
echo "isset";
//Some Database writing
}else{
echo "is not set";
}
Bizarrely, the output "is not set" always appears after submiting the form, but Database Changes are applied anyway... (Database Changes are only performed if the isset statement is true)
Can someone figure out the problem?
Thanks for your help!
Upvotes: 0
Views: 126
Reputation: 13738
POST
values will always set after post or submit form with form post method
echo "is not set";
always true until you not click on submit or post any values. after submit click you will find $_POST["config_btn"]
is set true so db queries runs.
so keep your form in else part.
So :-
if(isset($_POST["config_btn"])){
echo "isset";
//Some Database writing
}else{
echo "is not set";
}
echo "is not set";
Upvotes: 2