Ok, ive made this function so when i call it, it inserts certain set variables in2 a table.
The error I get is:
Warning: Missing argument 1 for register() in C:\apache\htdocs\fromesh\inc\conf.php on line 129
Warning: Missing argument 2 for register() in C:\apache\htdocs\fromesh\inc\conf.php on line 129
Line 129 on conf.php is:
function Register($query, $usercheck)
Below, is the contents of my function (I've added some comments):
function Register($query, $usercheck) // $query and $usercheck are both assigned within this function
{
// These global's are values of a form, and are set from "outside" the function
global $username;
global $email1;
global $email2;
global $pass1;
global $pass2;
global $homepage;
global $icq;
global $msn;
global $yahoo;
global $aim;
global $interests;
global $occupation;
global $location;
global $dbname;
global $accounts;
if ($username && $email1 && $email2 && ($email1=="$email2") && $pass1 && $pass2 && ($pass1=="$pass2")) // Checks the values input on the form
{
// First check that the username isnt already in use
$query = "SELECT * FROM $accounts WHERE Username='$username'";
$usercheck = mysql_db_query($dbname, $query);
if ($usercheck[0]=="$username")
{
// Print an error indicating that the chosen username is unavailible
print "<center><font face=verdana size=1 color=#3F798F><b>Error:</b> The username $username is already in use, please choose another - <a href=\"javascript:history.back(1)\"><i>go back></i></a></font></center>";
}
else
{
// Continue to register the user
// Test non-required fields
if ($homepage==="")
{
$new_homepage = "N/A";
}
elseif ($homepage==="http://")
{
$new_homepage = "N/A";
}
else
{
$new_homepage = "$homepage";
}
if ($icq==="")
{
$new_icq = "N/A";
}
else
{
$new_icq = "$icq";
}
if ($msn==="")
{
$new_msn = "N/A";
}
else
{
$new_msn = "$msn";
}
if ($yahoo==="")
{
$new_yahoo = "N/A";
}
else
{
$new_yahoo = "$yahoo";
}
if ($aim==="")
{
$new_aim = "N/A";
}
else
{
$new_aim = "$aim";
}
if ($interests==="")
{
$new_interests = "N/A";
}
else
{
$new_interests = "$interests";
}
if ($occupation==="")
{
$new_occupation = "N/A";
}
else
{
$new_occupation = "$occupation";
}
if ($location==="")
{
$new_location = "N/A";
}
else
{
$new_location = "$location";
}
// Insert values into the accounts table
$query = "INSERT INTO $accounts (DateOfReg, Username, Email, Password, HomePage, ICQ, MSN, Yahoo, AIM, Interests, Occupation, Location)
values ('$date', '$username', '$email2', '$pass2', '$new_homepage', '$new_icq', '$new_msn', '$new_yahoo', '$new_aim', '$new_interests', '$new_occupation', '$new_location')";
mysql_db_query($dbname, $query) or die ("Query <i>register user</i> failed: ".mysql_error());
print "<center><font face=verdana size=1 color=#3F798F>Your account has been successfully registered! Please login on your bottom left</font></center>";
}
}
else
{
print "<center><font face=verdana size=1 color=#3F798F><b>Error:</b> Please fill in all required fields as asked - <a href=\"javascript:history.back(1)\"><i><font size=1>go back</font></i></a></font></center>";
}
}
I am calling the function by simply using: Register();
Thanks a lot for any help any1 can offer! I've been stuck on why it wont work for a while, thanks for any time you people can spare! 🙂