Tak więc z dedykacją dla Ciebie, cały kod:
<?php
if (isset($_POST['submit'])) { // if form has been submitted
/* check they filled in what they supposed to,
passwords matched, username
isn't already taken, etc. */
if (!$_POST['uname'] || !$_POST['passwd'] ||
!$_POST['passwd_again'] || !$_POST['email']) {
die('You did not fill in a required field.');
}
//validate the inputs
$_POST['uname'] = safe($_POST['uname']);
$_POST['passwd'] = safe($_POST['passwd']);
$_POST['email'] = safe($_POST['email']);
$_POST['tele'] = safe($_POST['tele']);
$_POST['gg'] = safe($_POST['gg']);
// check if username exists in database.
$qry = "SELECT 'username' FROM 'users' WHERE 'username' = '".$_POST['uname']."'";
// check passwords match
if ($_POST['passwd'] != $_POST['passwd_again']) {
die('Passwords did not match.');
}
// check e-mail format
die('Invalid e-mail address.');
}
// check show_email data
if ($_POST['show_email'] != 0 & $_POST['show_email'] != 1) {
}
// now we can add them to the database.
// encrypt password
$_POST['passwd'] = sha1($salt.$_POST['passwd']);
$regdate = date('m d, Y');
$insert = "INSERT INTO 'users' (
username,
password,
regdate,
email,
tele,
gg,
show_email)
VALUES (
'".$_POST['uname']."',
'".$_POST['passwd']."',
'$regdate',
'".$_POST['email']."',
'".$_POST['tele']."',
'".$_POST['gg']."',
'".$_POST['show_email']."')";
?>
<h1>Registered</h1>
<p>Thank you, your information has been added to the database,
you may now <a href="index.php?id=login" title="Login">log in</a>.</p>
<?php
} else { // if form hasn't been submitted
?>
<h1>Register</h1>
<form action="index.php?id=register" method="post">
<table align="center" border="1" cellspacing="0" cellpadding="3">
<tr><td>Username*:</td><td>
<input type="text" name="uname" maxlength="40">
</td></tr>
<tr><td>Password*:</td><td>
<input type="password" name="passwd" maxlength="50">
</td></tr>
<tr><td>Confirm Password*:</td><td>
<input type="password" name="passwd_again" maxlength="50">
</td></tr>
<tr><td>E-Mail*:</td><td>
<input type="text" name="email" maxlength="100">
</td></tr>
<tr><td>Telefon:</td><td>
<input type="text" name="tele" maxlength="150">
</td></tr>
<tr><td>GaduGadu</td><td>
<input type="text" name="gg" maxlength="150">
</td></tr>
<tr><td>Newsletter?</td><td>
<select name="show_email">
<option value="1" selected="selected">Yes</option>
<option value="0">No</option></select>
</td></tr>
<tr><td colspan="2" align="right">
<input type="submit" name="submit" value="Sign Up">
</td></tr>
</table>
</form>
<?php
}
?>