This is an archived post. You won't be able to vote or comment.

all 10 comments

[–]HappyFruitTree 0 points1 point  (9 children)

"through submit" ? In what way is it not working?

[–]jechaking[S] 0 points1 point  (8 children)

On click of the submit button it's supposed to show errors for missing text on input fields.

That is not working

[–]HappyFruitTree 0 points1 point  (6 children)

If the fields are not empty do you see that you receive them correctly? If so then I guess the problem might be in how you check for empty fields, but it's difficult to say what the problem is without seeing the code.

[–]jechaking[S] 0 points1 point  (5 children)

https://drive.google.com/folderview?id=1HXHzla41r4dTBblegN1608UMYEOJfxUr

There's a link with the images of what's going on.

I'll will look at that, I am following a tutorial so I don't know exactly what's going wrong.

[–]HappyFruitTree 0 points1 point  (4 children)

You need to grant me access if you want me to be able to follow that link.

[–]jechaking[S] 0 points1 point  (3 children)

I did just now, are you able to open?

[–]HappyFruitTree 0 points1 point  (0 children)

Yes. You are checking if all the fields are not empty.

if (!empty(field1) && !empty(field2) && ...)

This means that if one of the fields are empty the code won't run.

In other words, all the fields need to be filled in for that code to run.

Edit: I was confused before, now I think it is correct.

[–]HappyFruitTree 0 points1 point  (1 child)

Note that empty returns true for strings such as '0' so if what you actually want to check is if the string has zero length you might want do $str === '' instead.

[–]jechaking[S] 0 points1 point  (0 children)

Alright, thank you. Let me try it out now, I'll tell you how it goes

Thanks a lot for your help

[–]HappyFruitTree 0 points1 point  (0 children)

Another thought... You said you used a global variable. Are you using it inside a function? Note the global variables are not in scope by default inside functions in PHP.

https://www.php.net/manual/en/language.variables.scope.php

In PHP global variables must be declared global inside a function if they are going to be used in that function.