Search the Community
Showing results for tags 'functions'.
-
Hey Guys, I am in the beginning stages of creating a user login / register system for my website. currently, i am working on the conditionals to make sure the information logged in is proper , either matching the DB of my users or spitting an error array , letting my users know that either they need to enter both a valid username & pass or that the info entered does not match the Database. i have created a few functions that clean up the $_POST variables using mysql_real_escape_string: and my main function login(); function sanitize($data) { return mysql_real_escape_string($data); } function user_id_from_username($username){ $username = sanitize($username); return (mysql_result(mysql_query(" SELECT `user_id` FROM `users` WHERE `username`= '$username'"), 0 , 'user_id')); } function login($username, $password){ $user_id = user_id_from_username($username); $username = sanitize($username); $password = md5($password); return(mysql_result(mysql_query(" SELECT COUNT(`user_id`) FROM `users` WHERE `username` = '$username' AND `password` = '$password'"), 0) == 1) ? $user_id : false; } and the conditionals to check the parameters given: if (empty($_POST) === false) { $username = $_POST['loginname']; $password = $_POST['loginpass']; if (empty($username) === true || empty($password) === true) { $errors[] = 'You need to enter a valid Username & Password'; } else if (user_exists($username) === false ) { $errors[] = ' Sorry we could not find this user info in our userbase.'; } else if (user_active($username) === false ) { $errors[] = 'This account still needs to be activated'; } else { $login = login($username, $password); if ($login === false) { $errors[] = ' The Username / Password combination you entered is incorrect.'; } else { echo 'Login Ok!!'; Now finally my issue : When i click login all of my conditionals work except the most important one. When I input a working username and password i am given the same error from my array that the combination is not correct. so its finding the username but the password is not matching and accepting ? any suggestions ? i have been trying to figure this out for a minute. Thanks guys!. edit: (just wanted to add: sorry mods for all caps in title, tried to go back and edit but was to late)
- 10 replies
-
- php
- login/registration
-
(and 3 more)
Tagged with:
-
hi if anyone can help me with a solution to this i would be gratefull i have a paginator function which at the moment while testing is set to display 2 products per page so if i have 10 products ill obviously have 5 page-tabs in my navigation i have filters on the page in order to drill the data set down ie, product type, price range ...etc i seem to having an issue in saving the state of my filters to work with the paginator properley ive supplied the main paginator function pagination.php the function is called in categories.php ive attached both files categories.php (this page gets the category id thats passed from the navigation menu which you will see if you visit http://inspiredskills.com/categories.php?id=1 and displays all products related to that category so we have the category/product listing and a filters menu/form and the left hand side which does indeed drill the products down now the filters work fine with the dataset no problem but i cannot get it to work with the paginator properley basically ive had limited success . but not the complete stable solution i need i cannot pass the saved state of the filter to work in conjuction with my paginator properley if anyone can point me in the right direction of achieving this id be gratefull to look at the product listing page go here http://inspiredskills.com/categories.php?id=1 and you will see what im trying to achieve cheers James pagination.php categories.php
-
Hi Everyone, I wanted to know if there is anyway to define classes and functions on one site and then have multiple other sites connect. I want to do this so that I can encrypt information on these other sites with a class that I have made on another site. I tried require but the remote script executes and then returns the result - it doesn't allow me to access or use the functions. If you have any ideas/suggestions/solutions I'm open to them but it looks like I'm going to need to reevaluate how I'm going to do this. Thanks for reading!
-
Hi Guys, I'm an amateur coder working on a huge project probably way above my capabilities and thus continue to run into problems. So, I seek your help! In my developing system, I'm making a dynamic website so you can control the front-end from the back-end. To edit the front-end you have a page Manage Layout which allows you to edit the HTML of the home page. Then you just type in my custom elements like, [menu], etc. I'm using preg_replace to change these into the scripts I require. The HTML of the homepage is contained in a database, then when it's executed on the homepage I do the preg replace etc. What I'm doing for my [menu] is: Now, the problem occurs. It executes this 100%, the preg_replace carries it out perfectly, BUT instead of it executing where I've placed it in the overall position on the page, it puts everything on the first line after the <body> tag... The preg_replace simply replaces [menu] with createMenu(); so I would've thought that my function would be executed wherever I had [menu]??? I'm not entirely sure what I've said is clear but lets hope so. Cheers. ABOVE:The menu is being placed on the first line, rather than in the div where I have [menu] (which is consequently to the right of the CrossFit St Marys Logo)