Skip to content

Instantly share code, notes, and snippets.

@jonmarkgo
Created July 9, 2013 18:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonmarkgo/5960001 to your computer and use it in GitHub Desktop.
Save jonmarkgo/5960001 to your computer and use it in GitHub Desktop.
<?php
require("Services/Twilio.php");
require("database.php");
$response = new Services_Twilio_Twiml();
if (empty($_POST["Digits"])) {
$gather = $response->gather(array('numDigits' => 6));
$gather->say("Please enter your verification code.");
}
else {
// grab db record and check for match
$result = db(sprintf("select * from numbers where phone_number='%s'", $_POST["Called"]));
if($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
if ($_POST["Digits"] === $line["verification_code"]) {
db(sprintf("UPDATE numbers SET verified = 1 WHERE phone_number = '%s'", $_POST["Called"]));
$response->say("Thank you! Your phone number has been verified.");
}
else {
// if incorrect, prompt again
$gather = $response->gather(array('numDigits' => 6));
$gather->say("Verification code incorrect, please try again.");
}
}
mysql_close();
}
print $response;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment