moodle php页面重定向继续页面重定向时出现

I have a moodle page and from that page I am trying to redirect to another page using redirect as follows:

redirect("page2.php?cId=".$cid);

I got redirect to the other page but while redirecting I am viewing something as follow:

enter image description here

It looks like so messy. I want to avoid this.

Here current page is having moodle header and footer and the page2.php does not have moodle header and footer

How can I avoid this Continue page?

Make sure Debugging is enabled (set to 'Developer' and display).

You may see a warning message here, that might explain why the redirect is not working immediately.

The most likely explanation is that something has been output before redirect is called. Look through your code for any 'echo' or 'print' calls before the redirect is reached.

If you can't find any 'echo' or 'print' calls, make sure there are no spaces (or any other characters) before the opening '<?php' tags in any of your files, that there are no closing '?>' tags at the end of your files (it is very easy to add unwanted spaces after closing PHP tags) and that there are no unwanted inline HTML sections.

Try the following in your code :

redirect("page2.php?cId=".$cid, 'Loading', 1); 

this will display "Loading" message and delay 1 second.

You will need to modify the outputrenderers.php file in moodle/lib. Look for the redirect_message public function and you will see a line that says something like:

$output .= '<div class="continuebutton">(<a href="'. $encodedurl .'">'. get_string('continue') .'</a>)</div>'; 

Either choose another string from the lang/en/moodle.php i18n file using get_string, or remove it all together. For example if you want to hard code a more informative message:

$output .= '<div class="continuebutton">(<a href="'. $encodedurl .'">Please click here if you are not automatically redirected within '.$delay.' seconds</a>)</div>';