marcus Posted October 5, 2006 Share Posted October 5, 2006 Ok, well, I'm trying to make my registration more secure by adding something if the username, email or ip already exists in the database, how would i do this? Quote Link to comment Share on other sites More sharing options...
alpine Posted October 5, 2006 Share Posted October 5, 2006 Do you mean adding a message to the user if they already exist in db ? Quote Link to comment Share on other sites More sharing options...
marcus Posted October 5, 2006 Author Share Posted October 5, 2006 if a user already exists in the database they cannot register at all, or have to choose a new usernameedit: many of my user tend to attempt to register multiple times, and when i view the member list there they are, right next to each other Quote Link to comment Share on other sites More sharing options...
RyanSmith345 Posted October 5, 2006 Share Posted October 5, 2006 do a SELECT count(*) FROM users_table WHERE user_name = . $_POST['username']I like to do the check with AJAX also on the user name text field blur event so you can inform them before they fill out the rest of the form. Quote Link to comment Share on other sites More sharing options...
marcus Posted October 5, 2006 Author Share Posted October 5, 2006 but how do i check w/ sql that it already exists? Quote Link to comment Share on other sites More sharing options...
alpine Posted October 5, 2006 Share Posted October 5, 2006 [code]<?php$num = mysql_result(mysql_query("select count(*) from users where user = '$user' or email = '$email' or ip = '$ip'"),0);if($num == 1){ // already exists}?>[/code] Quote Link to comment Share on other sites More sharing options...
marcus Posted October 5, 2006 Author Share Posted October 5, 2006 ok, lemme try that Quote Link to comment Share on other sites More sharing options...
marcus Posted October 5, 2006 Author Share Posted October 5, 2006 It isnt workingWarning: mysql_result(): supplied argument is not a valid MySQL result resource in /home/neoblob/public_html/inc/do_reg.inc on line 20 Quote Link to comment Share on other sites More sharing options...
marcus Posted October 5, 2006 Author Share Posted October 5, 2006 if i post the code could you alter it so it will work? possibly? Quote Link to comment Share on other sites More sharing options...
redarrow Posted October 5, 2006 Share Posted October 5, 2006 [code]<?php$username=addslashes($_POST['username']);$email=addslashes($_POST['email']);$ip=addslashes($_POST['ip']);$query="SELECT * FROM `users` WHERE `username`='$username' or `email`='$email' or `ip`='$ip' "$result=mysql_query($query);if(mysql_num_rows($result)){echo "Sorry but you have a account with us!"}?>[/code] Quote Link to comment Share on other sites More sharing options...
alpine Posted October 5, 2006 Share Posted October 5, 2006 [quote author=mgallforever link=topic=110627.msg447561#msg447561 date=1160085805]It isnt workingWarning: mysql_result(): supplied argument is not a valid MySQL result resource in /home/neoblob/public_html/inc/do_reg.inc on line 20[/quote]Did you change your table- and fieldnames etc. ? Quote Link to comment Share on other sites More sharing options...
marcus Posted October 5, 2006 Author Share Posted October 5, 2006 yes i did Quote Link to comment Share on other sites More sharing options...
marcus Posted October 5, 2006 Author Share Posted October 5, 2006 Omg, thanks redarrow, it works now, I owe you :) Quote Link to comment Share on other sites More sharing options...
redarrow Posted October 5, 2006 Share Posted October 5, 2006 ok mate any time ok your only 14 whale that's young here is a link for you ok,to help you with any mysql you need to do.http://www.1keydata.com/sql/sqlandor.html Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.