Forum Moderators: coopster
SIGNUP:
$page = "signup.php?id=$id";
$id = $_GET['id'];
//(id,first_name,last_name,user,pass,email,upgrade,ref)
if (isset($submit))
{
mysql_query("INSERT INTO members (first_name,last_name,user,pass,email,upgrade,ref) Values ('$first','$last','$user','$pass','$email','$upgrade','$ref_user')");
// Retrieve new id for member
$new_member_id = mysql_query("SELECT * FROM members WHERE 'user' = '$user'");
$new_member_id = mysql_fetch_object($new_member_id);
$new_id = $new_member_id->id;
$sponsor_ads_id = mysql_query("INSERT INTO sponsor_ads (id) Values ('$new_id')");
$featured_ads_id = mysql_query("INSERT INTO featured_ads (id) Values ('$new_id')");
// End of query
print "<br><br><blockquote><blockquote><blockquote><p align=left><font face=arial size=2>Thanks for signing up! We have sent your login details to your email address $email!<br><a href=\"login.php\">Click here to login now!</a><br><br>Thanks,<br>Admin<br><a href=$domain>$domain</a></font></p></blockquote></blockquote></blockquote>";
// Send email code goes here
$title = "New $title Account";
$message = "Hi $first,\n\nThanks for signing up with $title $domain\nYour Username is: $user\nYour Password is: $pass\n\nThanks,\nAdmin\n$domain\n\n";
mail("$email", "$title", $message,
"From: webmaster@{$_SERVER['SERVER_NAME']}\r\n" .
"Reply-To: webmaster@{$_SERVER['SERVER_NAME']}\r\n" .
"X-Mailer: PHP/" . phpversion());
exit;
}
?>
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title><? print $title;?> Members Signup Form</title>
<link rel="stylesheet" type="text/css" href="design.css" />
<script language="JavaScript">
function validateLogin(field1, field2, field3, field4, field5)
{
if (field1.value == '')
{
alert("First Name can't be empty");
return false;
}
if (field2.value == '')
{
alert("Last Name can't be empty");
return false;
}
if (field3.value == '')
{
alert("Username can't be empty");
return false;
}
if (field4.value == '')
{
alert("Password can't be empty");
return false;
}
if (field5.value == '')
{
alert("Email Address can't be empty");
return false;
}
return true;
}
</script>
</head>
<body>
<form action="<? print $page;?>" method="POST" onSubmit="javascript:return validateLogin(first, last, user, pass, email);">
<div align="center">
<center>
<table border="0" width="405" height="411">
<tr>
<td width="405" height="22" bgcolor="#000080">
<p align="center"><font face=arial size=2 color="#ffffff"><b><? print $title;?></b></font></p>
</td>
</tr>
<tr>
<td width="405" height="354" valign="top"> <p align="center"><font face="Arial" size="2"><b>Signup Form<br>
<br>
</b>First Name<b><br>
</b></font>
<input type="text" class=texta name=first><br>
<br>
<font size="2" face="Arial">Last Name</font><br>
<input type="text" class=texta name=last><br>
<br>
<font face="Arial" size="2">Username</font><br>
<input type="text" class=texta name=user><br><br>
<font face="Arial" size="2">Password</font><br>
<input type="text" class=texta name=pass><br><br>
<font face="Arial" size="2">Valid Email Address</font><br>
<input type="text" class=texta name=email><br><br>
<input type="hidden" name="upgrade" value="0">
<input type="hidden" name="ref_user" value="<? print $id;?>">
<input type="submit" class=texta name="submit" value="Join Now!">
</form>
<br><br>
<center>
<a href="index.php"><font face=arial size=2>No Thanks! I'll Join later!</font>
</a></center>
</p>
<p align="center">
</p>
</td>
</tr>
<tr>
<td width="405" height="19" bgcolor="#000080">
<p align="center"><font color="#FFFFFF" size="1" face="Arial">All Rights
Reserved. 2006</font></p>
</td>
</tr>
</table>
</center>
</div>
</body>
</html>
MEMBERS:
<?
session_start();
include("config.php");
if ($user == "")
{
print "<center><font face=arial size=2 color=red>You have entered invalid account information! <a href=\"login.php\">Click here!</a></font></center>";
exit;
}
if ($pass == "")
{
print "<center><font face=arial size=2 color=red>You have entered invalid account information! <a href=\"login.php\">Click here!</a></font></center>";
exit;
}
$member_info = mysql_query("SELECT * FROM members WHERE 'user' = '$user' AND 'pass' = '$pass'");
$member_info = mysql_fetch_object($member_info);
$db_user = $member_info->user;
$db_pass = $member_info->pass;
$id = $member_info->id;
if (($user == "$db_user" ¦¦ $pass == "$db_pass"))
{
session_register("user");
session_register("pass");
print $id;
?>
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title><? print $title;?> Members Login</title>
<link rel="stylesheet" type="text/css" href="design.css" />
</head>
<body>
<div align="center">
<center>
<table border="0" width="405" height="311">
<tr>
<td width="405" height="22" bgcolor="#000080">
<p align="center">
<font face=arial size=2 color="#ffffff"><b><? print $title;?>
</b>
</font>
</p>
</td>
</tr>
<tr>
<td width="405" height="254" valign="top"> <p align="center"><font face="Arial" size="2"><b><? print $title;?> Members Main Menu</b></font>
<br>
<center>
<br>
<font face=arial size=2>Your very own <b><? print $title;?></b> website is located at: <a href="<? print $domain;?>/index.php?id=<? print $id;?>" target=_blank><? print $domain;?>/index.php?id=<? print $id;?></a></font><br><br>
<a href="profile.php?id=<? print $id;?>"><font face=arial size=2>Profile</font></a>
<br>
<a href="sponsor_ads.php?id=<? print $id;?>"><font face=arial size=2>Sponsor Ads</font></a>
<br>
<a href="featured_ads.php?id=<? print $id;?>"><font face=arial size=2>Feature Ads</font></a>
<br>
<a href="logout.php"><font face=arial size=2>Logout</font></a>
<br>
</center>
</p>
</td>
</tr>
<tr>
<td width="405" height="19" bgcolor="#000080">
<p align="center"><font color="#FFFFFF" size="1" face="Arial">All Rights
Reserved. 2006</font></p>
</td>
</tr>
</table>
</center>
</div>
</body>
</html>
<?
}
else
{
print "<center><font face=arial size=2 color=red>You have entered invalid account information! <a href=\"login.php\">Click here!</a></font></center>";
session_unregister("user");
session_unregister("pass");
session_unregister("id");
session_destroy();
When a new account is created, can you check in the database to see if a record was created (look for a table called "members" and open it to see if the record is in there).
If you don't know how to do this, I suggest getting to grips (at least a little bit) with phpMyAdmin.
When you say it is not creating the new ID number, what do you mean? Is it not appearing in the Email, or is the account just not being created?
Your Username is: #*$!x Your Password is: #*$!x.. but when I login it says... You have entered invalid account information! If the login information worked properly it should direct me to my new user index page that reads
.....http://www.example.com/advertising_forum/index.php?id=65 ...each unique user would have a different number id behind the index page web address but it's not doing that. I am not even sure if it's a permissions problem...right now all the files are chmod at 664. There was no read me files with this program. I guess I will have to read up as suggested. Thanks
[edited by: jatar_k at 7:19 pm (utc) on Aug. 17, 2006]
[edit reason]
[1][edit reason] no urls thanks [/edit] [/edit][/1]
$page = "signup.php?id=$id";
$id = $_GET['id'];
Notice the first line is expecting a variable named "$id" but that variable isn't set until the next line? Try just rearranging those two lines like so and see if that works.
$id = $_GET['id'];
$page = "signup.php?id=$id";
I'm going to assume that the code you show represents the bulk of the each script and my comments that follow are based on that assumption. If I'm wrong, and earlier portions of the code address my concerns, I apologize... but if I'm right you definitely need to know these things.
This script is insecure for a couple reasons. First, it appears as though it requires that register_globals [us2.php.net] is on. That link goes to a page explaining the problem with register globals.
Also, the input from the user is being directly placed into your database without being "escaped." What this means is that the user could easily delete your entire membership database or perform queries that reveal other members login information.
Bad:
mysql_query("INSERT INTO members (first_name,last_name,user,pass,email,upgrade,ref) Values ('$first','$last','$user','$pass','$email','$upgrade','$ref_user')");
Each user-supplied input that is inserted into the database must have mysql_real_escape_string [php.net] applied to it before insertion. That link goes to the function's manual page that also explains and shows an example of an injection attack (what can happen if you don't use the function).
Overall, I would highly recommend both getting your money back and finding a different software package or developer. I wouldn't run that code (and be able to sleep at night) without changing every line that deals with the database and user input.