Find the answer to your Linux question:
Results 1 to 4 of 4
Hi all, I have a html login form. Once login is clicked I call a cgi script that checks for the correct password. I then want to redirect to another ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jun 2012
    Posts
    9

    redirect to a web page


    Hi all,

    I have a html login form. Once login is clicked I call a cgi script that checks for the correct password. I then want to redirect to another page or call another cgi script. How do i redirect to another script/webpage using C?
    Last edited by janhar; 09-05-2012 at 06:02 AM. Reason: SOLVED

  2. #2
    Just Joined!
    Join Date
    Oct 2006
    Posts
    32
    Would having it print a javascript window.location work?

    For example:

    Code:
    if ( $auth == 0 ) {
        printf("<script javascript>");
        printf("alert(\"Auth success!\";);
        printf("window.location = \"mypage.html\";);
        printf("</script>");
    }

  3. #3
    Just Joined!
    Join Date
    Jun 2012
    Posts
    9
    That didn't work for me. This did

    printf("<META HTTP-EQUIV=\"refresh\" content=\"2;URL=mypage.html\">");

    Thank you

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Guru Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,252
    janhar: that's not quite the right way to do it. Redirection is done by using a special HTTP header, with a 3xx status code (for this case, 302). You can read more here:
    https://en.wikipedia.org/wiki/URL_re...atus_codes_3xx

    You will need to be able to modify the HTTP header, but this is definitely the most straightforward way to do redirection.

Posting Permissions

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