0

我有一个表单,一旦用户单击提交按钮,他就会被发送到 save.php 页面。在 save.php 页面上,表单的信息被发送到 MySQL 表。但是,在 save.php 页面上,我放置了一个重新编辑,将用户带到一个独特的页面,在那里他可以看到他刚刚输入的信息。

为此,我在包含用户信息的表格中放置了一个唯一代码,以放置在“唯一页面”的 URL 中。这是涉及我所谈论内容的代码部分。

 $registerquery = mysql_query("INSERT INTO users_event (x, x, x, x, x, Confirm_code) VALUES('".$x."', '".$_SESSION['x']."', '".$x."', '".$x."', '".$x."', '".$confirm_code=md5(uniqid(rand())). "'); ");
    if($registerquery)

    {
        echo "<h1>Congrats!</h1>";
        echo "<p>All perfect!</p>";
        echo "<meta http-equiv='refresh' content='0;URL=show2.php?confirm_code=<?php echo $registerquery[Confirm_code];?> />";
}

我的问题是确认代码从不显示在 URL 中。所以,独特的页面也没有。如何使确认代码显示在 URL 中?

4

4 回答 4

1

您正在插入 MySQL 而不是选择。$registerquery 变量不包含代码。因此,在查询之前将确认代码保存在某个 php 变量中。

$temp_code = Confirm_code; //whatever the code is

然后

 $registerquery = mysql_query("INSERT INTO users_event (x, x, x, x, x, Confirm_code) VALUES('".$x."', '".$_SESSION['x']."', '".$x."', '".$x."', '".$x."', '".$confirm_code=md5(uniqid(rand())). "'); ");
if($registerquery)

{
    echo "<h1>Congrats!</h1>";
    echo "<p>All perfect!</p>";
    echo "<meta http-equiv='refresh' content='0;URL=show2.php?confirm_code=<?php echo $temp_code;?> />"; }

使用该临时变量而不是 $registerquery[Confirm_code]

另一种方法是首先插入然后选择我认为你真的不想这样做。

于 2013-08-04T03:25:06.740 回答
1

您的确认代码永远不会显示,因为您的查询很可能会失败。您可以or die(mysql_error())在查询结束时使用来验证 -$registerquery = mysql_query(...) or die(mysql_error())

在查询之外创建变量,然后将其添加到查询和元字符串中。

$confirm_code=md5(uniqid(rand()));
$registerquery = mysql_query("INSERT INTO users_event (x, x, x, x, x, Confirm_code) VALUES('".$x."', '".$_SESSION['x']."', '".$x."', '".$x."', '".$x."', '".$confirm_code. "'); ");
if($registerquery){
        echo "<h1>Congrats!</h1>";
        echo "<p>All perfect!</p>";
        echo "<meta http-equiv='refresh' content='0;URL=show2.php?confirm_code=".$confirm_code."' />";
}
于 2013-08-04T03:30:34.760 回答
0

我假设你的意思是使用你的$confirm_code变量?因为您要插入数据库,而不是选择.

echo '<meta http-equiv="refresh" content="0;URL=show2.php?confirm_code=' . $confirm_code . '" />';
于 2013-08-04T03:27:11.953 回答
0

在将值插入数据库的同时,您正在为 $confirm_code 分配一个值。只是改变:

$registerquery[Confirm_code]

$confirm_code
于 2013-08-04T03:29:39.237 回答