Jump to content

check multi


chriscloyd

Recommended Posts

heres my problem
im 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 with

heres my first page
[code]
<?php
session_start();
error_reporting(E_ALL);
include("functions.php");
//connect to mysql
mysql_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 mysql
mysql_connect('*****','******','******');
mysql_select_db('******');
//check multi
function 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]
Link to comment
Share on other sites

you need to return something from your function

I would do something like

[code]
<?php
function 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 code
Something like
[code]
<?php
if(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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.