【问题标题】:$_POST function won't work?$_POST 功能不起作用?
【发布时间】:2012-01-30 06:43:07
【问题描述】:

我无法从此处找到的页面获取文本字段:Here 并将其移至此处:Here 正如我之前所见,我已经尝试过 $_post 函数,但它似乎没有传递信息!

这是当前描述的第一页的脚本:

<?php
// Creator: Will Renfroe
// All rights Reserved

//Vote Sites and MySQL
$DBNAME="mysql";
$DBUSER="mysql";
$DBPASSWORD="mysql";
$DBHOST="mysql";

///////////////////
// SCRIPT
///////////////////
mysql_connect($DBHOST, $DBUSER, $DBPASSWORD) or die("<center>Cannot connect to MySQL</center>");
mysql_select_db($DBNAME) or die("<center>Cannot select DB</center>");
/////////

?>

<?php
    include("secure.php");
    if (getenv(HTTP_X_FORWARDED_FOR)) {
    $pipaddress = getenv(HTTP_X_FORWARDED_FOR);
    $ipaddress = getenv(REMOTE_ADDR);
} else {
    $ipaddress = getenv(REMOTE_ADDR);
}

if(isset($_POST['dovote'])){
check_inject();

    //Get user id from session
    $userid=secure($_POST["nick"]);
    $time=time();

    $query=mysql_query("SELECT nick,time FROM votesdb WHERE ip='$ipaddress'");
    $checkip=mysql_num_rows($query);
    $iprow=mysql_fetch_row($query);

    $query=mysql_query("SELECT time FROM votesdb WHERE nick='$userid'");
    $checkuser=mysql_num_rows($query);
    $userrow=mysql_fetch_row($query);

    if ($checkuser){
        //if user vote
        if ($checkip and $time>$iprow[1]){$canvote=1;}
        if (!$checkip and $time>$userrow[0]){$canvote=1;}
    }else{
        //if user never vote
        if ($checkip and $time>$iprow[1]){$canvote=1;}
        if (!$checkip){$canvote=1;}
    }

    //Do Vote
    if ($canvote){
        $newtime=time()+60*60*24;

        if ($checkuser){
            //update
            mysql_query("UPDATE votesdb SET time=$newtime, ip='$ipaddress', votes=votes+1, flags=flags+1 WHERE nick='$userid'");
        }else{
            //insert
            $query=mysql_query("INSERT INTO votesdb(nick,time,ip,votes,flags) VALUES ('$userid',$newtime,'$ipaddress',1,1)");
        }

        //Add nick to nicklist table
        $query=mysql_query("INSERT INTO nicklist(nick) VALUES ('$userid')");

        echo "<font color='red'>You can vote every 24 hours to get reward.</font>";
    }else{
        echo "<font color='green'>thank you for voting!</font>";
    }
}

?>






<style type="text/css">
.minecrafttext {
    font-family: "Volter (Goldfish)";
    font-size: 12px;
    color: #0F3;
}
.minecrafttext {
    font-family: "Volter (Goldfish)";
}
</style>
<body background="http://files.enjin.com/121395/19.gif" bgproperties="fixed"><div style="text-align: center;"> <img style="border: medium none;" alt="" title="" src="http://files.enjin.com/121395/Vote_For_Diamonds.png"><span style="color: rgb(255, 165, 0);"><br>You will get <span style="font-weight: bold; font-size: 18pt; color: rgb(255, 0, 0);">10</span></span> <img style="border: medium none; width: 37px; height: 34px;" alt="" title="" src="http://www.minecraftwiki.net/images/9/90/Diamond_%28Gem%29.png"><span style="color: rgb(255, 165, 0);">for voting on the sites below!</span><br></div><div style="text-align: center;"><span style="color: rgb(30, 144, 255); font-weight: bold;"></span><span style="color: rgb(30, 144, 255); font-weight: bold; text-decoration: underline;">Directions:</span><br>
  <br>
  <span class="minecrafttext">Vote right here: </span>
</div>

<center>
  <form target="_blank" action="http://www.minecraftservers.net/vote.php?id=1991" method="post"> 
  <p>
    <input onClick="document.getElementById('vote4').disabled=false" value="Minecraftservers.net" name="vote1" id="vote1" type="submit" />
  </p>
  <p class="minecrafttext">And here:&nbsp;</p>
