<?php
require('config.php');
sleep(1);
if (isset($_POST)) {
  $phone = (string)$_POST['phone'];

  $result = $connexion->query(
    'SELECT * FROM chance WHERE phone = ' . $phone
  );
  $row = $result->fetch_assoc();

  $assessor = $connexion->query(
    'SELECT * FROM user WHERE id = ' . $row['user_id']
  );

  if ($result->num_rows > 0) {
    $rowa = $assessor->fetch_assoc();
    echo '<div class="alert alert-warning"><strong>Oportunidad Encontrada!</strong><br>Celular ' . $phone . ' Registrado por ' . $rowa['name'] . ' ' . $rowa['lastname'] . '.</div>';
  } else {
    echo '<div class="alert alert-info"><strong>Alerta!</strong> Celular ' . $phone . ' No registrado anteriormente.</div>';
  }
}
