Ecco il codice della pagina registrazione completo...
Codice PHP:
<?php
require_once('./class/database.class.php');
require_once ('./class/security.class.php');
require_once('./functions/language.php');
$dbconnect = new Database();
$security = new Security();
$dbconnect->Connect();
$security->control_Post();
$security->control_Get();
/*if ($_SESSION['login'] == 1) {
exit("You are Already Registered!");
}
else {*/
?>
<script src="./scripts/submit.function.js"></script>
<table width="75%" align="center">
<tr>
<td width="50%" valign="middle" align="right">
<?php print($language['selectlang']); ?>:
</td>
<td width="50%" valign="bottom" align="left">
<form action="<?php $_SERVER['PHP_SELF']; ?>" method="get">
<select name="lang" >
<option value="it" onclick="Invia(this.form);" selected="selected">Italiano</option>
<option value="en" onclick="Invia(this.form);">English</option>
</select>
</form>
</td>
</tr>
<form action="<?php $_SERVER['PHP_SELF']; ?>" method="post">
<tr>
<td width="50%" height="30px" valign="middle" align="right">
<?php print($language['username']); ?>:
</td>
<td width="50%" height="30px" valign="middle" align="left">
<input type="text" value="" name="username" />
</td>
</tr>
<tr>
<td width="50%" height="30px" valign="middle" align="right">
<?php print($language['password']); ?>:
</td>
<td width="50%" height="30px" valign="middle" align="left">
<input type="password" value="" name="password" maxlength="15" />
</td>
</tr>
<tr>
<td width="50%" height="30px" valign="middle" align="right">
<?php print($language['confirmpass']); ?>:
</td>
<td width="50%" height="30px" valign="middle" align="left">
<input type="password" value="" name="confirmpass" maxlength="15" />
</td>
</tr>
<tr>
<td width="50%" height="30px" valign="middle" align="right">
<?php print($language['email']); ?>:
</td>
<td width="50%" height="30px" valign="middle" align="left">
<input type="text" value="" name="email" />
</td>
</tr>
<tr>
<td width="50%" height="30px" valign="middle" align="right">
<?php print($language['state']); ?>:
</td>
<td width="50%" height="30px" valign="middle" align="left">
<input type="text" value="" name="state" />
</td>
</tr>
<tr>
<td width="50%" height="30px" valign="middle" align="right">
<?php print($language['city']); ?>:
</td>
<td width="50%" height="30px" valign="middle" align="left">
<input type="text" value="" name="city" />
</td>
</tr>
<tr>
<td width="50%" height="30px" valign="middle" align="right">
<?php print($language['birthday']); ?>:
</td>
<td width="50%" height="30px" valign="middle" align="left">
<select name="day">
<?php
for($i=1; $i<32; $i++){
print("<option value=\"$i\">$i</option>\n");
}
?>
</select>
<select name="month">
<?php
for($i=1; $i<13; $i++){
print("<option value=\"$i\">$i</option>\n");
}
?>
</select>
<select name="year">
<?php
for($i=1950; $i<2010; $i++){
echo "<option value=\"$i\">$i</option>\n";
}
?>
</select>
</td>
</tr>
<tr>
<td width="50%" height="30px" valign="middle" align="right">
<?php print($language['captcha']); ?>:
</td>
<td width="50%" height="30px" valign="middle" align="left">
<input type="text" name="captcha" value="" maxlength="5" />[img]./functions/captcha.php[/img]
</td>
</tr>
<tr>
<td width="100%" height="30px" valign="middle" align="center" colspan="2">
<input type="submit" value="<?php print($language['register']); ?>" name="submit" />
<input type="reset" value="<?php print($language['reset']); ?>">
</td>
</tr>
</form>
</table>
<?php
session_start();
if (isset($_POST['submit'])) {
$username = $_POST['username'];
$password = $_POST['password'];
$confirmpass = $_POST['confirmpass'];
$email = $_POST['email'];
$state = $_POST['state'];
$city = $_POST['city'];
$captcha = $_POST['captcha'];
$birth = $_POST['year']."/".$_POST['month']."/".$_POST['day'];
$date = date("y/m/d");
if ($username == NULL || $password == NULL || $confirmpass == NULL || $email==NULL || $captcha == NULL) {
print("You Have Left Empty an Important Field!");
}
else {
if ($password != $confirmpass) {
print("Your Password does not Match with the Confirm!");
}
elseif ($captcha != $_SESSION['captcha']) {
print("Your Security Code is Wrong!");
}
else {
$username = $security->control_Username($username);
$password = $security->control_Password($password);
$confirmpas = $security->control_Password($confirmpass);
$email = $security->control_Email($email);
$state = $security->control_Other($state);
$city = $security->control_Other($city);
$captcha = $security->control_Other($captcha);
$password = md5($password);
$queryuser = $dbconnect->Query("SELECT * FROM pp_users WHERE username='$username'");
$queryemail = $dbconnect->Query("SELECT * FROM pp_users WHERE email='$email'");
if ($dbconnect->numRow($queryuser) != 0) { // Da Bianco
print("This Username Already Exist!");
}
elseif ($dbconnect->numRow($queryemail) != 0) { // Da Bianco
print("This Email Already Exist!");
}
else {
$dbconnect->Query("INSERT INTO pp_users SET username='$username', password='$password', email='$email', state='$state', city='$city', date_birth='$birth', date_reg='$date'");
print("The Registration has Finished!
We have Sent You an Email to Activate your Account!");
}
}
}
}
?>