修改PHP Post数据
我正在使用刷卡来获取id,并使用该id将出勤情况存储到数据库中。我有一个带有jQuery的表单,当用户在输入字段中输入8个字符串时,它会自动提交表单。我想使用刷卡中的数据来执行此操作,但当我刷卡时,得到的输出是修改PHP Post数据,php,jquery,forms,post,trim,Php,Jquery,Forms,Post,Trim,我正在使用刷卡来获取id,并使用该id将出勤情况存储到数据库中。我有一个带有jQuery的表单,当用户在输入字段中输入8个字符串时,它会自动提交表单。我想使用刷卡中的数据来执行此操作,但当我刷卡时,得到的输出是;910522804?它应该在哪里k1052280 我怎样才能修剪数据,以便当有人刷卡时,它应该清除?最后一位数字。任何帮助都将不胜感激 表单和jQuery代码如下 <form id="SwipeForm" action="Swiped.php" method="post">
;910522804?
它应该在哪里k1052280
我怎样才能修剪数据,以便当有人刷卡时,它应该清除?最后一位数字
。任何帮助都将不胜感激
表单和jQuery代码如下
<form id="SwipeForm" action="Swiped.php" method="post">
<input id="Swipe" name="studentID" type="text" value="" />
<input type="submit" value="Submit" />
</form>
<script>
$(function () {
$('#Swipe').bind('DOMAttrModified textInput input change keyup keypress paste', function() {
var vallength = $(this).val().length;
if (vallength == 8) {
$('#SwipeForm').submit();
}
});
});
</script>
<form id="SwipeForm" action="Swiped.php" method="post">
<input id="Swipe" name="studentID" type="text" value="" />
<input type="submit" value="Submit" />
</form>
$(函数(){
$(“#滑动”).bind('DOMAttrModified textInput input change keyup keypress paste',函数(){
var vallength=$(this).val().length;
if(vallength==8){
$(“#SwipeForm”).submit();
}
});
});
要删除第一个字符和最后两个字符,嵌套的substr
函数可以工作:
$str = ';910522804?';
$str = substr(substr($str, 1), 0, -2);
echo $str;
// 91052280
或者,您可以将strlen函数与substr一起使用,以获取字符串的一部分
$str = ';910522804?';
$str = substr($str, 1, strlen($str) - 2);
var_dump($str);
非常感谢您的快速回复,这是非常有用的,现在我所要做的是附上“k”,这将是很好的去。谢谢你,我将结合这两个答案来解决我的问题