GregRickshaw Posted January 12 Share Posted January 12 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: 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 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 Quote Link to comment https://forums.phpfreaks.com/topic/317626-php-function-woes-stuck/ Share on other sites More sharing options...
Solution Barand Posted January 12 Solution Share Posted January 12 Stick with your first code block. Instead of returning "true" on success return $email['fk_UserTypes_Id']. Then you just need to check the login return value to decide the next page. Quote Link to comment https://forums.phpfreaks.com/topic/317626-php-function-woes-stuck/#findComment-1614103 Share on other sites More sharing options...
GregRickshaw Posted January 12 Author Share Posted January 12 (edited) WOW works a treat thank you so much I don't think I would ever have done that. A lot to learn but it's every exciting and enjoyable. Edited January 12 by GregRickshaw Quote Link to comment https://forums.phpfreaks.com/topic/317626-php-function-woes-stuck/#findComment-1614104 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.