2014-01-21 52 views
-1

我有一个问题$remarks。它给我一个错误:

Notice: Undefined index: remarks in C:\xampp\htdocs\index.php on line 83

我不知道如何解决这个问题。当我完成注册部分中的所有字段时,它看起来没问题(“注册成功”),但没有数据添加到我的数据库中。有人能帮我吗?

<?php 
$remarks=$_GET['remarks']; 
$username="username"; 
$password="password"; 

if ($remarks==null and $remarks=="") 
{ 
echo 'Register Here'; 
} 
if ($remarks=='success') 
{ 

$insert = mysql_query("INSERT INTO simple_login('username','password') VALUES ('$username','$password')"); 
echo 'Registration Success'; 
} 
?> 
+0

删除'('username','password')'中的引号或者更好,用反引号替换它们。接下来..........的答案(呵呵,不要用纯文本存储密码)+'mysql_ *'combined = ['确定hack'](http://stackoverflow.com/q/60174 /)。另外,使用'GET'在地址栏中通告密码,顺便说一句。换句话说,**“不要使用此代码”。** ---旁注:'&&'优先于'AND' –

+0

@scrowler:'=='在PHP中很棘手,我不会所以肯定它.. :) –

+0

@KarolyHorvath - touche,https://eval.in/92553 –

回答

-1

你有一个无效的SQL查询,所以显然没有数据被插入到数据库。

修复查询。 SQL字段名称不应引用。

这个故事的寓意:经常检查每个API调用的结果(在这种情况下:mysql_query

+0

这完全没有回答这个问题 –

+0

@scrowler:现在开心吗? –

+0

nope,你的建议如何解决未定义的索引错误,可能与他的脚本顶部的$ _GET变量有关? –

0

我建议检查你的SQL脚本。打印(回显)变量$ username和$ password。 当然,也许regis所有的SQL脚本字符串变量和回声检查它。

$strSQL="INSERT INTO simple_login('username','password') VALUES ('$username','$password')";  
echo $strSQL; #to check your SQL script 
$insert = mysql_query($strSQL); 
echo 'Registration Success';