Ok, here is my code. What it is supposed to do is retrieve the referer that sent you to the page, the user will type someurl.com/refcreate.php?ref=username
<?php
session_start();
$referer = $_GET['ref'];
$_SESSION['referer'] = $referer;
if (!isset($referer))
{
echo 'You did not specify a referer, please correct this to continue';
die;
}
elseif($referer == "")
{
echo 'You did not specify a referer, please correct this to continue';
die;
}
The above part works fine if they forgot to specify the referer. The below half is to check if the current referer specified is an actual user in the database.
if(refcheck($referer) = false)
{
echo 'that referer is not in our database,please double chek the spelling and try again.';
die;
}
function refcheck($ref)
{
require('mysql_con.php');
$query="SELECT username FROM jos_users WHERE username='". $ref ."'";
echo $query;
$result = mysql_query($query, $con);
$exists =mysql_fetch_assoc($result);
if ($exists != false)
{
//return true;
echo 'true';
return true;
}
require('mysql_close.php');
}
?>
OK, I figured out the problem (or problems rather). 1 was it needed to look like this if(refcheck($referer) == false){}
instead of if(refcheck($referer) = false);
. So it was a missing equal sign and a misplaced colon :P thanks guys
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…