PunkGo
09-14-2003, 05:40 AM
hey, im bored so imma show u how to make ur very own user/login thingy with php
step 1. make a register page...
<html>
<h1>Register Here</h1>
<br><br>
<strong>Username</strong>
<form method="post" action="register_check.php">
<input type="text" name="username"><br><br>
<strong>Password</strong>
<input type="password" name="password"><br><br>
<input type="submit" value="Submit">
<input type="reset" value="Clear">
</form>
</html>
ok...les explain...everyone shood know the html, for the action i put register_check.php so all this info entered on this page will goto the register_check.php
ok, off to register_check.php......
<?php
session_start();
mysql_connect("localhost", "username", "password")
or die(mysql_error());
mysql_select_db("dbname")
or die(mysql_error());
$username = $HTTP_POST_VARS['username'];
$passwd = $HTTP_POST_VARS['password'];
$query = "SELECT * FROM tablename WHERE username='$username'";
$result = mysql_query($query);
$rows = mysql_num_rows($result);
if($rows > 0){
echo "Username ";
echo $username;
echo " Is Taken, Please Try Again!";
}
else {
mysql_query("INSERT INTO tablename (username, password)
VALUES('$username', '$passwd');
echo 'Sucessfully Registered!';
}
?>
thats all im writing for now...if u want me to continue this tutorial...reply to this..
step 1. make a register page...
<html>
<h1>Register Here</h1>
<br><br>
<strong>Username</strong>
<form method="post" action="register_check.php">
<input type="text" name="username"><br><br>
<strong>Password</strong>
<input type="password" name="password"><br><br>
<input type="submit" value="Submit">
<input type="reset" value="Clear">
</form>
</html>
ok...les explain...everyone shood know the html, for the action i put register_check.php so all this info entered on this page will goto the register_check.php
ok, off to register_check.php......
<?php
session_start();
mysql_connect("localhost", "username", "password")
or die(mysql_error());
mysql_select_db("dbname")
or die(mysql_error());
$username = $HTTP_POST_VARS['username'];
$passwd = $HTTP_POST_VARS['password'];
$query = "SELECT * FROM tablename WHERE username='$username'";
$result = mysql_query($query);
$rows = mysql_num_rows($result);
if($rows > 0){
echo "Username ";
echo $username;
echo " Is Taken, Please Try Again!";
}
else {
mysql_query("INSERT INTO tablename (username, password)
VALUES('$username', '$passwd');
echo 'Sucessfully Registered!';
}
?>
thats all im writing for now...if u want me to continue this tutorial...reply to this..