Account Creation Help

JealY

LOMCN VIP
VIP
Nov 28, 2004
5,354
52
305
England
Well i've not tested this (not even used MSSQL with php) but i've had a look and it looks similar to MySQL in terms of PHP.

As people seem to be having trouble creating an account page, so I thought i'd help a bit.

NOTE - This is just a very rough guide, this should help you create an account page.

Right, first of all you need a page to hold the form in which people fill out to create an account. Somewhere in this page you will need a form like so;

Code:
<form method="post" action="create.php">
Login: <input type="text" name="Login" size="30"  />
<br />
Password: <input type="password" name="Password" size="15"  />
<br />
<input type="submit" value="Create" />
</form>
I am unsure of the max sizes for username & password, so they're at 30 & 15 relatively. Obviously you will want a password confirmation, but i'll leave that to you.

Now that is the user side, this is a run down of what you'll want server side (PHP).

From the form the user has just created, we need to define the fields
PHP:
$Login = $_POST['Login'];
$Password = $_POST['Password'];
You'll want to connect to the database
PHP:
mssql_connect ("localhost", "sa", "password") or die ('I cannot connect to the database');
Select the database
PHP:
mssql_select_db("accountdatabase");
Create a query for inserting the values into the table
PHP:
$query="INSERT INTO accountdatabase (FLD_LOGINID, FLD_PASSWORD) VALUES ('$Login', '$Password')";
As you probably noticed, there are many other values. As I have said this is just how to do it, this is not all you need.

Run the query
PHP:
mssql_query($query) or die ('Error creating account');
& you also might want some sort of confirmation message afterwards, to do that use
PHP:
echo "Created";
or whatever.


Obviously this is just for learning purposes. Hopefully it might help a bit. I'm no expert, i've only ever used PHP with MySQL.
 

Celsius

LOMCN Veteran
Veteran
Dec 31, 2008
1,155
17
124
Looks good, however, before doing the insert query you need to do a select query using the information the user is using. This will allow you to check if the account with them details already exists and stop duplicate accounts.
 

JealY

LOMCN VIP
VIP
Nov 28, 2004
5,354
52
305
England
Yeah true, but as I say it's just to show people how to make the accounts. I heard the files are buggy as shit anyway so I doubt they will be used properly - hopefully this will encourage people to learn a bit so good servers can be made in the future.