Redirect in a Php page (joomla)

Hello guys,

how can Redirect to a custom page (article) in joomla in the code below I have some ideas but I am more into .net programming and  have zero  to none skills on php , but I believe this can be done, thanks!!
<?php defined( '_JEXEC' ) or die( 'Restricted access' ); ?>

<?php
    
    $url = JRoute::_("components/com_jquarks/assets/stylesheets/jquarks_style.css");
    $document =& JFactory::getDocument();
    $document->addHeadLink($url, "stylesheet", "rel");
?>

<div class="componentheading">
	<?php echo JText::_('RESULTS'); ?>
</div>

<!-- Rick Modified ........ Old line 11 was echo JText::_('SESSION_RESULTS'); ?> -->


<!-- Score and answers status -->
<?php
    $score = $this->session->score;
    $totalScore = $this->totalQuestions - $this->totalInput + $this->inputEvaluated;
    $percent = $score * 100 / $totalScore;
?>

<!-- Rick Modified  Redirect if less than 100 %--->

<?php
  
 if($score <100 )
 
  { 
  
echo 'Please retake Test ';
  //NEED CODE TO REDIRECT
  
   }
                                         
	
	?>

Open in new window

LVL 9
TonyRebaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
"Redirect" is often associated with the header("Location: ...") command.  It is a law of HTTP that all headers must come before and be complete before any browser output.  So the concept of putting a header() redirect behind an echo will not work.

You have some choices.  You can use output buffering to catch the browser output.  Then you can issue the header() command.  Your client will not see anything but the redirect.

Or you can use the meta refresh tag with a delay time.  It is deprecated, but works perfectly well.

Or you can give the client the message to retake the test and give the client a clickable link to the URL to retake the test.

HTH, ~Ray
te-eduCommented:
$test = getAllHeaders() ;
will collect all you need

to see what you need :
print_r($test);
TonyRebaAuthor Commented:
Ray:
" you can give the client the message to retake the test and give the client a clickable link to the URL to retake the test."


, How would I do this???

Amazon Web Services

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Ray PaseurCommented:
Line 32:
echo 'Please retake Test ';

And after that, echo the HTML <a href= tag that points to the page where you take the test.
TonyRebaAuthor Commented:
this is my current code which checks a score lower than 100 and then will display a retake link, Or redirect automatically.


if($score <100 )
 
  { 
  
echo 'Please retake Test ';
  //NEED CODE TO REDIRECT

  
   }
                                         
	
	?>

Open in new window

TonyRebaAuthor Commented:
I dont know much php syntax can younplease show me the right sintax??
TonyRebaAuthor Commented:
I think I got something like this pershaps?
<?php
  
 if($score <100 )
 
  { 
    //NEED CODE TO REDIRECT
echo 'Please retake Test ';  
 }
 
?>

<p>
 <a href="index.php?option=com_jquarks&view=quiz&id=1&Itemid=2">Re-take test</a>.
                                        
	

<br />

Open in new window

Ray PaseurCommented:
The echo statements would need to be inside the curly braces (also called the "control structure"), like this.
<?php
if( $score < 100 )
{ 
    echo 'Please retake Test '; 
    echo '<a href="index.php?option=com_jquarks&view=quiz&id=1&Itemid=2">Re-take test</a>.'; 
}

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
TonyRebaAuthor Commented:
cool that worked!! how to break line here:


<?php
if( $score < 100 )
{ 

    echo 'A score of 100% is required to pass this quiz. Click the link below to re-take the test' \n;
	
    echo '<a href="index.php?option=com_jquarks&view=quiz&id=1&Itemid=2">Re-take test</a>.'; 
}
 ?>

Open in new window

Ray PaseurCommented:
Thanks for the points.  This ought to do it...

Best regards, ~Ray
<?php
if( $score < 100 )
{ 
    echo 'A score of 100% is required to pass this quiz. Click the link below to re-take the test' . PHP_EOL;
    echo '<br/><a href="index.php?option=com_jquarks&view=quiz&id=1&Itemid=2">Re-take test</a>.'; 
}
?>

Open in new window

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Joomla

From novice to tech pro — start learning today.