Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,194,232 members, 7,953,882 topics. Date: Friday, 20 September 2024 at 08:09 AM |
Nairaland Forum / Science/Technology / Webmasters / Checking User And Email Already Exist (545 Views)
I Will Extract Phone Number And Email Of Any Facebook Page Or Group For You / If Already Exist PHP / Content Blogpost And Email Writer Needed (2) (3) (4)
Checking User And Email Already Exist by freelancenig: 2:19pm On May 07, 2017 |
Help sort out this code if(isset($_POST) & !empty($_POST)){ |
Re: Checking User And Email Already Exist by Lantean(m): 5:57pm On May 07, 2017 |
freelancenig: Hello freelancenig. You didn't tell what you have as the error message coupled with what you want to accomplish. However: $check_user should be $fname NOT '$fname'. The latter is a literal string rather than a variable which you intend for the spot. In $data_insert, you did the same to the post variables. E.g. $fname NOT '$fname'. Do same correction for the other variables. |
Re: Checking User And Email Already Exist by mcqwerty(m): 8:55pm On May 08, 2017 |
Don't hash the password in the password variable. Do that at the point of insertion onto the database. //Check for existing username: $query= "SELECT * FROM users WHERE username='$username'"; $data=mysqli_query($conn, $query); //not found, then insert if (mysqli_num_rows($data) == 0){ $query="INSERT into users (username, password) VALUES ('$username', SHA256('$password') )"; mysqli_query($conn, $query); echo 'Success'; }else{ echo 'user exists!' } Just follow this sort of logic |
Re: Checking User And Email Already Exist by Greene66: 9:05am On May 09, 2017 |
Wrong. Hash the password BEFORE the query in a variable such as $password = hash ('sha256', $pass); And you should use mysqli_num_rows (); To check that it exists, it should be >0 not ==0 To check that it DOES NOT exists, it should be <1 |
Re: Checking User And Email Already Exist by mcqwerty(m): 8:37pm On May 09, 2017 |
Greene66: Your coding logic is so wrong. if $username shouldnt exist then mysqli_num_rows == 0 and not > 0 |
(1) (Reply)
Designer For A 50% 3:2(3 By 2) Ponzi/peer To Peer Donation Website Site / Please Help Me With Urgent Info / Looking To Buy Amazon AWS Accounts With Email Sending Limits Lifted
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 11 |