Advertisement
DrewPierce

Untitled

Oct 22nd, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.81 KB | None | 0 0
  1. create schema gilbert_sip;
  2. USE gilbert_sip;
  3.  
  4. drop procedure if exists Validate_Login;
  5. DELIMITER //
  6. CREATE Procedure Validate_Login(IN passedUser VARCHAR(255), IN passedPassword VARCHAR(255), OUT success INT )
  7. BEGIN
  8.     DECLARE storedUser VARCHAR(255);
  9.     DECLARE storedPass VARCHAR(255);
  10.  
  11.     SELECT userName INTO storedUser
  12.     FROM gilbert_sip.login
  13.     WHERE userName = passedUser;
  14.  
  15.     IF storedUser IS NOT NULL THEN
  16.         SELECT password INTO storedPass
  17.         FROM gilbert_sip.login
  18.         WHERE userName = storedUser AND password = passedPassword;
  19.     END IF; -- dont forget me
  20.    
  21.     IF storedPass IS NOT NULL THEN
  22.         SET success = 1;
  23.     ELSE
  24.         SET success = 0;
  25.     END IF; -- dont forget me
  26.     -- RETURN success; -- ooops dont do this it is not a function
  27. END//
  28.  
  29. DELIMITER ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement