Created
June 21, 2018 11:59
-
-
Save evilnapsis/966a09377785a3df1e9ddb00fbdafec2 to your computer and use it in GitHub Desktop.
Servicio web para servir contactos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
@author evilnapsis | |
*/ | |
$con = new mysqli("localhost","root","","contactapp"); | |
if(isset($_GET["opt"]) && $_GET["opt"]=="all"){ | |
$sql = "select * from contact"; | |
$query = $con->query($sql); | |
$data = array(); | |
while($r = $query->fetch_assoc()){ | |
$data[] = $r; | |
} | |
echo json_encode($data); | |
} | |
else if(isset($_GET["opt"]) && $_GET["opt"]=="add"){ | |
$sql = "insert into contact (name,lastname,address,phone,email) values (\"$_POST[name]\",\"$_POST[lastname]\",\"$_POST[address]\",\"$_POST[phone]\",\"$_POST[email]\" )"; | |
$con->query($sql); | |
echo json_encode(array("status"=>"success")) | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment