redirecting to error page produces original content below?

Discussion in 'PHP' started by ElusiveOne, Mar 3, 2010.

  1. #1
    The following php is used to redirect the user of an email form if the email address does not meet the syntax.

    // Subscription request from a subscription form (in page or widget), can be
    // a direct subscription with no confirmation
    if ($action == 's') {
    if (!newsletter_is_email($_REQUEST['ne'])) {
    $url = "http://www.ace4space.com/content/subscription-error/";
    $content = file_get_contents($url);

    echo $content;
    }

    Unfortunately this produces an error where the user is taken to the correct URL

    HOWEVER;

    The initial page is displayed BELOW the new URL contents? Any idea on how to redirect the user to a fresh page showing the subscription error page ONLY without the referring page below it...
    Please view any page @ http://www.ace4space.com and enter a NON formated email address to be sent to http://www.ace4space.com/content/subscription-error/ and see what I mean!

    Its annoying me! Why won't the http://www.ace4space.com/content/subscription-error/ page just display the content of http://www.ace4space.com/content/subscription-error/?
     
    ElusiveOne, Mar 3, 2010 IP
  2. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #2
    JAY6390, Mar 3, 2010 IP
  3. chriseccles2

    chriseccles2 Peon

    Messages:
    28
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    What have you got AFTER the ending curly brace of the 'if' loop ? ? ?

    ;-)
     
    chriseccles2, Mar 3, 2010 IP
  4. Narrator

    Narrator Active Member

    Messages:
    392
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    80
    #4
    If you haven't passed headers do what JAY6390 said, if not try:

    
    // Subscription request from a subscription form (in page or widget), can be
    // a direct subscription with no confirmation
    if ($action == 's') {
    if (!newsletter_is_email($_REQUEST['ne'])) {
    $url = "http://www.ace4space.com/content/subscription-error/";
    echo "<SCRIPT LANGUAGE=javascript>window.location='$url'</SCRIPT>";
    exit();
    }
    
    PHP:
     
    Narrator, Mar 3, 2010 IP
  5. ElusiveOne

    ElusiveOne Peon

    Messages:
    87
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Woo Woo thanks Jay - all sorted now mate - and thanks to all who commented!
     
    ElusiveOne, Mar 3, 2010 IP