SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Dec 2013
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Redirecting output back to html page

    I have a html page with a form with all the processing done on a separate php file, though what should I do if I want to report an error in form validation back to the existing html page alongside the users form instead of just doing die() and creating a new page to report the form validation error to the user.

  2. #2
    SitePoint Member PhoenixWS's Avatar
    Join Date
    May 2014
    Location
    UK
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I believe that this is not possible if the page does not have a .php extension.

    If it does have a .php extention you could do something like below, obviously = error is not valid code but you would replace the $form_part with the part that you are validating and error with what it should equal or match.
    Code:
    if($form_part1 = error) {
        $error_msg = "Error Message";
    } elseif($form_part2 = error) {
        $error_msg = "Error Message 2";
    } else {
        // Validate the form
    }
    and then on your page that contains the form something like this should work
    Code:
    if(isset($error_msg)) {
        echo $error_msg;
    }


Bookmarks

Posting Permissions

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