TonyReba
asked on
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!!
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
}
?>
$test = getAllHeaders() ;
will collect all you need
to see what you need :
print_r($test);
will collect all you need
to see what you need :
print_r($test);
ASKER
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???
" 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???
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.
echo 'Please retake Test ';
And after that, echo the HTML <a href= tag that points to the page where you take the test.
ASKER
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
}
?>
ASKER
I dont know much php syntax can younplease show me the right sintax??
ASKER
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 />
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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>.';
}
?>
Thanks for the points. This ought to do it...
Best regards, ~Ray
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>.';
}
?>
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