gpt4 book ai didi

php - 修改 PHP 发布数据

转载 作者:行者123 更新时间:2023-12-01 04:05:38 25 4
gpt4 key购买 nike

我正在使用刷卡来捕获 ID 并将其用于将出勤存储到数据库中。我有一个 jQuery 表单,当用户在输入字段中输入 8 个字符串时,它会自动提交表单。我想使用刷卡中的数据来执行此操作,但是当我刷卡时,我得到的输出是 ;910522804?,而它应该是 k1052280

我如何修剪数据,以便当有人刷卡时应该删除 ; ?和最后一位数字。任何帮助将不胜感激。

表单和 jQuery 代码是这样的

<form id="SwipeForm" action="Swiped.php" method="post">
<input id="Swipe" name="studentID" type="text" value="" />&nbsp;
<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="" />&nbsp;
<input type="submit" value="Submit" />
</form>

最佳答案

或者,您可以使用 strlen 函数和 substr 来获取字符串的一部分。

$str = ';910522804?';
$str = substr($str, 1, strlen($str) - 2);
var_dump($str);

关于php - 修改 PHP 发布数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29221184/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com