Created
August 20, 2012 06:40
-
-
Save dice/3401623 to your computer and use it in GitHub Desktop.
PHP code snippet for FullCourt SMS Authentication Sample Code
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 | |
include 'functions.php'; | |
/* | |
* First we retrieve each of the relevant variables and remove any | |
* non-alphanumeric characters filter them to protect against things such | |
* as SQL Injection. | |
*/ | |
$username = isset($_POST['username']) ? $_POST['username'] : ''; | |
$username = preg_replace("/[^A-Za-z0-9]/", "", $username); | |
$password = isset($_POST['password']) ? $_POST['password'] : ''; | |
$password = preg_replace("/[^A-Za-z0-9]/", "", $password); | |
$phoneNum = isset($_POST['phone_number']) ? $_POST['phone_number'] : ''; | |
$phoneNum = preg_replace("/[^0-9]/", "", $phoneNum); | |
$action = isset($_POST['action']) ? $_POST['action'] : ''; | |
switch ($action) { | |
case 'token': | |
$message = user_generate_token($username, $phoneNum); | |
break; | |
case 'login': | |
$message = user_login($username, $password); | |
break; | |
default: | |
echo 'do nothing'; | |
} | |
header("Location: index.php?message=" . urlencode($message) . "&action=" . $action); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment