Created
July 18, 2014 16:59
-
-
Save shivasurya/c4b7c3217a6b1608cd69 to your computer and use it in GitHub Desktop.
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 | |
header('Content-Type: application/json'); | |
if($_POST) | |
{ | |
if($_POST['email']) | |
{ | |
$incominglist = $_POST['email']; | |
$full=array(); | |
$con=mysqli_connect("localhost","root","shiva1995","invite"); | |
// Check connection | |
if (mysqli_connect_errno()) { | |
echo "Failed to connect to MySQL: " . mysqli_connect_error(); | |
} | |
$result = mysqli_query($con,"SELECT email,pic,name FROM email"); | |
$full = array(); | |
while($row = mysqli_fetch_assoc($result)) { | |
$full[]=$row['email']; | |
$fulls[]=$row['pic']; | |
$fulln[]=$row['name']; | |
} | |
$friendlist = array_intersect($full,$incominglist); | |
$piclist = array_intersect_key($fulls, $friendlist); | |
$namelist = array_intersect_key($fulln, $friendlist); | |
$friendlist = array_values($friendlist); | |
$piclist = array_values($piclist); | |
$namelist = array_values($namelist); | |
$newlist= array_diff($incominglist,$friendlist); | |
$newlist = array_values($newlist); | |
echo json_encode(array("newlist" =>$newlist,"users" =>$friendlist,"pic" => $piclist,"name" => $namelist)); | |
mysqli_close($con); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment