-1

with this code:

$tstUsername = getValue($_POST['tstUsername']);
$tstPassword = getValue($_POST['tstPassword']);

if ($tstUsername !== false && $tstPassword !== false) {
    echo "New string added to database!";
    haydayshops_mysql_query($conn,"INSERT INTO table_accounts (username, password) VALUES >('$tstUsername','".sha1($tstPassword)."')");
}

The code works fine, but when i put the error mode on, i see this nasty errors:

Notice: Undefined index: tstUsername in ...

Undefined index: checkPassword in ...

Community
  • 1
  • 1
  • What is your question? Are you wondering [what undefined index means](http://stackoverflow.com/questions/12769982/reference-what-does-this-error-mean-in-php/12770836#12770836)? – kero Dec 28 '13 at 21:43
  • var_dump($_POST)to make sure correct data is in post – Awlad Liton Dec 28 '13 at 21:43

1 Answers1

1

You get these errors because you're trying to access to key of an array which doesn't exists. Here, you access to $_POST['tstUsername'] but it doesn't seems to exists in the $_POST data. Same case with a key named checkPassword somewhere else in your code.

To avoid that, use isset() function to check if they are declared before trying to access to the value.

Maxime Lorant
  • 28,973
  • 16
  • 79
  • 93