Código PHP:
<?php
require('../include/database_connection.php');
if($_POST['yes']=='1'){
$username=$_POST[username];
$password=$_POST[password];
$email=$_POST[email];
$firstname=$_POST[firstname];
$lastname=$_POST[lastname];
$day=$_POST[day];
$month=$_POST[month];
$year=$_POST[year];
$country=$_POST[country];
$query="SELECT * FROM users WHERE username='$username'";
$result=mysql_db_query($base,$query,$conn) or die (mysql_error());
if(mysql_num_rows($result)==0)
{
//delimitation
mysql_query('INSERT INTO users (username, password, email, name, lastname, day, month, year, country)
VALUES ("' . $username . '", "' . $password . '", "' . $email . '", "' . $firstname . '",
"' . $lastname . '", "' .$day. '", "' .$month. '", "' .$year. '", "' .$country. '");')or $error = true;
if(isset($error))
echo 'We are sorry, but you were not able to register, please contact the administrator.<br><small>' . mysql_error() . '</small>';
else
echo 'Registration successful! Now you can <a href="../login.php">Log In</a>.';
exit;
}
}//End of IF
else
{
?>
<SCRIPT LANGUAGE="javascript">
alert("The Username already exists, please try again...");
history.go(-1);
</SCRIPT>
<?
} //End of Else
?>