CREATE DEFINER=`root`@`localhost` PROCEDURE `user_register`(Fullname VARCHAR(50), Email VARCHAR(150), Pass VARCHAR(50))
BEGIN
DECLARE s VARCHAR(20);
DECLARE returned_id varchar(100);
SET returned_id = (SELECT email FROM users WHERE email = Email);
IF (returned_id IS NULL) THEN
INSERT INTO users (`name`, `email`, `password`, `create_time`)
VALUES (Fullname, Email, Pass, CURRENT_TIMESTAMP());
SET s = 'success';
call log_msg(s); #for testing
ELSE
SET s = 'exists';
call log_msg(s); #for testing
END IF;
END
When doing this stored procedure, it seems to add a user to the user table if the table is empty. Then, no matter what variables I input, the user table always says that the user exists inside the user table.
Ex) I call the procedure with ('ss', 'ss', 'ss') on an empty user table and it will succesfully update the parameters in the table with ss, ss, and ss.
Then, if I call the procedure with ('123','123','123') on the user table where ss,ss,ss is already a user. The procedure thinks that 123,123,123 is already in the table and won't update it.
Please help, I need a stored procedure for user registration and it doesn't seem to work and I can't find a way for it to work. I believe my code works logically, I don't get why it is not updating it.