Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $scope.student = [name: "Joe", grades: "85", info: ""];
- <?php
- $servername = "localhost";
- $username = "username";
- $password = "password";
- $dbname = "myDB";
- // Create connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- //read the json file contents
- $jsondata = file_get_contents("php://input");
- //convert json object to php associative array
- $data = json_decode($jsondata, true);
- $studentname = $data['studentname'];
- $stuedentgrades = $data['stuedentgrades'];
- $studentinfo = $data['studentinfo'];
- $sql = "INSERT INTO students (name, grades, info)
- VALUES ('$studentname', '$stuedentgrades', '$studentinfo')";
- if ($conn->query($sql) === TRUE) {
- echo "New record created successfully";
- } else {
- echo "Error: " . $sql . "<br>" . $conn->error;
- }
- $conn->close();
- ?>
- Undefined index: info
- `if(isset($_POST('info'))){
- $info= $data['info'];
- }else{
- echo "NOOOOOOOOOO";
- } `
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement