Hi,
I am trying (unsuccessfully) to get this code to work and I was wondering if someone could take a quick look at it and let me know what I am missing... I have a feeling it is something really minor. dbhost, dbpass, and dbuser were just edited out I know those values work.
<?php
require_once("session.php");
$yesno = 0;
if ($_POST["validate"] != "")
{
foreach($_POST as $key=>$val)
{
$$key = $val;
if (strlen($val) == 0)
$yesno = 1;
}
$dbuser = "xxxxxx";
$dbpass = "xxxxxx";
$dbhost = "xxxxxx";
$link = mysql_connect($dbhost,$dbuser,$dbpass);
mysql_select_db("memberz");
//check existing username
$result = mysql_query("select * from members where username = \"$username\"");
if (mysql_num_rows($result) > 0)
{
//that username does exist
echo "Username is taken, try again<BR>";
exit();
}
//check the passwords for match
else if ($password != $cpassword)
{
echo "Your passwords do not match, try again";
}
else if ($yesno == 1)
{
echo "Please enter info for all fields";
}
else
{
//the user is available, and the passwords match
$password = md5($password);
$result2 = mysql_query("insert into members first_name,last_name,username,password (\"$username\",\"$password\",\"$fname\",\"$lname\")");
if ($result2)
{
echo "Created $username successfully, you will now have to wait for administration to add your access to the page";
require_once("index.php");
exit();
}
else
echo "error";
}
//input into DB
}
echo "<BR><BR><center>
<font face='tahoma'>
Register</font><BR><BR>
<table border=0 cellpadding=0 cellspacing=5>
<form method=post action=register.php>
<tr><td>Username</td><td><input type=text name=username size=15 maxlength=30 value='$username'></td></tr>
<tr><td>Password</td><td><input type=password name=password size=15 maxlength=30></td></tr>
<tr><td>Confirm Password</td><td><input type=password name=cpassword size=15 maxlength=30></td></tr>
<tr><td>First Name</td><td><input type=text name=fname size=15 maxlength=30 value='$fname'></td></tr>
<tr><td>Last Name</td><td><input type=text name=lname size=15 maxlength=30 value='$lname'></td></tr>
</table>
<input type=hidden name=validate value=validate>
<input type=submit value='Register'>
</form>
";
?>
Thank you for any help that you can offer! I really appreciate it.
-Mike