View: 2459|Reply: 5
|
cane nak wat register form n login gune php
[Copy link]
|
|
sy dah wat 1 register form..tp x dpt nak link laa..leh x sapa2 yg tau tu tlg check coding sy btoi ke x..
<?PHP
//Database Information
$dbhost = "localhost";
$dbname = "your database name";
$dbuser = "username";
$dbpass = "yourpass";
//Connect to database
mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
mysql_select_db($dbname) or die(mysql_error());
$name = $_POST['name'];
$email = $_POST['email'];
$username = $_POST['username'];
$password = md5($_POST['password']);
// lets check to see if the username already exists
$checkuser = mysql_query("SELECT username FROM users WHERE username='$username'");
$username_exist = mysql_num_rows($checkuser);
if($username_exist > 0){
echo "I'm sorry but the username you specified has already been taken. Please pick another one.";
unset($username);
include 'register.html';
exit();
}
// lf no errors present with the username
// use a query to insert the data into the database.
$query = "INSERT INTO users (name, email, username, password)
VALUES('$name', '$email', '$username', '$password')";
mysql_query($query) or die(mysql_error());
mysql_close();
echo "You have successfully Registered";
// mail user their information
$yoursite = 慬url]www.blahblah.com[/url] |
|
|
|
|
|
|
|
nak tanya...
form action ko dalam file login ape?
tables dalam database kompem ke sama? |
|
|
|
|
|
|
|
dah dpt penyelesaiannye..database x sama rupenye..hehe..soryy..anyway...thanks a lot.. |
|
|
|
|
|
|
|
Reply #3 kupu2siang's post
aku dah agak da... tu pasal la tak dapat nak link |
|
|
|
|
|
|
|
register aku dah dpt wat..dah link kat database..prob aku skang ngan login..aku xdpt nak link la.. username n password kat page login tu amik dr database yg kte register tu laa kan??tp nape dia kata wrong username n password ehh padahal dah btoi dah aku masukkan..tlgg... |
|
|
|
|
|
|
|
disebabkan ko buat time nk register tuh
md5($_POST['password']);
so time nk login tuh.. ko md5($_POST['password']); dulu baru compare data pasword dalam db tuh..
[ Last edited by liverpoolfctv at 16-8-2007 08:16 PM ] |
|
|
|
|
|
|
| |
|