Page 2 of 2 FirstFirst 12
Results 16 to 17 of 17

Thread: Struggles with form validation

  1. #16
    Join Date
    Nov 2013
    I think that the problem is that you are trying to echo undefined variables as the values in your input boxes and this is why you are getting the errors. The reason these are echoed this way is because without them, if someone enters data, and your code does not like what is entered and displays an error message, all the inputs will go away.

    A common way to prevent this error is to set all of those variables to empty in the beginning. Try putting the below code at the top of the file with the rest of your variables and see what that does. I think it will fix your problem, although I could be wrong.

    PHP Code:
    $strForename $strAge $strEmail ''

  2. #17
    Join Date
    Nov 2013
    Just a cursory glance and I notice your first issue is that your setting variables with unknown or empty values which are undefined
    PHP Code:
    $strSuggestion $_POST["suggestion"]; 
    try doing this
    PHP Code:
    $strSuggestion = isset($_POST["suggestion"]) ? $_POST["suggestion"] : null
    then just check if the variables are null before doing other checks
    PHP Code:
    $strError .= "<li>Your error message</li>\n";

    this should resolve your undefined issues.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center