English 中文(简体)
如何检查是否设置了员额?
原标题:How to check whether a post was made or not?
if(isset($_POST["email"]))
{
$email = mysql_real_escape_string($_POST["email"]); /* Line 10 */
$password = mysql_real_escape_string($_POST["password"]);

$result = mysql_query("SELECT password, id FROM users WHERE email =  $email ");

if (!$result)
    {
        die( Invalid query:   . mysql_error());
    }

$row = mysql_fetch_assoc($result);

if($row[ password ] == $password)
    {
        ini_set("session.cookie_lifetime","360000");
        session_start();
        $_SESSION[ valid_user ] = $row[ id ];
        $_SESSION[ email ] = $row[ email ];
        mysql_close($link);
        header( Location: index.php );
    }


mysql_close($link);
}

I m不设任何员额,但指出$email 没有在第10条下定义。 为什么? http://www.easyphp.org/“rel=“nofollow” 方便PHP。

Notice: Undefined index: email in C:Program FilesEasyPHP-5.3.5.0wwwv0.3modellogin.php on line 10

最佳回答

采用最可靠的方法检查是否填写了名册。

if ($_SERVER[ REQUEST_METHOD ] ==  POST ) {
   ... you re in a post ...
}

检查某个特定形式领域是有风险的——你可能重新命名/脱离实地,并忘记更新表格。 但是,核对这一美元价值100%是可靠的——不管用什么方法使用该笔记本,它始终可以提供。

问题回答

它说,由于<代码>_POST阵列是空的(当然,你没有张贴),你正在试图查阅emailindex of that place if(isset ($_POST[“email”])),而这种编号的确存在。

You could fix this by doing:

if (isset($_POST[ email ]))
$email = mysql_real_escape_string($_POST["email"]);

:这只是一份通知,它胜诉影响到你的申请,因此,你不会对此感到太多担忧,你将拥有一部更清洁的法典。 ∗∗∗∗∗ https://stackoverflow.com/questions/1960509/isset-and-empty-make-code-ugly/> 如何避免出现()和空洞()

UPDATE

为预防通知而添加固定功能。 由于欺骗。

array() = 虚假,因此不:

if($_POST)
{
    // stuff
}

有些人胜过这一点,但我说,如果你重新使用一种充满活力的语言,你也会利用这一语言。





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签