Hi, I am working on a login system and I am trying to see if a user name already exist, then the user would have to choose another user name.
I am not sure how to check the table and see. And yeah, I am a php newbie.?
Thanks in advance!
Here is my code.
[code=php]<!doctype html public “-//W3C//DTD HTML 4.0 //EN”>
<html>
<head>
<title>added</title>
</head>
<body>
<?php
$dbNewUser = $_REQUEST[‘newuser’]; // this gets the user name from the register.html form
$dbNewPassword = $_REQUEST[‘newpassword’]; // this gets the password from the register.html form
$dbh=mysql_connect (“localhost”, “hrpjeff_root”, “password”) or die (‘I cannot connect to the database because: ‘ . mysql_error()); // this connects to the database of dies
mysql_select_db (“hrpjeff_time”);
$query = “INSERT INTO users (id, name, password) VALUES ( 0, ‘$dbNewUser’, MD5( ‘$dbNewPassword’ ) )”; // this inserts the new user name and password into the table
$result = mysql_query($query) or die(“Query failed: ” . mysql_error()); // if it is not saved then a error is thrown
?>
</body>
</html>