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

我可以在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!");
}
}
}
?>

我刚刚完成这个脚本它运行良好,但我很难将$ invite变量传递给寄存器。 php页面。 有人可以告诉我如何实现这一目标吗? 我把它定义为$ invite = $ _POST ['inviteinput']; p>

如何从index.php获取用户输入以转移到register.php? 感谢您的帮助! p>

HTML表格: p> &lt; form action =“index.php”method =“post”&gt ; 您的邀请代码是什么?&lt; BR /&gt; &lt; input class =“textbox”name =“inviteinput”type =“text”/&gt; &lt; BR /&gt; &lt; input type =“hidden”name =“formsubmitted”value =“TRUE”/&gt; &lt; input name =“Submit”type =“submit”value =“Verify”/&gt; &lt; / form&gt; \ n code> pre>

PHP: p>

 &lt;?PHP 
include('scripts / dbconnect.php'); 
  
if(isset($ _ POST ['formsubmitted'])){
 
if(空($ _ POST ['inviteinput'])){
echo'&lt; div class =“errormsgempty”&gt;&lt; u&gt; ERROR&lt;  ; / u&gt;:&lt; br&gt;您必须输入有效的邀请码才能继续!&lt; / div&gt;'; 
}其他{
 
 
 $ invite = $ _POST ['inviteinput']; // 否则为它分配一个变量
 $ 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)&gt; 0){  
 
echo'&lt; META HTTP-EQUIV =“刷新”内容=“0;  URL = register.php“&gt;'; 
} else {
echo'&lt; div class =”errormsgbox“&gt;&lt; u&gt; ERROR&lt; / u&gt;:&lt; br&gt;您输入的邀请代码'。$ 邀请。'不是有效的邀请代码!&lt; / div&gt;'; 
 //($ notvalidcode =“您输入的邀请代码&lt; strong&gt;”。$ invite。“&lt; / strong&gt;不是有效的 邀请代码!“); 
} 
} 
} 
?&gt; 
  code>  pre> 
  div>

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?

Absolutely. Just add it to the URL:

<meta http-equiv="Refresh" Content="0; url=register.php?var=value&othervar=hello" />

Note that you may be better off using:

header("Location: register.php?var=value&othervar=hello");
exit;