chriscloyd Posted December 30, 2006 Share Posted December 30, 2006 heres my problemim creating a script so a person can not register an account from the same ip or have the same username or same email as any other users so heres the problem i created the script but it seems to just skip right over it even tho im using the same info i already registered withheres my first page[code]<?phpsession_start();error_reporting(E_ALL);include("functions.php");//connect to mysqlmysql_connect('*****','******','******');mysql_select_db('******');//register begins//define vars$first = $_POST['First_Name'];$last = $_POST['Last_Name'];$username = $_POST['Username'];$password = md5($_POST['Password']);$email = $_POST['Email'];$day = $_POST['day'];$month = $_POST['month'];$year = $_POST['year'];$key = $_POST['key2'];$sc = sha1(md5($_POST['key1']));$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);$ip = $_SERVER['REMOTE_ADDR'];check_mulit($ip,$email,$username);?>[/code]then heres my function[code]<?php//connect to mysqlmysql_connect('*****','******','******');mysql_select_db('******');//check multifunction check_multi($i,$e,$u) { $check_i = mysql_query("SELECT * FROM users WHERE ip = '$i'"); $check_e = mysql_query("SELECT * FROM users WHERE email = '$e'"); $check_u = mysql_query("SELECT * FROM users WHERE username = '$u'"); $i_status = mysql_num_rows($check_i); $e_status = mysql_num_rows($check_e); $u_status = mysql_num_rows($check_u); if ($i_status > 0) { $error = '-You already have an account on this ip address'; header("Location: ../?page=Register&error=$error"); } if ($e_status > 0){ $error = '-The email address '.$email.' is already registered'; header("Location: ../?page=Register&error=$error"); } if ($u_status > 0){ $error = '-The username '.$username.' is already taken'; header("Location: ../?page=Register&error=$error"); }}?>[/code] Quote Link to comment Share on other sites More sharing options...
onlyican Posted December 30, 2006 Share Posted December 30, 2006 you need to return something from your functionI would do something like[code]<?phpfunction check_multi($i,$e,$u) {$return_value = true; $check_i = mysql_query("SELECT * FROM users WHERE ip = '$i'"); $check_e = mysql_query("SELECT * FROM users WHERE email = '$e'"); $check_u = mysql_query("SELECT * FROM users WHERE username = '$u'"); $i_status = mysql_num_rows($check_i); $e_status = mysql_num_rows($check_e); $u_status = mysql_num_rows($check_u); if ($i_status > 0) { $error = '-You already have an account on this ip address'; header("Location: ../?page=Register&error=$error");$return_value = false; } if ($e_status > 0){ $error = '-The email address '.$email.' is already registered'; header("Location: ../?page=Register&error=$error");$return_value = false; } if ($u_status > 0){ $error = '-The username '.$username.' is already taken'; header("Location: ../?page=Register&error=$error");$return_value = false; }return $return_value;}[/code]Then on the Actual codeSomething like[code]<?phpif(check_mulit($ip,$email,$username)){echo "Everything is fine, lets add this information}else{echo "DEGUB_TEXT: An error has occured, the script should have forwarded.}?>[/code] 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.