</form>
<form target="_blank" action="http://www.minestatus.net/15901-freebuildxiz" method="post">
  <input onClick="document.getElementById('vote5').disabled=false" disabled="disabled" value="Minestatus" name="vote1" id="vote4" type="submit" />&nbsp;</form>
<br/>
  <form method="POST">
    <font color='lime' class="minecrafttext"><strong>Put your In-Game-Name here!</strong></font><br/>
    <input name="nick"/><br/>
<form method="POST">
<input name="dovote" type="submit" value="Receive Diamond" onClick="document.getElementById('vote5').disabled=false" id="vote5" disabled="disabled" onSubmit="return nameempty();" /> 
</form> 
<a href="http://legacyserver.info/fbxtop.php" target="http://legacyserver.info/fbxtop.php" class="minecrafttext">Click here to see the Top 10 voters!</a>
</center>

</body>
</html>

这里是第二个:

<body background="http://files.enjin.com/121395/19.gif" bgproperties="fixed"><div style="text-align: center;"><br /> <img style="border: medium none;" alt="" title="" src="http://files.enjin.com/121395/Vote_For_Diamonds.png"><br /><center><font color='cyan'>Click below to start the vote for diamonds process!</font></center><br /><br />
<form method="POST" action="VotingScriptfbxiz.php">
<input type="image" method="POST" action="VotingScriptfbxiz.php" src="http://files.enjin.com/121395/JulieGloopUI(43)45(REV2).png" alt="Submit value="POST" input name="VoteVerify" id="submitButton" />

当我尝试将文本字段从第一页移动到第二页并仍然让它正确提交信息时,它不想正常工作。

另外,描述的第一个脚本似乎存在某种问题,它说您每次都投票,但它甚至不想将您添加到数据库中,我已经尝试了很多版本在我搞砸的时候突然发生了

【问题讨论】:

  • 您的图像输入不需要方法或操作,而且您没有正确关闭您的 alt 属性。此外,您有 9 个表单,其中一些未关闭,其中一些没有操作。
  • @will,附带说明一下,将 $_POST 视为(超级全局)变量而不是函数可能会有所帮助。
  • 该标记中有很多非常奇怪的错误。使用a validator
  • 显然,我还在学习,而且我没有最干净的工作,我实际上是在找人教我而不是看youtube教程:/
  • 您已尝试在此条件if(isset($_POST['dovote'])) 内运行您的代码。但是提交按钮“dovote”是disabled='disabled'

标签: php post text field move


【解决方案1】:

您的第二个脚本是错误的。您需要将其更改为:

<body background="http://files.enjin.com/121395/19.gif" bgproperties="fixed">
   <div style="text-align: center;"><br /> 
       <img style="border: medium none;" alt="" title="" src="http://files.enjin.com/121395/Vote_For_Diamonds.png"/><br />
<center><font color='cyan'>Click below to start the vote for diamonds process!</font></center><br /><br />
<form method="POST" action="VotingScriptfbxiz.php">
  <input type="image" src="http://files.enjin.com/121395/JulieGloopUI(43)45(REV2).png" alt="Submit" value="POST" /> 
  <input name="VoteVerify" id="submitButton" />
  </form>
 </div>
 <body/>

为什么要对图像标签使用动作和方法。不需要那个。你也不要关闭表单标签并输入 type="image" 标签

也使用验证器来验证。

你为什么不必要地使用
标签。使用样式使其正确。

希望这会有所帮助:)

【讨论】:

  • 谢谢!我还没有尝试过,但是当我这样做时,我会给你最好的答案;)
  • 等等,它对我的​​第一个问题有用......但整个事情仍然只是......不起作用你可以在这里看到我的意思:link
  • 问题是即使您与未向数据库添加投票的用户投票,对吗?是这个问题吗
  • 我不完全理解你的意思,但它没有正确验证用户,它与 if 语句有关,它说“你只能每 24 小时投票一次”。即使您在过去 24 小时内没有投票,并且如果您查看此处:legacyserver.info/fbxtop.php,您也会看到当您投票时数据库中没有任何变化。它不会添加您,如果您的投票失败,您会收到消息,因为您已经投票了。
  • 我很困惑。有一件事把你网站的网址发给我,这里添加的第一个脚本是 php 吗??
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-05-25
  • 2016-02-24
  • 2023-03-13
  • 2021-08-27
相关资源
最近更新 更多