Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6730051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:21:44+00:00 2026-05-26T10:21:44+00:00

I call this function from another page Redirect($loc); and I want it to redirect

  • 0

I call this function from another page

  Redirect($loc);

and I want it to redirect my server..

function Redirect($loc) 
{    
   echo ("<script type=\"text/javascript\">var timeout=1; setTimeout(\"window.location.replace('" . $loc . "')\", timeout*1000 );</script>");    
} 

I have two questions. one is the script in the function is correct?
second, how do I pass it a url, assuming I am using the localhost and I want my applicaton to be portable. So I my file is called Registration.php and it is in the Users folder of my site, how do I contruct a url?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T10:21:45+00:00Added an answer on May 26, 2026 at 10:21 am

    Is there any particular reason that you’re using Javascript to redirect? What if the client has Javascript disabled?

    A better way to perform redirection would be to do it server-side like such:

    function redirect($location)
    {
        header('Location: ' . $location);
        die();
    }
    

    That will send the location header to the browser thus redirect it immediately, saving you bandwidth and the possibility that Javascript is disabled on the client side.

    Note that as this is a header, you will need to either call this method before you have output any data (with echo or otherwise), or use output buffering so as to not have to change your application much.


    As described in comment to cover a relative URL, you could use a constant storing your web root which would work like this (replace line):

    header('Location: ' . WEB_ROOT . $location);
    

    Example usage:

    <?php
    define('WEB_ROOT', '/');
    function redirect($location) 
    {
        header('Location: ' . WEB_ROOT . $location);
        die();
    }
    redirect('Users/Registration.php');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to call a page with ajax, but from another server. This
I've got an html page from where Im making this call periodically: function logon(id)
I have a JavaScript function, pop_item . I have to call this from PHP,
I have a UDF in sql server. I want to call this function at
i call my UI dialog from page which has scriptManager, this way: function openDialog()
Has anyone seen this error when trying to call an external C function from
From: http://ejohn.org/apps/learn/#2 Function.prototype.bind = function(){ var fn = this, args = Array.prototype.slice.call(arguments), object =
If I want to trigger an error in my interpreter I call this function:
When calling a function from a page in javascript, is there a way to
Does anybody know how to redirect parent page from an ajax call? I made

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.