Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Importing DBConfig.php file.
- include 'DBConfig.php';
- // Connecting to MySQL Database.
- $con = mysqli_connect($HostName,$HostUser,$HostPass,$DatabaseName);
- // Getting the received JSON into $json variable.
- $json = file_get_contents('php://input');
- // decoding the received JSON and store into $obj variable.
- $obj = json_decode($json,true);
- $S_Name = $obj['nombre'];
- $S_Class = $obj['clase'];
- $S_Phone_Number = $obj['telefono'];
- $S_Email = $obj['email'];
- // Creating SQL query and insert the record into MySQL database table.
- $Sql_Query = "insert into DetalleEstudiantes (nombre,clase,telefono,email) values ('$S_Name','$S_Class','$S_Phone_Number','$S_Email')";
- if(mysqli_query($con,$Sql_Query)){
- // If the record inserted successfully then show the message.
- $MSG = 'Record Successfully Inserted Into MySQL Database.' ;
- // Converting the message into JSON format.
- $json = json_encode($MSG);
- // Echo the message.
- echo $json ;
- }
- else{
- echo 'Try Again';
- }
- mysqli_close($con);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement