I'm having a problem with this script which allows users to register on a website I am designing. The script accepts a username, password, email address, advertisement type, and advertisement content. I intended to design this script so that upon entering AT LEAST the username,password, and email, the account would be created. However, when I do not enter a password, the account is still created, and the entry shows up in the MySQL database as a single space.
Kindly help me
Code: Select all
<?php
if(isset($_POST['uid']) && isset($_POST['pwd']) && isset($_POST['email']))
{
include('connect.php');
$uid = $_POST['uid'];
$pwd = $_POST['pwd'];
$email = $_POST['email'];
$adtype = $_POST['adtype'];
$adcontent = $_POST['adcontent'];
$availability = "SELECT * FROM logins WHERE username='$uid'";
$result = mysql_query($availability);
$count = mysql_num_rows($result);
if($count==0)
{
mysql_query("INSERT INTO logins (username,password,adtype,adcontent,email) VALUES ('$uid','$pwd','$adtype','$adcontent','$email')");
echo "<script>alert('Your account has been created! Thanks!');</script>";
}
else
{
echo "<script>alert('It seems that your account name is not available. Please choose a different account name!');</script>";
}
}
else
{
echo "<form method='post' action='#'>";
echo "*Username: <input type='text' name='uid' size='16' maxlength='16'/><br>";
echo "*Password: <input type='password' name='pwd' size='20' maxlength='20'/><br>";
echo "*E-Mail Address: <input type='text' name='email' size='40' maxlength='40'/><br>";
echo "Adtype: <input type='text' name='adtype' size='20' maxlength='20'/><br>";
echo "Ad Content: <input type='textarea' name='adcontent' cols='100' rows='20' maxlength='2000'/><br>";
echo " <input type='submit' name='submit' value='Create User!'/>";
echo "</form>";
}
?>