在PHP中使用跨页面的变量

时间:2015-05-17 20:21:04

标签: php html netbeans

我有一个登录页面,您可以在其中输入用户名和密码,如果正确,则提交按钮会将您发送到有效的用户页面

在有效用户页面中,输入一些数据然后提交以转到付费页面

如何在付费页面中获取用户名?注意$ usertext = $ _ POST [“username”];停在有效的用户页面

登录页面:

<?php

    $con = mysql_connect("localhost","root","2421993");
    if (!$con)
     {die('Could not connect: ' . mysql_error());
     }

     mysql_select_db("trial", $con);


$usertext=$_POST["username"];
$passwordtext=$_POST["password"];
// if exists in database
header("Location: http://localhost/lab6/valid.php");
?>

VALID PAGE

<html>



    <head></head>

    <body  style="background-color:lightgrey">


    <h1  align="middle"> Welcome to Smart Garage Services </h1> 

       <form name="input" action="pay.php" method="post">

          Choose the area:
          <select name="place">
            <option value="6october">6 October</option>
            <option value="Zayed">Zayed</option>
          </select>

          <input type="submit" value="Go to Paying" />
    </form>
    </body>

   </html>

付费页面:

 <?php

    $con = mysql_connect("localhost","root","2421993");
    if (!$con)
     {die('Could not connect: ' . mysql_error());
     }

     mysql_select_db("trial", $con);



    $placetext=$_POST["place"]; 

    mysql_query("UPDATE clients SET place='$placetext' WHERE Username= '$usertext' "); 
// PROBLEM IS HERE: USERTEXT variable doesn't have the user as valid page
?>

0 个答案:

没有答案