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

  • SEARCH
  • Home
  • 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 7065217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:55:46+00:00 2026-05-28T04:55:46+00:00

I have a .php that registers a user by calling another php function but

  • 0

I have a .php that registers a user by calling another php function but i dont know what the best way to redirect a user if the registration is successful. Is there an option other than header incase i want to echo something before i redirect?

<?
// processRegister.php
//////////////////////

// First include the class definition
include('UserClass.php');

// Next, create an instance of the class
$newUser = new User;

// Call the registerUser() method, passing in the required variables
$newUser->registerUser($userName, $userPassword);

// If it was an error, the class will kill the script, if not, it will reach this point
$newUser->displayUserInfo();
?> 
  • 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-28T04:55:47+00:00Added an answer on May 28, 2026 at 4:55 am

    You can use 4 methods, as you said using a header redirect:

    <?php header('Location: success.php'); exit; ?>
    

    Another is to use a session and to set some message you want to display and then display that message after you have redirected.

    if($login){
      $_SESSION['login_message'] = "Your account has been logged in ".$newUser->username;
    }
    
    //after redirect
    if(isset($_SESSION['login_message']){
      echo $_SESSION['login_message'];
    }
    

    You can also use javascript:

    <script type="text/javascript">
    <!--
    window.location = "http://www.google.com/"
    //-->
    </script>
    

    in php:

    <?php echo '<script>window.location = "http://www.google.com/"</script>'; ?>
    

    The last method is to use a HTML redirect:

    <html>
    <head>
    <meta http-equiv="Refresh" content="5;url=http://www.w3schools.com" />
    </head>
    
    <body>
    <p>Your message here, probably in php</p>
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a PHP application that displays a list of options to a user.
i have made user-register.tpl.php file. And i have set many text field in that.
I have the following facebook registration plugin that lets user register through their FB
I have php scripts that do things like register, login, upload. I would like
I have PHP configured so that magic quotes are on and register globals are
I have php script that creates a temporary watermark image for users that are
I have PHP scrip that goes like this: if ($cost_frm < $cost){ echo <script
I have a php that makes some maintenance operations in my web and I
I have a php file somejson.php that echos a json encoded array {jsonone:first json,jsontwo:second
I have a php server that is running my domain name. For testing purposes

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.