将值插入DB不起作用?

Hey guys i had a similar problem before but i scraped that idea. Now basically my system allows my users to input there data into the fields and if they submit it the information will go to the database. Now for some reason the data does not go and i am presented with the echo that i stored in my else statement which was " echo" try again later" ;"

Now i have gone back into the database and looked at all the fileds and there correct names and placed them into the query but nothing gets stored into the db. Now you may be thinking whats the file on top called connect.inc.php in my code this is its basically a script in php which connects to the server.

here is my code pleas have a look thank you :)

<?php

  //require 'core.inc.php';
  include 'connect.inc.php';


if(isset($_POST['Username'])&& isset($_POST['Password']) && isset($_POST['PasswordAgain'])&& isset($_POST['Firstname'])&& isset($_POST['Lastname'])){

    $username = $_POST['Username'];
    $password = $_POST['Password'];

    $password_again = $_POST['PasswordAgain'];
    $Firstname = $_POST['Firstname'];

    $password_hash = md5($password);

    $Lastname = $_POST['Lastname'];

    if(!empty($username)&& !empty($password) && !empty($password_again) && !empty($Firstname) && !empty($Lastname)){



if ($password !== $password_again) {

            echo "passwords do not match";
        }
        else{

            $query = "SELECT username FROM members WHERE username = '$username'";
            $query_run = mysql_query($query);
            if(mysql_num_rows($query_run )==1){

                echo "The username ". $username ." is taken";

            }else{

                $query = "INSERT INTO members VALUES ('','Firstname','Lastname','Username','Password')";
                if ($query_run = mysql_query($query)){

                    echo "Well done";


                }else{

                    echo "Sorry we couldn't register at this time. Please try again later thank you";
                }

            }

        }
    }   
    else{

        echo "Please fill in all the details thank you ";

    }
}

?>


<form action="join.inc.php" method="post">


     Username: <input type="text" name="Username" value="<?php echo $username; ?>" /><br />
     Password: <input type="password" name="Password" /><br />
     Password Again: <input type="password" name="PasswordAgain" /><br />
     FirstName: <input type="text" name ="Firstname" value="<?php echo $Lastname; ?>"  /><br />
     LastName: <input type="text" name ="Lastname" value="<?php echo $Firstname ?>" /><br />

    <input type="submit" value="SUBMIT" />
</form>

Connect Script

I would recommend explicitly stating the columns used in your INSERT statement.

INSERT INTO members (`field1`, `field2`, ...) 
VALUES ('','Firstname','Lastname','Username','Password')

Also, what is the blank value you are trying to insert? If that field is an AUTO_INCREMENT field, you should not include it in the VALUES declaration.

you should use something like this.

$query = "insert into members (id,username) values ('','$username')";

Try this :

INSERT INTO members (`field1`, `field2`, ...) 
VALUES ('','$Firstname','$Lastname','$Username','$password_hash')

IF your first field is auto_increment

omit the field1 as shown below

INSERT INTO members (`field2`,`field3`,...)
VALUES ('field2Val','field3Val',...);
password !== $password_again 

should be

password != $password_again

Try changing to:

$query = "INSERT INTO members VALUES ('". $Firstname."','". $Lastname. "','" .$username. "','" .$password_hash. "')";
$result = mysql_query($query);
  if (!$result){

           echo "Sorry we couldn't register at this time. Please try again later thank you";

   }else{
           echo "Well done";

   }

enable error_reporting and see whats wrong actually, is the ID first field auto increment?

if that's auto increment your query will execute but if its not auto increment and set to PK only it wont insert records and raise duplicate key error.

hope this helps