javascript - How to post text variable in angular to mysql trough php -


so have little bit tricky or rather odd situation.

i have php , mysql database, frontend using angular.js

so creating service, sends data, via post request php.

so working when sending input values via name html attribute.

but problem appears when trying send hardcoded text variable loop.

i know it's hardcoded way doing don't know how differently.

so here php

<?php  $conn = mysqli_connect('localhost','nemkeang','nemkic23','interventure');  if(!$conn) {  die("connection failed: " . mysqli_connect_error()); }   $text = $_post['first_name']; $text2 = $_post['last_name']; $text3 = $_post['date']; $text4 = $_post['author']; $text5 = $_post['note']; $text6 = $_post['skill']; $target = "/assets"; $target = $target . basename( $_files['cv_file_name']['name']); //this gets other information form $file_name=  $_files['cv_file_name']['name']; $file_name2=  $_files['cv_file_name']['name'];   //writes file server if(move_uploaded_file($_files['cv_file_name']['tmp_name'], "./".$file_name)) {     //tells if ok     echo "the file ". basename( $_files['cv_file_name']['name']). " has been uploaded, , information has been added directory";     // connects database     }   $sql = "insert user (first_name, last_name, skill, date, cv_file_name, cv_url, author, note) values ('$text','$text2','$text6','$text3','$file_name','$file_name2','$text4','$text5')";  if (!mysqli_query($conn,$sql)) {   die('error: ' . mysqli_error($conn)); } else {     echo "success"; }  mysqli_close($con); ?> 

the php working correctly it's sending data, on $text6 = $_post['skill']; problem arrives.

so here angular service first

app.service('testpost',['$http',function($http){     this.saverecipe = function(postdata){          let payload = new formdata();         payload.append("first_name", postdata.first_name);         payload.append('last_name', postdata.last_name);         payload.append('date', postdata.date);         payload.append('cv_file_name', postdata.cv_file_name);         payload.append('author', postdata.author);          payload.append('note', postdata.note);          payload.append('skill', postdata.skill);           return $http.post('login/post.php', payload, {             transformrequest: angular.identity,             headers: {'content-type': undefined},          })     } }]); 

and it's working correctly, when log console, shows correct values. don't send payload.append('skill', postdata.skill); value php.

here controller

app.controller('newuser',['$scope','$filter','testpost', function($scope,$filter,testpost) {         $scope.postdata = {}         $scope.arr = [];         let bar = document.getelementsbyclassname('md-chip-content');          this.saverecipe = function(postdata) {         for(var = 0;  < bar.length;  i++) {             $scope.arr.push(bar[i].innertext);            }                let skills = $scope.arr;             postdata.date = $filter('date')(postdata.date, "mm/dd/yyyy").split('/').join('-');             postdata.skill  = skills[0];             postdata.skill2 = skills[1];             postdata.skill3 = skills[2];             postdata.skill4 = skills[3];             testpost.saverecipe(postdata).then((data)=>{                 console.log(data);              })             error:(err) =>{ return false};         }      }]); 

just clear want value postadata.skill sent mysql via php. , think problem in php because value don't come input type.

i hope i've explained well. in advance.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -