我想从数据库表中获取用户(当前已登录)的电子邮件和uid,然后将其插入另一个表中。我已经试过了,但我得到的是空白的结果,是在uid和电子邮件。
<?php
session_start();
if(isset($_POST['button'])){
$bidamount = $_POST['bidamount'];
$email = $_SESSION['$u_email'];
$uid = $_SESSION['$u_uid'];
//TO ALERT SUBMISSION OF BLANK FIELDS(IT DOESN'T PREVENT SUBMISSION OF BLANK FIELD THOUGH)
if (!$bidamount){
echo "can't submit blank fields";
}
//TO CONFIRM YOU ARE CONNECTED TO YOUR DATABASE (OPTIONAL)
$connection = mysqli_connect('localhost', 'root', '', 'tickmill_auctions');
if ($connection){
header ("Location: ../Afterlogin.php?action=success");
}else{
die("connection failed");
}
//TO INSERT username and password from field to jossyusers database
$query = "INSERT INTO orders(bidamount,email,uid) VALUES('$bidamount','$email','$uid')";
$result = mysqli_query($connection, $query);
if(!$result){
die("OOPPS! query failed".mysqli_error($connection));
}
}
?>
1条答案
按热度按时间rhfm7lfc1#
这看起来是错误的,因为我在脚本中没有看到有名称的变量
$u_email
以及$u_uid
```$email = $_SESSION['$u_email'];
$uid = $_SESSION['$u_uid'];
$email = $_SESSION['u_email'];
$uid = $_SESSION['u_uid'];
$email = $_SESSION["$u_email"];
$uid = $_SESSION["$u_uid"];
ini_set('display_errors', 1);
ini_set('log_errors',1);
error_reporting(E_ALL);
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);