Reputation: 51
I have a form (POST method), the treatment of that form is a function in a class.
on my form the submit button name is "submit"
I also call my function like this :
$validate= new validateForm();
$validate->sendForm();
in my class I have this :
class validateForm{
private $error="";
public function sendForm(){
$db= new db();
$db::connectDb();
if(isset($_POST["submit"])){ ... somme code ...}
However when I do click on the submit, the form gets posted my the method but my function do not fire (just like if it don't get the isset($_POST["submit"])
Any idea?
Upvotes: 0
Views: 61
Reputation: 643
Easyest ways to debug it would be to see what isset($_POST['Submit']) gives you, if its false, print out what submit index holds in post.
Submit depends on how your form is formed. Make sure your button has name "submit" then.
Ether way, easyer to solve it would be using other input names like email input for example if isset($_POST['email'])
is true, that means someone posted some information. Anyhow, read about form handling https://www.w3schools.com/php/php_forms.asp hare. Depending from where you call your sendForm
function you could allways saend it as a parameter sendForm($_POST);
and on recaiving.
public function sendForm(formData)
In other waords if you have a form with username and password check if post username and post password is there instead, since submit button is kind of tricky with value. add form name "submit" as well then.
Once you read about php forms, names and their differences, you should solve it pretty easily. If its a problem that is a little bit deeper, try to replicate the code in a simpler form to debug it, otherwise give us more details.
Upvotes: 1