插入单选按钮的值



当一个单选按钮被检查到mysqldb表中时,我正试图插入它的值。下面是HTML和PHP。请告诉我出了什么问题?

这是HTML第一个:

<div class='container'>
    <label for='username' >Business*:</label><br/>
    <input type="radio" name="bus" id="username" value="bus" maxlength="50" /><br/>
    <span id='register_username_errorloc' class='error'></span>
</div>
<div class='container'>
    <label for='username' >Personal*:</label><br/>
    <input type="radio" name="pers" id="username" value="per" maxlength="50" /><br/>
    <span id='register_username_errorloc' class='error'></span>
</div>

现在PHP:

function InsertIntoDB(&$formvars)
    {
        $confirmcode = $this->MakeConfirmationMd5($formvars['email']);
        $formvars['confirmcode'] = $confirmcode;
        $insert_query = 'insert into '.$this->tablename.'(
                name,
                email,
                username,
                password,
                confirmcode,
                dob,
                business,
                personal
                )
                values
                (
                "' . $this->SanitizeForSQL($formvars['name']) . '",
                "' . $this->SanitizeForSQL($formvars['email']) . '",
                "' . $this->SanitizeForSQL($formvars['username']) . '",
                "' . md5($formvars['password']) . '",
                "' . $confirmcode . '",
                "' . $this->SanitizeForSQL($formvars['dob']) . '",
                "' . $this->SanitizeForSQL($formvars['bus']) . '",
                "' . $this->SanitizeForSQL($formvars['pers']) . '"
                )';      
        if(!mysql_query( $insert_query ,$this->connection))
        {
            $this->HandleDBError("Error inserting data to the tablenquery:$insert_query");
            return false;
        }        
        return true;
    }

我认为存在逻辑错误。您应该只保存数据库中单选按钮中的一个变量。

            "' . $this->SanitizeForSQL($formvars['bus']) . '",
           "' . $this->SanitizeForSQL($formvars['pers']) . '"

最新更新