Hello,

What I need is a registration/login PHP script that uses mySQL. I have already setup the mySQL database with required fields.

Database details:
Database: localhost
Database name: database1
Database password: password1
Table = users

Can someone just create me a simple register page with the following fields:
Email (database field=email), Password (database field=password), Verify Password, Company Name (database field=company_name), Phone (database field=phone), Fax (database field=fax), Address (database field=address).

All fields are required except fax 😉

And a login page with the following fields:
Email, Password

After login, it should go into a protected page that you can only view if you have logged in.

I really really need this script fairly urgently, so thank you to anyone that can help me in this regard 🙂 🙂

    I don't really understand what you mean?

    I've created a table already in phpmyadmin but I don't know how to write the PHP coding to go with it for what I need, as I have described above.

      It will take time to show you how to write codes for php & mysql.
      But it's not hard at all if you want to learn it.
      My advise is go buy a book about PHP Programming that have SQL section also. It will tell you from the very beginning the procedure about connecting to database and how the SQL works.

      Hope this helps ... 😉

        first of, there really are dozens of complete user registration scripts out there. Just open google and search for them.

        But, if you want to do it yourself (at least a basic version) (and there's really no other way if you want to be able to modify and understand PHP code), here's some crude list to follow.

        What you'll need (you could reduce these pages and collapse any or all of them into one page, but for reasons of simplicity I list each one as an extra file)

        • a page with an input field for the email and one for the password, contained in a form with method post, directing to a page that handles the login logic (like action="doLogin.php")

        • the script to handle the login: retrieve the password from the database (based on the entered email), compare it to the entered one, if they match, redirect to the desired safe page; set a session variable that states that the user has properly logged in. On the redirected page, check whether the session variable isset and has the proper value, else redirect to the login page.
          Additonal: You may want to check if the entered email and password are valid (thats a matter of definition, but e.g. email must contain "@" and at least one dot) before querying the db to avoid overhead)

        • a html page that contains a form for registration (basically all fields you listed above, with an action to the registration handler script

        • the script that handles the registration: check if all of the fields contain valid data (email as listed above e.g., or passwords min length, or whatever), and if they do, submit them to the database with a SQL "Insert into" statement. Your email probably is your primary key (at least if there's only one registration per Email) so you'll either have to catch the SQL error when someone tries to register with an Email ad. already stored or else have to check before the insertion.
          If the data was incorrect, you'll redirect to the reg form; if you want to take it one step further, you'll store the wrong data and print it in red or display custom error messages for each field.

        Even while writing this list, a dozen things that I'd probably do if i were to write this come to mind. It's easy to expand though, so a basic version should be enough though.

        Be sure to read up on sessions, mail, mysql in the manual at www.php.net

        Good luck

          OK, I made the login script with a little help from a friend, but if the email (login name) doesn't exist it comes up with this error:

          "Warning: Unable to jump to row 0 on MySQL result index 2 in /blah/blah/login.php on line 4"

          <?
          include "config.php"; 
          $query = mysql_query("SELECT * FROM users WHERE email='$email'");
          $pass = mysql_result($query, 0, "password");
          if(!$passw) {
          echo '
          blah
          ';
          

          If the email exists and the password is wrong, then it wont come up with that error.

          I tried putting if(!$email) etc., but that didn't work??

          Anyway, if you could help me on this one it would be great.

            <?

            include "config.php";
            $query = mysql_query("SELECT * FROM users WHERE email='$email'");

            $row=mysql_fetch_row($query);

            if ($pass<>$row['password']){
            echo "no valid user";
            exit();
            }else{
            //redirect to another page
            header("location:http://www.mysite.com/welcome.php");
            }

            ?>

              Write a Reply...