dongtiaobeng7901 2019-05-21 20:48
浏览 136
已采纳

跨页面传递Sessions用户ID

I need to pass the sessions user name (that they have logged in with) which is an email! I need to pass this to a separate page and output it in a table to represent a review submitted

$_SESSION['name'] = $_POST['name']; - sends page to login in when refreshed $name = ['name'] - sends page back to login

<!-- logged in user information -->
<?php  if (isset($_SESSION['email'])) : ?>
<p>Welcome you are logged in as: <strong><?php echo $_SESSION['email']; ?></strong></p>

the 'email' needs passing across from the code above 'index.php' to the code below 'reviews.php'

<p>
<input name="product_id" value="<?php echo "$var" ?>" readonly> <!-- get value from previous page-->
<input name="track_name" value="<?php echo "$var_value" ?>" readonly> <!-- get value from previous page-->
<input name="track_name" value="<?php echo "EMAIL_HERE" ?>" readonly> <!-- get value from previous page-->
<!-- get value from previous page-->
<input type="Submit" name="Submit" value="Submit"></p>

As this is an assignment I can only use PHP MYSQL HTML CSS

I would like the user name (email) to be echo out in a table as $var and $var_value is, they should then all print out beside each other in a form

UPDATE using this code I have managed to now get the variable value across but cannot insert it to the DB

$email = $_SESSION['email'];

$sql = "INSERT INTO reviews (rating, review, track_name, product_id, email) values('$rate', '$text', '$track', '$artist', '$email')";

``" readonly>```

so the update is how can I now get this inserted to my database?

  • 写回答

2条回答 默认 最新

  • dongluan1901 2019-05-21 21:38
    关注

    FINALLY THANK YOU FOR YOUR HELP ALL

    $email = $_SESSION['email']; Get the email from session

    $email = (isset($_POST['email']) ? $_POST['email'] : null); Remove index error

    <input name="email" value="<?php echo "$email" ?>" readonly> <!-- get value from previous page--> Display the value

    $review_query = mysqli_query($result,"SELECT rating, review, email FROM reviews WHERE track_name = '$var_value' AND product_id = '$var'"); Grab it from the DB

    <td class='col-4 col-s-4' name='email'><?php echo $email ?></td> Output its value

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题