 WS Newbie ~PHP Nuke User~Posts: 41
Next Group: 9 posts
JRowe wrote:I'm trying to put together a CMS shell for myself and I'm wondering if someone could give me a hand.
I want to check if a username has been taken during the registration process. The only problem is that there are two databases. One is the billing database (a generic subs manager i threw together) and the other is the game database. I want to check if a username has been taken in the games database, and if so, send the user back to the signup page.
Here's my code:
Code: |
<html>
<head>
<title>Game Subscription</title>
</head>
<body>
<h1>Game Subscription</h1>
<?php
//HERE THERE BE GAMES
$_POST[gametitle] = 'Game Name Here';
//HERE THERE BE GAMES
//SET USER INFO
$firstname=$_POST[firstname];
$lastname=$_POST[lastname];
$address=$_POST[address];
$city=$_POST[city];
$state=$_POST[state];
$country=$_POST[country];
$zipcode=$_POST[zipcode];
$email=$_POST[email];
$username=$_POST[username];
$password=$_POST[password];
$gametitle=$_POST[gametitle];
$ccnumber=$_POST[ccnumber];
$ccexpmonth=$_POST[ccexpmonth];
$ccexpyear=$_POST[ccexpyear];
$ccCVN=$_POST[ccCVN];
//SET USER INFO
//GET DATE
$date=date("y-m-d H:i:s");
//GET DATE
//PARSE USER INFO FOR BLANK FORMS
if(!$firstname || !$lastname || !$address || !$city || !$state || !$country || !$zipcode || !$email || !$username || !$password || !$gametitle || !$ccnumber || !$ccexpmonth || !$ccexpyear || !$ccCVN)
{
echo 'Please fill out all the required information. Press the back button on the browser, or hit Alt+Left, and fill out all the required information.';
exit;
}
//PARSE USER INFO FOR BLANK FORMS
//PARSE USER INFO FOR EXISTING USERNAME
//PARSE USER INFO FOR EXISTING USERNAME
//SET DATABASE SERVER INFORMATION AND CONNECTION INTO BILLING DB
$link = mysql_connect('localhost', 'dadada', 'dadada');
//SET DATABASE SERVER INFORMATION AND CONNECTION INTO BILLING DB
//OPEN DATABASE INTO BILLING DB
$open = mysql_select_db("BillingDB");
//OPEN DATABASE INTO BILLING DB
//COMMAND TO INSERT INFORMATION INTO DATABASE INTO BILLING DB
$information = "insert into Customer(FirstName, LastName, Address, City, State, country, ZipCode, Email, Username, Password, Game, CardNumber, CardExpMonth, CardExpYear, CardCVN) values('$firstname','$lastname','$address','$city','$state','$country','$zipcode','$email','$username','$password','$gametitle','$ccnumber','$ccexpmonth','$ccexpyear','$ccCVN')";
//COMMAND TO INSERT INFORMATION INTO DATABASE INTO BILLING DB
//COMPLETE INFORMATION UPDATE OR INSERTION INTO BILLING DB
mysql_query($information);
//COMPLETE INFORMATION UPDATE OR INSERTION INTO BILLING DB
//SET DATABASE SERVER INFORMATION AND CONNECTION INTO GAME DB
$link = mysql_connect('localhost', 'dadada', 'dadada');
//SET DATABASE SERVER INFORMATION AND CONNECTION INTO GAME DB
//OPEN DATABASE INTO GAME DB
$open = mysql_select_db("dadada");
//OPEN DATABASE INTO GAME DB
//COMMAND TO INSERT INFORMATION INTO DATABASE INTO GAME DB
$gameupdate = "insert into users(pay,idname, passwd,regi_date,enable,name,lastname,email,city,region,countryeic) values('c','$username','$password','$date','1','$firstname','$lastname','$email','$city','$state','$country')";
//COMMAND TO INSERT INFORMATION INTO DATABASE INTO GAME DB
//COMPLETE INFORMATION UPDATE OR INSERTION INTO GAME DB
mysql_query($gameupdate);
//COMPLETE INFORMATION UPDATE OR INSERTION INTO GAME DB
?>
</body>
</html> |
I need a function that checks whether $username already exists in the game database, and if so, tells you to go back and choose a different name.
So, this is what I came up with, and it doesnt work, heh.
Code: |
$link = mysql_connect('xx.xx.xxx.xxx', 'Username', 'Password');
$UNCheck = "SELECT * from game_db WHERE idname='$username'";
if(mysql_query($UNCheck)->num_rows>0)
{
echo 'This username has been used already. Please hit the back button on your browser, or press Alt+Left, and choose a new Username.';
exit; |
Can someone clean that up for me, or show me what I did wrong? Much thanks for any assistance.
idname is the username within the game database.
Posted: Wed May 31, 2006 2:35 pm
 Site Admin ~PHP Nuke User~ Posts: 3366
StaffNext Group: 1634 posts
admin(Mark) wrote:hi, something like this should work
Code: |
//ACCESS DATABASE
$userName = 'USERNAME';
$userPass = 'PASSWORD';
$dbName = 'DATABASENAME';
$mysql_access = mysql_connect("localhost", $userName, $userPass);
mysql_select_db($dbName, $mysql_access);
//END DATABASE ACCESS
$query = "SELECT * FROM game_db WHERE idname='$username'";
$result = mysql_query($query, $mysql_access);
if(mysql_num_rows($result)) {
//THE USER EXIST SO ECHO SOMETHING HERE
echo 'USER EXIST';
} else {
//USER DOES NOT EXIST
echo 'YOUR ARE NOT A MEMBER';
}
|
Posted: Wed May 31, 2006 3:50 pm
 WS Newbie ~PHP Nuke User~Posts: 41
Next Group: 9 posts
JRowe wrote:awesomeness. Thanks much man
Posted: Wed May 31, 2006 4:19 pm
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
 |