本文整理汇总了PHP中test_input函数的典型用法代码示例。如果您正苦于以下问题:PHP test_input函数的具体用法?PHP test_input怎么用?PHP test_input使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了test_input函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_spouse
function get_spouse($spouse1, $spouse2, $spouse3)
{
$spouse1 = test_input($spouse1);
$spouse2 = test_input($spouse2);
$spouse3 = test_input($spouse3);
$num = rand(1, 3);
switch ($num) {
case 1:
return $spouse1;
case 2:
return $spouse2;
case 3:
return $spouse3;
default:
return "Mystery spouse";
}
}
示例2: add_question
public function add_question()
{
$arr['question'] = test_input($_POST['judge_des']);
$arr['point'] = test_input($_POST['point']);
$arr['answer'] = $_POST['answer'];
$arr['easycount'] = intval($_POST['easycount']);
$arr['isprivate'] = intval($_POST['isprivate']);
$arr['creator'] = $_SESSION['user_id'];
$arr['addtime'] = date('Y-m-d H:i:s');
if (M('ex_judge')->add($arr)) {
return true;
} else {
return false;
}
}
示例3: register_seller
function register_seller()
{
global $host, $user, $pass, $dbname;
$db = new mysqli($host, $user, $pass, $dbname);
$email = test_input($_POST["semail"]);
$password = test_input($_POST["spassword"]);
$confirm_pass = test_input($_POST["sconfirm-password"]);
$fname = test_input($_POST["sfname"]);
$lname = test_input($_POST["slname"]);
$query = "SELECT * FROM SELLER WHERE SELLER.email = '" . $email . "'";
$result = $db->query($query);
//echo $query;
if ($result->num_rows > 0) {
echo '{"created": false}';
} else {
$count_query = "SELECT COUNT(*) FROM SELLER";
$result2 = $db->query($count_query);
if ($result2->num_rows > 0) {
$row = $result2->fetch_assoc();
$sid = $row["COUNT(*)"];
} else {
$sid = 0;
}
$insert = "INSERT INTO SELLER (sid, email, password, fname, lname) VALUES (" . $sid . ", '" . $email . "', '" . $password . "', '" . $fname . "', '" . $lname . "');";
$db->query($insert);
$token = 256;
echo '{"created": true, "sid": ' . $sid . ', "fname": "' . $fname . '", "token": ' . $token . '}';
}
}
示例4: formFunctions
/**
* Test savingForm
* Test so a proper form is saved, with correct data.
* Also test if it is possible to enter incorrect data that might ruin something.
* @author Fredrik Andersson
* @small
* @test
*/
public function formFunctions()
{
// Create new user class
$a = new PP();
// Check if the object was created
$this->assertNotNull($a);
// Adding some variables into the form class PP
$a->student1 = "StudentName";
$this->assertEquals("StudentName", $a->student1);
//Test of the function test_num($data)
$this->assertEquals(1, test_num(1));
$this->assertEquals("-", test_num("-"));
$this->assertEquals("-", test_num(10));
//Test of the function test_input($data)
$this->assertEquals("123", test_input(" 123 "));
//trim() removes spaces before the first char and after the last one.
$this->assertEquals("123'hihi\ttab", test_input("123\\'hi\\hi\ttab"));
//stripslashes() removes all slashes exept proper slashes like \t and \n etc.
$this->assertEquals("& " < >", test_input("& \" < >"));
//htmlspecialchars() changes some special characters to code that html can handle.
//Test of the function is_empty($data)
$this->assertEquals(false, is_empty(array('apple', 'banana ', ' cranberry ')));
$this->assertEquals(false, is_empty(array('', '', '')));
$temp[10] = "something";
$this->assertEquals(false, is_empty($temp));
//Test of the function input_length()
$string128 = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
$string129 = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab";
$this->assertEquals($string128, input_length($string129));
//Test of the function length_one()
$this->assertEquals("1", length_one("12345"));
}
示例5: addFillInfo
public function addFillInfo()
{
$reqResult = new Result();
$arr = FillConvert::convertFillFromPost();
$arr['addtime'] = date('Y-m-d H:i:s');
$arr['creator'] = $_SESSION['user_id'];
$fillId = FillBaseModel::instance()->insertData($arr);
if ($fillId) {
for ($i = 1; $i <= $arr['answernum']; $i++) {
$answer = test_input($_POST["answer{$i}"]);
$arr2['fill_id'] = $fillId;
$arr2['answer_id'] = $i;
$arr2['answer'] = $answer;
M('fill_answer')->add($arr2);
}
$pointIds = I('post.point', array());
KeyPointService::instance()->saveExamPoint($pointIds, $fillId, FillBaseModel::FILL_PROBLEM_TYPE);
$reqResult->setMessage("填空题添加成功!");
$reqResult->setData("fill");
} else {
$reqResult->setStatus(false);
$reqResult->setMessage("填空题添加失败!");
}
return $reqResult;
}
示例6: setValuesWhenSubmitIsClicked
function setValuesWhenSubmitIsClicked()
{
$GLOBALS['pkstu_id'] = test_input($_POST['pkstu_id']);
$GLOBALS['fkstu_lug_id'] = test_input($_POST['fkstu_lug_id']);
$GLOBALS['stu_nombre'] = test_input($_POST['stu_nombre']);
$GLOBALS['stu_fecha_creacion'] = test_input($_POST['stu_fecha_creacion']);
}
示例7: setMessage
function setMessage($data)
{
if (empty($data)) {
echo "E-mail couldn't be send without a message";
} else {
return test_input($data);
}
}
示例8: test_num_meals
function test_num_meals($data)
{
$data = test_input($data);
if (!is_numeric($data)) {
return FALSE;
}
return $data;
}
示例9: nomChercheur
function nomChercheur($bdd)
{
$id = test_input($_SESSION['id']);
$requete = $bdd->query("SELECT * FROM chercheur WHERE ID = {$id}");
$data = $requete->fetch();
$resultat = $data['PrenomChercheur'] . " " . $data['NomChercheur'];
$requete->closeCursor();
return $resultat;
}
示例10: convertJudgeFromPost
public static function convertJudgeFromPost()
{
$arr = array();
$arr['question'] = test_input($_POST['judge_des']);
$arr['answer'] = $_POST['answer'];
$arr['easycount'] = intval($_POST['easycount']);
$arr['isprivate'] = intval($_POST['isprivate']);
return $arr;
}
示例11: setValuesWhenSubmitIsClicked
function setValuesWhenSubmitIsClicked()
{
$GLOBALS['pkusu_id'] = test_input($_POST['pkusu_id']);
$GLOBALS['fkusu_rol_id'] = test_input($_POST['fkusu_rol_id']);
$GLOBALS['usu_nombre'] = test_input($_POST['usu_nombre']);
$GLOBALS['usu_correo'] = test_input($_POST['usu_correo']);
$GLOBALS['usu_clave'] = test_input($_POST['usu_clave']);
$GLOBALS['usu_imagen'] = test_input($_POST['usu_imagen']);
}
示例12: convertFillFromPost
public static function convertFillFromPost()
{
$arr = array();
$arr['question'] = test_input($_POST['fill_des']);
$arr['easycount'] = intval($_POST['easycount']);
$arr['answernum'] = intval($_POST['numanswer']);
$arr['kind'] = intval($_POST['kind']);
$arr['isprivate'] = intval($_POST['isprivate']);
return $arr;
}
示例13: setValuesWhenSubmitIsClicked
function setValuesWhenSubmitIsClicked()
{
$GLOBALS['pkins_id'] = test_input($_POST['pkins_id']);
$GLOBALS['fkins_car_id'] = test_input($_POST['fkins_car_id']);
$GLOBALS['fkins_cor_id'] = test_input($_POST['fkins_cor_id']);
$GLOBALS['ins_valor'] = test_input($_POST['ins_valor']);
$GLOBALS['ins_gualdrapa'] = test_input($_POST['ins_gualdrapa']);
$GLOBALS['ins_puesto_partida'] = test_input($_POST['ins_puesto_partida']);
$GLOBALS['ins_favorito'] = test_input($_POST['ins_favorito']);
}
示例14: updateBaseCodeDef
/**
* 修改菜单
**/
function updateBaseCodeDef($baseCodeDefId)
{
mysql_query("set character_set_connection=utf8");
$fatherBaseCodeDef = isset($_POST['fatherBaseCodeDef']) ? test_input($_POST['fatherBaseCodeDef']) : "";
// 父字典code
$codeValue = isset($_POST['codeValue']) ? test_input($_POST['codeValue']) : "";
// 字典编码
$displayValue = isset($_POST['displayValue']) ? test_input($_POST['displayValue']) : "";
// 字典名称
mysql_query("update base_code_def set father_base_code ='" . $fatherBaseCodeDef . "', code_value='" . $codeValue . "', display_value='" . $displayValue . "' where base_code_id = " . $baseCodeDefId);
}
示例15: setValuesWhenSubmitIsClicked
function setValuesWhenSubmitIsClicked()
{
$GLOBALS['pkfac_id'] = test_input($_POST['pkfac_id']);
// $GLOBALS['pkapu_id'] = test_input($_POST['pkapu_id']);
// $GLOBALS['fkapu_cor_id'] = test_input($_POST['fkapu_cor_id']);
// $GLOBALS['fkapu_jug_id'] = test_input($_POST['fkapu_jug_id']);
// $GLOBALS['fkapu_fac_id'] = test_input($_POST['fkapu_fac_id']);
// $GLOBALS['fkapu_taq_id'] = test_input($_POST['fkapu_taq_id']);
// $GLOBALS['apu_monto'] = test_input($_POST['apu_monto']);
// $GLOBALS['apu_lugar_llegada'] = test_input($_POST['apu_lugar_llegada']);
}