PHP从数据库中选择并比较结果

时间:2013-10-20 15:38:24

标签: php html mysql

我有一个php脚本数据用于将用户注册到数据库中。但首先,我希望它用数据库中的密码和用户密码检查用户密码,我的db pin匹配den我们将用户详细信息添加到数据库中,否则我们会回显错误但我似乎没有得到它。请帮我解决php脚本

`

$connect=mysql_connect("$host","$user","$password")
or die("Bross why na, change the localhost to example site.com without www. ");
$select=mysql_select_db("$db_name")
or die("dagogo change the db");

//collection data from registration form and processing encrypting it
$first_name=($_POST["First_Name"]);//user 1st name
$last_name=($_POST["Last_Name"]);//user last name
$username=($_POST["UserName"]);//user special User name
$phone=($_POST["Phone"]);//user phone number
$email=($_POST["email"]);//user email address
$password=($_POST["password"]);//user password

    //checking the pin with pin in the database

$query=mysql_query("SELECT * FROM pin_code WHERE pin='$password'");
$numrows=mysql_num_rows($query);
if($numrows!=0)
{
while($row =mysql_fetch_assoc($query))
{

$dbpassword=$row['pin'];

}
if($password==$dbpassword)
{


//inserting the form details into the database.
mysql_query("INSERT INTO users(first_name,last_name,username,phone,email,password)VALUES('$first_name','$last_name','$username','$phone','$email','$password')")or die ("Registration failed");
}
else
{
echo"dagogo";
}

`

和kip on得到此错误Parse error: parse error in C:\wamp\www\9ja School Solution\register.php on line 114 wic hapenns将成为d脚本的最后一行“?>”请帮忙

1 个答案:

答案 0 :(得分:0)

错误是你没有关闭第一个If语句没有关闭它的支架(})

尝试以下方法..

$connect=mysql_connect("$host","$user","$password")
    or die("Bross why na, change the localhost to example site.com without www. ");
    $select=mysql_select_db("$db_name")
    or die("dagogo change the db");

    //collection data from registration form and processing encrypting it
    $first_name=($_POST["First_Name"]);//user 1st name
    $last_name=($_POST["Last_Name"]);//user last name
    $username=($_POST["UserName"]);//user special User name
    $phone=($_POST["Phone"]);//user phone number
    $email=($_POST["email"]);//user email address
    $password=($_POST["password"]);//user password

    //checking the pin with pin in the database

    $query=mysql_query("SELECT * FROM pin_code WHERE pin='$password'");
    $numrows=mysql_num_rows($query);
    if($numrows!=0)
    {
        while($row =mysql_fetch_assoc($query))
        {

            $dbpassword=$row['pin'];

        }
        if($password==$dbpassword)
        {


            //inserting the form details into the database.
            mysql_query("INSERT INTO users(first_name,last_name,username,phone,email,password)VALUES('$first_name','$last_name','$username','$phone','$email','$password')")or die ("Registration failed");
        }
        else
        {
            echo"dagogo";
        }
    }