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条)

报告相同问题?

悬赏问题

  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP