使用带有oracle db的php将是足够的验证

时间:2013-11-18 17:52:34

标签: php oracle validation

我是使用oracle的新手,但我认为在大多数数据库中验证PHP中的所有内容应该是相同的。

我已经在前端进行了js验证,所以我不需要它。

这是我的表格:

<br/><br/>
<form method="post">
<legend>Log In</legend><br/>
<label for='email' >Email Address*:</label>
<input type='text' name='email' id='email' maxlength="50" /><br/><br/>
<label for="password">Password*:</label>
<input type="password" name="password" id="password" placeholder="password" required><br/><br/>
<input type='button' name='login' id='login' value='Login' />
</form>

ajax图层:

if (isset($_GET['email']) && $_GET['email'] != '' && isset($_GET['password']) && $_GET['password'] != '') {

    // todo: change their connection string to become their Oracle user.
    $shopper = new Shopper($_GET['email']);
    $token = $shopper->login($_GET['password']);

    if (isset($token) && $token != '') {
        echo json_encode($token);
    }
}

php api layer:

//both parameters are required, so make sure they were passed-in
if(!isset($_GET['email'])) {
    die('Must pass \'email\' through the URL');
}
if(!isset($_GET['password'])) {
    die('Must pass \'password\' through the URL');
}

//instantiate a new Shopper object for the email address that was passed-in
$foo = new Shopper($_GET['email'])
or die('Could not create the Shopper object using the \'email\' passed-in');

//token will be null if the password for the user is incorrect
$token = $foo->login($_GET['password']);

//thus what is echoed here will be a null JSON array
echo json_encode($token);

一切看起来都很稳固吗?任何建议或帮助都会很棒,提前谢谢。

0 个答案:

没有答案