dousha1394 2012-06-26 22:59
浏览 56
已采纳

我可以在Meta Http Equiv Refresh中传递变量吗?

I just finished this script it works well, but I am struggling to pass along the $invite variable to the register.php page. Can someone please tell me how I can achieve this? I have it defined as $invite = $_POST['inviteinput'];

How do I get the users input from index.php to transfer to register.php? Thank you for your help!

HTML FORM:

    <form action="index.php" method="post">
    What is your Invite Code?<BR />
    <input class="textbox" name="inviteinput" type="text" />
    <BR />
    <input type="hidden" name="formsubmitted" value="TRUE" />
    <input name="Submit" type="submit" value="Verify" />
    </form>

PHP:

<?PHP
include ('scripts/dbconnect.php');

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

if (empty($_POST['inviteinput'])) {
echo '<div class="errormsgempty"><u>ERROR</u>:<br>You must enter a valid invite code to proceed!</div>';
} else {


$invite = $_POST['inviteinput'];//else assign it a variable
$invite = stripslashes($invite);
$invite = mysql_real_escape_string($invite);

$sql = "SELECT yourMemberId FROM Register WHERE yourMemberId='$invite'";
$result = mysql_query($sql);

if(mysql_num_rows($result) > 0) {

echo '<META HTTP-EQUIV="Refresh" Content="0; URL=register.php">';   
} else { 
echo '<div class="errormsgbox"><u>ERROR</u>:<br>The Invite Code you entered ' . $invite . ' is NOT a valid invite code!</div>';
//($notvalidcode = "The Invite Code you entered <strong>" . $invite . "</strong> is NOT a valid invite code!");
}
}
}
?>
  • 写回答

2条回答 默认 最新

  • dqayok7935 2012-06-26 23:04
    关注

    There are a few ways Save it in a session

    session_start();
    $_SESSION['invite'] = $invite;
    

    2nd is you can pass it via get

    echo '<META HTTP-EQUIV="Refresh" Content="0; URL=register.php?invite=' . $invite . '">'; 
    

    I would recommend option 2. Also, why are you doing $invite = $_POST['inviteinput']; twice?

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

报告相同问题?

悬赏问题

  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥170 如图所示配置eNSP
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果