dosf40815 2013-04-06 01:52 采纳率: 100%
浏览 11
已采纳

在下一页获取POST mysql数据

Ok, I haven't done much of this sort of stuff, so I am clueless right now.

On the first page you hit the form submit that generates a bunch of information/stuff and displays it underneath submit button, but I don't know how to take the displayed information and use it on the next page I will show some of my code. btw I know the code is bad, just ignore that fact.

<form name="input" action="slaymonster.php" method="post" id="id">
  <div align="center">
    <input name="Submit" id="Submit" type="submit" class="button" value="Explore Map!"/>
  </div>
</form> 

if (isset($_POST['Submit'])) {

include 'includes/mapstuff.php';


// So here we pick a random row from the table pokemon notice the order by rand
$sql23 = "SELECT * FROM map1pokemon ORDER BY RAND() LIMIT 1;";
// We then check for errors
$result23 = mysql_query($sql23) or die(mysql_error());
// we then make the result into a virable called battle_get23
$battle_get23 = mysql_fetch_array($result23);

$sql2 = "SELECT * FROM pokemon WHERE name='".$battle_get23['pokemon']."'";
$result2 = mysql_query($sql2) or die(mysql_error());
$battle_get2 = mysql_fetch_array($result2);

// Now we need to make sure the image is safe be for we use it
$pic2= mysql_real_escape_string($battle_get2['pic']);
$pic = strip_tags($pic2);


include 'includes/maptypes.php';


?>


<form name="inputt" action="" method="post">
  <div align="center">
    <input type="submit" class="catch" value="Catch Pokemon" name="catch">
  </div>
</form>

<p></p>

<?php
echo "You have just found a " ;
echo $randomview97[0];
echo " ";

echo $battle_get23['pokemon'];


$_SESSION['pokemon'] = $battle_get23['pokemon']; 
$_SESSION['type'] = $randomview97[0];
$_SESSION['pic'] = $battle_get2;
$_SESSION['money'] = $randomview2[0];
$_SESSION['level'] = $randomview3[0];
$_SESSION['ticket'] = $randomview4;

?>
<p></p>
<?php
echo "You have gained ".$randomview3[0]." levels" ;
echo " ";
?>
<p></p>
<?php
echo "You have received $".$randomview2[0]."" ;
echo " ";
?>
<p></p>
<?php
echo "</center>";
}

?>

it displays the pokemon's picture it's name, type,amount of money you got ect...

I need all that information to be useable on the next page.

Any help is appreciated :)

  • 写回答

2条回答 默认 最新

  • doujian1954 2013-04-06 02:05
    关注

    At the top of your PHP code, be sure to include session_start(); You are already using session variables, so you should refer here to see what a PHP session is: PHP session_start() - Manual. It makes sure to do exactly what you are asking for (someone may point out that in certain cases session_start(); is not necessary, but for your purposes, while learning, stick to the Manual for best practices)

    This information will be usable on the next 'page', just as the manual describes, and will be available, until you call something like session_destroy().

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

报告相同问题?

悬赏问题

  • ¥15 marlin编译错误,如何解决?
  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥15 关于超局变量获取查询的问题
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集
  • ¥15 在启动roslaunch时出现如下问题
  • ¥15 汇编语言实现加减法计算器的功能