简体   繁体   English

POST变量未正确保存

[英]POST variable is not being saved correctly

Im using method post to send a mutliple input text form, i draw information from the database to after re insert the information which is inside input text: 我使用方法post发送一个多输入文本形式,我从数据库中提取信息到重新插入输入文本内部的信息之后:

echo "<CENTER><TABLE BORDER='0'>";
echo "<FORM METHOD='POST'>";
$sele_players = "SELECT nombre FROM JUGADORES WHERE NOM_EQUIPO='Aston villa'";
        $sele_players = mysql_query( $sele_players , $link );

        while( $row = @mysql_fetch_assoc( $sele_players ) )
        {
            $row['nombre'] = addslashes( $row['nombre'] );
            echo "<TR><TD ALIGN='CENTER'>".$row['nombre']."</TD>";
            echo "<TD><INPUT TYPE='TEXT' NAME='{$row['nombre']}'></TD></TR>";
        }

        echo "<TR><TD COLSPAN='2' ALIGN='CENTER'><INPUT TYPE='submit' NAME='send2' VALUE='INSERTAR' style='width:200px; height:60px' ></TD></CENTER></TR>";

ok here i get the names of players from database, then i use them for insert inside input text as his name, to after pick with array $_POST: 好的,这里我从数据库中获取球员的名字,然后用它们在输入文本中插入他的名字,然后用数组$ _POST进行选择:

    if( !empty( $_POST['send2'] ) )
    {

        foreach($_POST as $jugador => $points)
        {
            $jugador = str_replace( "__" ,". ", $jugador );
            $jugador = str_replace( "_" ," ", $jugador );

            if( $points == "" )
            {
                $points = "NULL";
            }

            $inser_jornada = "INSERT INTO JORNADA VALUES( '{$_GET['jornada']}','{$_GET['equipo']}', '$jugador', '$points', now() );";

So there is no problem with most of names, excluding N'Zogbia name or apostrophe names which is shown in $_POST array as 'N', i have tried adding slashes before send it through from but doesnt work, so i dont know how to get the complete name in post array, thats the main problem. 因此,大多数名称都没有问题,但在$ _POST数组中显示为N的N'Zogbia名称或撇号名称除外,我曾尝试在从中发送斜线之前将其添加为斜杠,但无法正常工作,因此我不知道如何获取完整的名称在post数组中,这就是主要问题。

THanks forwarded!! 谢谢转发!

There are many things to point out here. 这里有很多事情要指出。 But instead of that, I will try my best to be helpful. 但除此之外,我会尽力提供帮助。

Add your database entries using mysql_real_escape_string($variableName) to enter the content to the database. 使用mysql_real_escape_string($variableName)添加数据库条目以将内容输入数据库。 It will automatically escape such quotes and make it a little SQL Injection proof. 它将自动转义此类引号,并使其成为一点SQL注入证明。

As it was mentioned before, your code "screams" help. 如前所述,您的代码“尖叫”会有所帮助。 There are lot of things to point out, but back to your answer: I think your problem is in the following line: 有很多事情要指出,但是回到您的答案:我认为您的问题出在以下几行:

 $inser_jornada = "INSERT INTO JORNADA VALUES( '{$_GET['jornada']}','{$_GET['equipo']}', '$jugador', '$points', now() );";

Try this instead: 尝试以下方法:

$inser_jornada = 'INSERT INTO JORNADA VALUES( "' . $_GET['jornada'] . '", "' . $_GET['equipo'] . '", "' . $jugador . '", "' . $points . '", now() );';

I would really, really recommend that you run mysqli_real_escape_string() to all your input. 我真的会真的建议您对所有输入都运行mysqli_real_escape_string()。

Good luck! 祝好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM