CariDotMy

 Forgot password?
 Register

ADVERTISEMENT

View: 2459|Reply: 5

cane nak wat register form n login gune php

[Copy link]
Post time 10-8-2007 11:27 PM | Show all posts |Read mode
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]
Reply

Use magic Report


ADVERTISEMENT


Post time 12-8-2007 06:07 AM | Show all posts
nak tanya...

form action ko dalam file login ape?

tables dalam database kompem ke sama?
Reply

Use magic Report

 Author| Post time 13-8-2007 12:25 AM | Show all posts
dah dpt penyelesaiannye..database x sama rupenye..hehe..soryy..anyway...thanks a lot..
Reply

Use magic Report

Post time 13-8-2007 05:11 AM | Show all posts

Reply #3 kupu2siang's post

aku dah agak da...   tu pasal la tak dapat nak link
Reply

Use magic Report

 Author| Post time 16-8-2007 08:09 PM | Show all posts
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...
Reply

Use magic Report

Post time 16-8-2007 08:14 PM | Show all posts
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 ]
Reply

Use magic Report

Follow Us
You have to log in before you can reply Login | Register

Points Rules

 

ADVERTISEMENT



 

ADVERTISEMENT


 


ADVERTISEMENT
Follow Us

ADVERTISEMENT


Mobile|Archiver|Mobile*default|About Us|CariDotMy

3-1-2025 01:08 AM GMT+8 , Processed in 0.136002 second(s), 19 queries , Gzip On, Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

Quick Reply To Top Return to the list