Add extra attribute value to database using PHP?

This is my HTML Code

   [code] <select name="subject" id="subject" class="form-control">
        <option value="0">-Select-</option>
        <option value="1">Investigate</option>
        <option value="2">Mobile Lost</option>
        <option value="3">Lost something else</option>
    </select>[/code]

So, In case the user selects value 2, an extra text box appears and the user has to enter the IMEI number.
I’ve used Jquery to display that div on subject value selection.

[code]$(’#subject’).on(‘change’, function(){
if ($(this).val() == 1 ) {
$(’#inv’).removeClass(‘hide’);
$(’#lost’).addClass(‘hide’);
}

if ($(this).val() == 2 ) {
    $('#inv').addClass('hide'); 
    $('#lost').removeClass('hide');        
}[/code]

Inside PHP code I’ll be having
[php]
$subject=$_POST[“subject”];[/php]
So just tell me how I should modify the PHP so that it sends the IMEI value on that subject selection (mobile Lost or value “2”) else it’s just the subject.

The simple way, would be to check the value of $_POST[‘subject’] and if it is a certain value, to also check if the new input has been passed thru.

So, you mean I add something like if clause under $_POST[‘subject’] and store them to DB?

Basically,

[php]if ( intval( $_POST[“subject”] ) == 2 && isset( $_POST[‘imei’] ) ) {
// validate mobile #
}[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service