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

报告相同问题?

悬赏问题

  • ¥30 求解达问题(有红包)
  • ¥15 请解包一个pak文件
  • ¥15 不同系统编译兼容问题
  • ¥100 三相直流充电模块对数字电源芯片在物理上它必须具备哪些功能和性能?
  • ¥30 数字电源对DSP芯片的具体要求
  • ¥20 antv g6 折线边如何变为钝角
  • ¥30 如何在Matlab或Python中 设置饼图的高度
  • ¥15 nginx中的CORS策略应该如何配置
  • ¥30 信号与系统实验:采样定理分析
  • ¥100 我想找人帮我写Python 的股票分析代码,有意请加mathtao