Jump to content

scope

Members
  • Posts

    7
  • Joined

  • Last visited

scope's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. I am trying to set up a mysql/php login and register system but whenever i try it fails. I was wondering if someone could write code that can do this with the following things: Database name = DBNAMEDatabase tabel = DBTABLEHost name = EXAHOST.COMHost username = HOSTUSERHost password = HOST PASSWebsite name = WEBNAME.ORG If anymore things are needed please tell me, and if someone could make one that works i would REALLY appreciate it Thanks
  2. ok... I did by the way check the links but i will recheck.
  3. oh and fyi yes i did fill in the db credentials
  4. I know get this error: Warning: mysql_connect() [function.mysql-connect]: Lost connection to MySQL server at 'reading initial communication packet', system error: 111 in /hermes/bosweb26b/b867/ipg.escratchorg/scope/source/include/fg_membersite.php on line 733 I also now use code from this site instead of the other stuff:http://www.html-form-guide.com/php-form/php-registration-form.html
  5. <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
  6. no i made a register html file with a form that is supposed to send it to a thing called process.php which sends it to the mysql server. Basically i am creating a registration form
  7. So me and a friend have a website (actually my friends but i work on it with him). He set up a mysql database and i set up a php registration thingy. It through back this error: Warning: mysql_connect() [function.mysql-connect]: Lost connection to MySQL server at 'reading initial communication packet', system error: 111 in /hermes/bosweb26b/b867/ipg.escratchorg/scope/process.php on line 6Lost connection to MySQL server at 'reading initial communication packet', system error: 111 Please help and if you need me to show files i will. (website is scope.escratch.org/register.html) ~SCOPE
×
×
  • Create New...