Jump to content

PHP function woes.. stuck


Go to solution Solved by Barand,

Recommended Posts

Hi All
Absolute newbie here, been using PHP for about three months, yes this is a homework project, yes there are a ton of mistakes, yes I may be open to SQL Injection but this is a total homework project on my laptop and destined never to go anywhere.

I have written two custom functions to check a login via a html form.

All works well but now I have decided I want to check what type of user is logging in to direct the users to a different page, eg: Standard user goes to one page Admin user to a different.

So this code works just fine:


image.png.de669dc8e600d99be41307c7d7de98ed.png
   

Finds the users email and logs the user in with the correct email so I get a different user for each email.
However, what I want to do now is pass the type of user FK_UserTypes_Id which will be a 1, 2 or 3 etc.,

I thought I would just be able to add a variable of usertype and the SQL would pull that value into my new variable
I can then use this further down the coding

image.png.d43339da79e94123518fdc999f1cf5c7.png
  

However as soon as I introduced another parameter I get this error message:
Fatal error: Uncaught ArgumentCountError: Too few arguments to function find_user_by_username(), 1 passed in C:\laragon\www\auth\src\auth.php on line 160 and exactly 2 expected in C:\laragon\www\auth\src\auth.php:1

I have run the SQL many times and the fk_User_Id does return for the email provided.

I'm learning so I'll continue to delve and try stuff but this has had me more stumped than any problem in PHP I have encountered so far.

Many thanks for looking

G
 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.