0

i have a dropdown list and i can access the selected name through ng_model directive(selectedName) but My problem is when i try to pass the selected option value to the database it pass a null value the query get executed and text box values are passing properly the issue is with the dropdown option values.. what went wrong .. in the controller or with the php code mysqli_real_escape_string part. it's confused .. any help

<select data-ng-model="selectedName" ng-options="item for item in names">
</select>

var app = angular.module('myApp', []);
app.controller('myCtrl',  function($scope)  {
$scope.names = ["7G", "8G", "13G", "15G", "23G","26G"];


   app.controller("usercontroller", function($scope, $http){
    $scope.insertData = function(){
        $http.post(
            "insert.php",
            {'selectedName':$scope.selectedName, 
'selectedProject':$scope.selectedProject,  'user':$scope.user}
        ).success(function(data){
            alert(data);
        });
    }


$connect = mysqli_connect("localhost","root","","microlinks");  
$data = json_decode(file_get_contents("php://input"));
if(count($data) > 0){
$frequency = mysqli_real_escape_string($connect, $data->selectedName);
$project = mysqli_real_escape_string($connect, $data->selectedProject);
   $user = mysqli_real_escape_string($connect, $data->user);


$query = "insert into links(frequency,project,user,date) values ('$frequency','$project', '$user',)";

if(mysqli_query($connect, $query))
{
    echo "Hello World";
}
else
{
    echo 'Error';
}
}
2
  • '$user',)" ? ? Commented Feb 2, 2018 at 2:06
  • $query = "insert into links(frequency,project,user,date) values ('$frequency','$project', '$user', NOW())"; Commented Feb 2, 2018 at 2:09

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.