Jedi Josh
08-15-2003, 12:46 AM
So I won't have duplicate "usernames" in my database. I've tried for about an hour and a half now to add such functionality to this script, but I can't. Check out the whole thing.
<?
$usr = "jedijosh";
$pwd = "";
$db = "memberdb";
$host = "localhost";
// connect to database
$cid = mysql_connect($host,$usr,$pwd);
mysql_select_db($db);
?>
<html>
<head>
<title>Member Registration</title>
</head>
<body bgcolor="#ffffff">
<h2> Add Member </h2>
<?
if ($_SERVER['REQUEST_METHOD'] == "POST")
{
$username = addslashes($_POST["username"]);
$password = addslashes($_POST["password"]);
$email = addslashes($_POST["email"]);
$password = MD5($password);
$sql = " INSERT INTO members (username, password, email) VALUES ('$username', '$password','$email') ";
$result = mysql_query($sql, $cid);
print "<p><b>New member added</b></p>\n";
print "<a href='http://localhost/memberlist.php'>View Data</a>\n";
}
?>
<form name="submit" action="register.php" method="POST">
<table>
<tr><td><b>Name: </b> </td><td><input type="text" name="username" size=40></td></tr>
<tr><td><b>Password:</b> </td><td><input type="text" name="password" size=40></td></tr>
<tr><td><b>E-mail: </b> </td><td><input type="text" name="email" size=40></td></tr>
<tr><th colspan=2><p><input type="submit" value="Register"></p></th></tr>
</table>
</form>
</body>
</html>
Basically, if a user submits a username which is already taken, the script should print something like "taken". Any help guys? http://forums.massassi.net/html/biggrin.gif
------------------
To think that once I could not see beyond the veil of reality, to see those who dwell behind. I was once a fool.
<?
$usr = "jedijosh";
$pwd = "";
$db = "memberdb";
$host = "localhost";
// connect to database
$cid = mysql_connect($host,$usr,$pwd);
mysql_select_db($db);
?>
<html>
<head>
<title>Member Registration</title>
</head>
<body bgcolor="#ffffff">
<h2> Add Member </h2>
<?
if ($_SERVER['REQUEST_METHOD'] == "POST")
{
$username = addslashes($_POST["username"]);
$password = addslashes($_POST["password"]);
$email = addslashes($_POST["email"]);
$password = MD5($password);
$sql = " INSERT INTO members (username, password, email) VALUES ('$username', '$password','$email') ";
$result = mysql_query($sql, $cid);
print "<p><b>New member added</b></p>\n";
print "<a href='http://localhost/memberlist.php'>View Data</a>\n";
}
?>
<form name="submit" action="register.php" method="POST">
<table>
<tr><td><b>Name: </b> </td><td><input type="text" name="username" size=40></td></tr>
<tr><td><b>Password:</b> </td><td><input type="text" name="password" size=40></td></tr>
<tr><td><b>E-mail: </b> </td><td><input type="text" name="email" size=40></td></tr>
<tr><th colspan=2><p><input type="submit" value="Register"></p></th></tr>
</table>
</form>
</body>
</html>
Basically, if a user submits a username which is already taken, the script should print something like "taken". Any help guys? http://forums.massassi.net/html/biggrin.gif
------------------
To think that once I could not see beyond the veil of reality, to see those who dwell behind. I was once a fool.