I need somthing that is a template that is easy to edit and has the sql code with it.

    That's delightful - I'll start right away.

    See you sooon - ttfn!

    Mwah! xxx

      You don't really think he's serious, do you? Post some code and we'll help you with it. We won't write something for you.

        Login.php wount work and im fierd if i dont get it working. :glare:

        <?php
        
        //Database Information
        
        (HEHE YOU WISH)
        
        //Connect to database
        
        mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
        mysql_select_db($dbname) or die(mysql_error());
        
        session_start();
        $username = $_POST[‘username’];
        $password = md5($_POST[‘password’]);
        
        $query = "SELECT * FROM users WHERE username=’$username’ AND password=’$password’";
        
        $result = mysql_query($query) or die("Query problem: " . mysql_error()); 
        
        
         if (!mysql_num_rows($result)) 
        { 
            $error = “BadLogin”; 
            include "includes/login.html"; 
        } 
        else 
        { 
            $_SESSION['username'] = $username; 
            include "mainpage.html"; 
        } 
        ?>

          What is it doing wrong?

          Have you echoed the query to the screen before sending it to the database? Does it look like what you expected?

          Your $_POST indices look suspect. Why isn't the closing quote the same as the opening one?

            Indeed, why are they curly quotes in the first place? (You'll note that the syntax highlighting doesn't recognise them as string delimiters - nor would PHP.)

              im new to php and i dont get wut your say plz paste the correct code.

                What they're telling you is that the quote marks you are using to indicate a string to PHP are incorrect. You're using curly quotes when they should be straight:

                e.g.

                $username = $_POST[‘username’];

                should be:

                $username = $_POST['username'];

                and

                $error = “BadLogin”;

                should be:

                $error = "BadLogin";

                Go through your code and replace the curly quotes with straight quotes.

                Bur147

                  How in the world did you get those characters into your code in the first place? Please don't tell me you used something like Microsoft Word.

                    Use

                    '

                    instead of

                    `

                    Same for

                    "

                    instead of

                      OK,

                      I think you've already been told the exact syntax problems in your code, so no need to repeat those here.

                      What might be worth thinking about now is how you go about debugging your code. If you have a chunk of code which doesn't work, you need to keep breaking it down into smaller slices to see how much of it works.

                      If it throws up error messages, read them. They are there to help you. If you read them and don't understand, type the error message into your favourite search engine and see if that shows up anything. If that doesn't get you anywhere, paste the code and the error message here, and see if anyone else can show you the syntax error.

                      If it doesn't throw up syntax errors, you can fall back on inserting "echo" commands into your code. These will help highlight which areas of your code are being run, which aren't and what the value of key variables are at certain points.

                      Judging by your post and response. I would imagine that you're not just new to PHP but that you're new to programming in general. Welcome aboard. It can be a very rewarding career or hobby.

                        Write a Reply...