Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.
New User page?
Okay I have everything working, more or less. I need help getting my INSERT to actually INSERT what I want when I want:
<?php
srand(time());
include 'config.php';
$user = "testing";
?>
<center>
<form action="createuser.php" METHOD="post" name="newuser">
Username
<br/>
<input class="textbox" type="text" name="user"/>
<br/>
Password
<br/>
<input class="textbox" type="pass" name="pass"/>
<br/>
<input type='submit' value='<Create User>'>
</form>
</center>
<?php
mysql_select_db(unrealcomps_game);
$sql = 'INSERT INTO elitehacks_user (user_name, user_pass, hack_points, rank, user_ip) VALUES (\'user\', \'" . md5(pass) . "\', 150, 1, \'" . rand() % 255 . "." . rand() % 255 . "." . rand() % 255 . "." . rand() % 255 . "\')';
mysql_query($sql) or die('Error, insert query failed');
$query = "FLUSH PRIVILEGES";
mysql_query($sql) or die('Error, ');
?>
Any ideas?
Code update:
<?php
srand(time());
include 'config.php';
$valid = "12345";
if (isset($_POST['valid']))
?>
<center>
<form action="createuser.php" METHOD="post" name="newuser">
Username
<br/>
<input class="textbox" type="text" name="user"/>
<br/>
Password
<br/>
<input class="textbox" type="pass" name="pass"/>
<br />
Validation #
<br/>
<input class="textbox" type="text" name="valid"/>
<br/>
<input type='submit' value='<Create User>'>
</form>
</center>
<?php
if ($_POST['valid'] == $valid ) {
mysql_select_db(unrealcomps_game);
$sql = 'INSERT INTO elitehacks_user (user_name, user_pass, hack_points, rank, user_ip) VALUES (\'user\', \'" . md5(pass) . "\', 150, 1, \'" . rand() % 255 . "." . rand() % 255 . "." . rand() % 255 . "." . rand() % 255 . "\')';
echo $sql;
mysql_query($sql) or die('Error, insert query failed');
$query = "FLUSH PRIVILEGES";
mysql_query($query) or die('Error, ');
} else {
echo "dang";
}
?>
Use the isset() function on your main POST variables:
The username already taken part is easy:
Run a Select query in PHP, looking for entries 'WHERE username = POST[user]'. Then, check for the presence of a result. For some stereotyped code / pseudocode:
if (!result)
{
die('Username $user already chosen!');
}
else
{
// run Insert query
}```
Not sure what you mean about the other part.
Edit: Smileys suck. Remember, kids, disable smileys when you post code.