Checking User And Email Already Exist - Webmasters - Nairaland
Nairaland Forum › Science/Technology › Webmasters › Checking User And Email Already Exist (611 Views)
| Checking User And Email Already Exist by freelancenig(op): 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 |
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
Why You Are Not Getting Leads; The Way Out! • Moderator(s) Needed !!! • Blogger Adsense, Pls Help