Student Username: '.$obj->Username.'
';
加
echo '';
然后在
$newBalance = $_POST['newBalance'];
加
$username = $_POST['username'];
并将您的查询修改为
$upsql = "UPDATE users SET Balance = Balance + '$newBalance'
WHERE Username='".$username ."'";
我的报价可能有点偏僻
echo '';
您可能需要将其更改为
echo '';
编辑#2:
由于您已经在使用会话,因此执行此操作的另一种方法=$_SESSION['Username'];?>
是为其分配变量并将其传递给您的查询.
$username = $_SESSION['Username'];
$upsql = "UPDATE users SET Balance = Balance + '$newBalance'
WHERE Username='".$username ."'";
编辑#3:
你在哪里
if(isset($_POST['search'])){
$searchq = $_POST['search'];
$searchq = preg_replace("#[^0-9a-z]#i","",$searchq);
用它替换它
if(isset($_POST['search'])){
$searchq = $_POST['search'];
$searchq = preg_replace("#[^0-9a-z]#i","",$searchq);
$student = $_POST['search'];
$_SESSION['student'] = $student;
echo $_SESSION['student']; // see what echos here
然后在你的查询中,执行:
$upsql = "UPDATE users SET Balance = Balance + '$newBalance'
WHERE Username='".$student ."'";
如果这不起作用,我不知道还有什么可以做的,这将是进一步的帮助.我的测试是确凿的并且有效.您的查询可能会失败,此时我没有更多的想法.
基于这种情况:
$_POST['search'] = "student1";
$student = $_POST['search'];
$_SESSION['student'] = $student;
// echo $_SESSION['student'];
$student2 = $student;
echo $student2; // will echo student1