Page 1 of 1

Undefined Index

Posted: Tue Dec 27, 2005 2:34 am
by bubberz
I've got a page a user sees if they're a new user. They enter an email and password.

If the "Check New Username" behavior allows the entry to continue, the new user will enter more information about themselves.

I'm trying to use the Email and password for the first two text fields in the next form via Bindings / Form Variable, but get the following for both these fields:

Undefined index: Email in <b>C:\htdocs\NewSubInfo.php

The HTML is:

value="<?php echo $_POST['Email']; ?>"

This should be pretty simple, but I'm not too sure what I'm doing wrong.

Thanks!

Posted: Tue Dec 27, 2005 3:59 am
by jmut
To have something in $_POST variable, hence, not having undefined index you should first submit a form.
Clearly the first time the page is accessed no form is submitted.


You should check if there is something in $_POST.

Code: Select all

if (isset($_POST['field_name'])) {
  $field_name = $_POST['field_name'];   //will do this if you have posted form
} else {
  $field_name = 'default value';  //if you do not have post there will be default value. For example the first time you access the page(before submiting post.)
}

//...use $field_name somewhere.
Have in mind that you should validade each POST as dada most probably comes from user interaction and we all know users are not to be trusted.