hi, iam new at php and iam doing a tutorial from youtube. 
I am keep getting 2 errors    
1st error is "Column count doesn't match value count at row 1"
2nd error is nothing shows up when i do


     <?php echo $error_message; ?>



full code of registration file











<?php
            /* when a user login it give a vaiable. Its for testing if user login or logout*/
            session_start(); 
            include("include/connect.php");
        include("include/html_code.php");

        //if they hit sumbit button, than check for errors.
        if(isset($_POST['submit'])) 
        {
            $error = array();

            //if user filed is empty, store error
            //else if = every thing is ok
            if(empty($_POST['username']))
            {
                $error[] = 'Please enter a username. ';
            }
            else if( ctype_alnum($_POST['username']))
            {
                $username = $_POST['username'];
            }
            else
            {
                $error[] = 'Username must consist of letters and numbers only. ';
            }

            //------------check for email field errors
            if(empty($_POST['email']))
            {
                $error[] = 'Please enter your email. ';
            }
            else if(preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/", $_POST['email']))
            {
                $email = mysql_real_escape_string($_POST['email']);
            }
            else
            {
                $error[] = 'Your e-mail address is invalid. ';
            }

            //------------------check for password field errors
            if(empty($_POST['password']))
            {
                //
                $error[] = 'Please enter a password. ';
            }
            else
            {
                $password = mysql_real_escape_string($_POST['password']);
            }

            //-------check for empty stuff
            if(empty($error))
            {//this is good info
                //
                $result = mysql_query("SELECT * FROM users WHERE email='$email' OR username='$username' ") 
                or die(mysql_error());
                    if(mysql_num_rows($result) == 0)
                    {
                        $activation = md5(uniqid(rand(), true));
                        //store information in tempuser query (5 field in tempuser sql table)
                        $result2 = mysql_query("INSERT INTO tempusers(user_id, username, email, password, activation)
                        VALUES('','$username','$email','$activation')") or die(mysql_error());
                        if(!$result2)
                        {
                            die('Could not insert into database: '.mysql_error());
                        }
                        else
                        {//create email
                            $messae = "To activate your account, please click on this link: \n\n";
                            $messae .= "http://lisa1986.com".'/activate.php?email='.urlencode($email)."&key=$activation";
                            //mail email
                            mail($email, 'Registration Confirmation', $message);
                            header('Location: prompt.php?x=1'); //prompt page say email has been sent
                        }
                    }
                    else//user taken
                    {   //user or email alreay taken try different
                        header('Location: prompt.php?x=2');
                    }
            }
            else
            {   //print all errors
                $error_message = '<span class = "error">';
                foreach($error as $key => $values)
                {
                    $error_message.= "$values";
                }
                $error_message = '</span><br/><br/>';
            }   
        }
        ?>









    <!-- Registration page -->
    <!DOCTYPE html>
    <html lng="en">
    <head>
        <title>Register</title>
        <!-- CSS file for every page-->
        <link rel = "stylesheet" href = "css/main.css">
        <link rel = "stylesheet" href = "css/form.css">
        <link rel = "stylesheet" href = "css/register.css">
    </head>
    <body>
        <div id="wrapper">
            <?php headerAndSearchCode(); ?>
            <aside id="left_side">
                <img src="images/registerbanner.png" />
            </aside>     
            <section id="right_side">

                <form id="generalform" class="container" method="post" action="">
                    <h3>Register</h3>
                    <?php echo $error_message; ?>
                    <div class="field">
                        <label for="username">Username:</label>
                        <input type="text" class="input" id="username" name="username" maxlength="20"/>
                        <!-- HINT -->
                        <p class="hint">20 characters maximum (letters and numbers only)</p>
                    </div>
                    <div class="field">
                        <label for="email">Email:</label>
                        <input type="text" class="input" id="email" name="email" maxlength="80"/>
                    </div>
                    <div class="field">
                        <label for="password">Password:</label>
                        <input type="password" class="input" id="password" name="password" maxlength="20"/>
                        <p class="hint">20 characters maximum</p>
                    </div>
                    <input type="submit" name="submit" id="submit" class="button" value="Submit"/>
                </form>

            </section>
            <?php footerCode(); ?>
        </div>
    </body>
    </html>

Your insert statement is missing the password in the values part.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.