<form action="finish.php" method="POST">Email: <input type="text" name="email" /></br>Username: <input type="text" name="username" /></br>Password: <input type="password" name="password" /></br>Re-type Password: <input type="password" name="re-password" /></br>Birth Year: <input type="text" name="birth" /></br><input type="submit" /></form>
this was the registration html file
<?php// CHANGE THESE VALUESDEFINE ('DB_USER', 'MY USERNAME');DEFINE ('DB_PASSWORD', 'MY PASSWORD');DEFINE ('DB_HOST', 'MY DB HOST');DEFINE ('DB_NAME', 'MY NAME); $dbc = @mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) OR die ('Could not connect to MySQL: ' . mysql_error()); @mysql_select_db (DB_NAME) OR die('Could not select the database: ' . mysql_error() );?>
some of those values i left out but that was called connect.php
<?php//STEP 1 Connect To Database$connect = mysql_connect("HOST","USERNAME","PASSWORD");if (!$connect){die("MySQL could not connect!");}$DB = mysql_select_db('scope');if(!$DB){die("My SQL could not select Database!");}//STEP 2 Declare Variables$Username = $_POST['username'];$Email = $_POST['email'];$Email1 = "@";$Email_Check = strpos($Email,$Email1);$Password = $_POST['password'];$Re_Password = $_POST['re-password'];$Birth = $_POST['birth'];//STEP 3 Check To See If All Information Is Correctif($Username == ""){die("Opps! You don't enter a username!");}if($Password == "" || $Re_Password == ""){die("Opps! You didn't enter one of your passwords!");}if($Birth == ""){die("Opps! You never entered in your birth year!");}if($Password != $Re_Password){die("Ouch! Your passwords don't match! Try again.");}if($Email_Check === false){die("Opps! That's not an email!");}//STEP 4 Insert Information Into MySQL Databaseif(!mysql_query("INSERT INTO users (email, username, password, birth)VALUES ('$Email', '$Username', '$Password', '$Birth')")){die("We could not register you due to a mysql error (Contact the website owner if this continues to happen.)");}?>
this was the finish.php which i also left out some things. this file was the file the register html file sent info to
<form action="members.php" method="POST" />Username: <input type="text" name="username" /></br>Password: <input type="password" name="password" /></br><input type="submit" />
this was the login form (but if anyone knows how it can make it so you login and stayed logged in on other pages and you can logout, please tell me)
<?php//STEP 1 Connect To Database$connect = mysql_connect("HOST","USERNAME","PASSWORD");if (!$connect){die("MySQL could not connect!");}$DB = mysql_select_db('scope');if(!$DB){die("MySQL could not select Database!");}//STEP 2 Declare Variables$Name = $_POST['username'];$Pass = $_POST['password'];$Query = mysql_query("SELECT * FROM Users WHERE Username='$Name' AND Password='$Pass'");$NumRows = mysql_num_rows($Query);$_SESSION['username'] = $Name;$_SESSION['password'] = $Pass;//STEP 3 Check to See If User Entered All Of The Informationif(empty($_SESSION['username']) || empty($_SESSION['password'])){die("Go back and login before you visit this page!");}if($Name && $Pass == ""){die("Please enter in a name and password!");}if($Name == ""){die("Please enter your name!" . "</br>");}if($Pass == ""){die("Please enter a password!");echo "</br>";}//STEP 4 Check Username And Password With The MySQL Databaseif($NumRows != 0){while($Row = mysql_fetch_assoc($Query)){$Database_Name = $Row['username'];$Database_Pass = $Row['password'];}}else{die("Incorrect Username or Password!");}if($Name == $Database_Name && $Pass == $Database_Pass){// If The User Makes It Here Then That Means He Logged In Successfullyecho "Hello " . $_SESSION['username'] . "!";}?><html><body><p>Here is where you can put information for the user to see when he logs on. (Anything inside these html tags!)</p></body></html>
this file is called members.php and it stores the info