• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 662
  • Last Modified:

How do I create a PHP page to display a certificate of completion from Joomla

Hi folks, I am working on modifying a joomla component called j quarks, it does almost all what I need for my quiz system to work, however, I intend to enhance the component and at the end of the quiz (if a score of 100%) , have the user print out a certificate of completion with
 his name , quiz name , and date quiz taken .

 I am more a Asp.net person..  Is there any php guru here that can help me building this page, or at least point me into the right direction.   This are the files I have . The first one is a form that user fills out once he completes the quiz, -> next step is the quiz result pages which I have included a link to a new page (certificate.php)  Now I am missing how to display the person who takes the quiz on a certificate page. Thanks

I need to build certificate.php
form.php

<?php
defined( '_JEXEC' ) or die( 'Restricted access' );
JHTML::_('behavior.mootools');
?>
<script type="text/javascript" language="javascript">

	function validEmail(email) 
	{
		pattern = new RegExp("^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$") ;

		return pattern.test(email) ;
	} 

	function checkForm() 
	{
		lastname = document.getElementById('lastname').value ;
		firstname = document.getElementById('firstname').value ;
		email = document.getElementById('email').value ;
		
		if (lastname != '' && firstname != '' && validEmail(email)) {
			return true ;
		} 
		else 
		{
			alert("<?php echo JText::_('ERROR_FILL_REQUIRED_FIELDS_PRVOIDE_VALIDE_EMAIL') ; ?>") ;
			return false ;
		}
	}

</script>

<p style="font-style: normal; font-size: 16px;font-weight: bold; color: #333;"><?php echo JText::_('Thank you for taking this quiz') ; ?></p>
</br>
<form method="post" onsubmit="return checkForm();">
  <table>
		<tr>
			<td><?php echo JText::_('First Name') ; ?> :</td>
			<td><input type="text" id="firstname" name="firstname" size="15" /> *</td>
		</tr>
		<tr>
			<td><?php echo JText::_('Last Name') ; ?> :</td>
			<td><input type="text" id="lastname" name="lastname" size="15" /> *</td>
		</tr>
        
                
		<tr>
			<td><?php echo JText::_('EMAIL') ; ?> :</td>
			<td><input type="text" id="email" name="email" size="30"/> *</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
			<td></tr>
		
  </table>
<input type="hidden" name="option"     value="com_jquarks" />
	<input type="hidden" name="controller" value="who" />
	<input type="hidden" name="task"       value="store" />
	<input type="hidden" name="sessionId"  value="<?php echo $this->sessionId ; ?>"/>
	<?php echo JHTML::_( 'form.token' ); ?>
  <input type="reset" value="<?php echo JText::_('RESET') ;?>" />
  <input type="submit" value="<?php echo ($this->isShowResults)? JText::_('SEND_AND_VIEW_RESULTS') : JText::_('SEND'); ?>"/>
</form>











default.php  (results page)


<?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");
?>
<style type="text/css">
#errormsg p {
	color: #F00;
}
</style>


<div class="componentheading">
	<?php echo JText::_('Quiz 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 %---><br />
<div class="contentheading">
<p>
     <span class="session-title"><?php echo JText::_('QUIZ').': ' ;?></span>
    <?php echo $this->session->title; ?>
 </p>
 <p>
     <span class="session-title"><?php echo JText::_('SCORE').': ' ;?></span>
    <?php echo  round($percent, 2) . '%&nbsp;&nbsp;&nbsp;'; ?>
     <span class="note-small">
          <?php echo JText::_('INPUT_QUESTIONS_ARE_NOT_RECORDED_IN_THE_SCORE'); ?>
     </span>
 </p>
 <p>
     <span class="session-title"><?php echo JText::_('IS_UNANSWERED').': ' ; ?></span>
    <?php echo $this->session->unanswered; ?>
 </p>
</div>
 
 <div id="errormsg">
 <!-- Rick added Line to show 100 percent is required to pass test --> 
 
 </br>
  <p>
  
  
  <?php
if( $percent >=100 )
{ 
echo " Congratulations, you passed this course \n";
echo '<br>' ;
echo " Print this page and turn in to your supervisor";
} 

else 
{
    echo "A score of 100 is required to complete this course.
	Please click the link below to re-take the test !!.";
	echo '<br>' ;
	echo '</br>';
    echo '<a href="index.php?option=com_jquarks&view=quiz&id=1&Itemid=2">Re-take test</a>.'; 
}
 ?>



  <a href="certificate.php" title="Sexual Harassment Certificate of Completion" target="_blank">Print Certificate</a>  
</div>

<!-- Answers details -->
<br />



<div >

<?php

     //defining format for evaluated propositions
    $li      = '<li>';
    $eli     = '</li>';
    $ligreen = '<li class="green-li">';
    $corr    = '<span class="li-highlight-green">  ('  . JText::_('GOOD')    . ')</span>';
    $incorr  = '<span class="li-highlight-red">  ('    . JText::_('WRONG')   . ')</span>';
    $omi     = '<span class="li-highlight-orange">  (' . JText::_('OMITTED') . ')</span>';


     $idq = NULL; // contains the actual question id
     foreach ($this->results as $res) :

        // show question statement if this latter doesn't exist
        $idq_temp = $res->question_id;
        if ($idq_temp != $idq)
        {
            $idq = $idq_temp;
            if ($idq != NULL) {
                echo '</ul>';
            }
            echo '<br /><span class="session-title">' . $res->statement . '</span>';
            echo '<ul class="result-list">';
        }

        switch($res->type_id) :
                case 1: // input question
                    echo $li . $res->altanswer. $eli;
                    break;

                case 2: // option question
                    if ($res->answer_id != NULL) // exists in answers
                    {
                        if($res->correct) {
                            echo $ligreen . $res->answer . $corr . $eli; //correct
                        }
                        else {
                            echo $li . $res->answer . $incorr . $eli;  // incorrect
                        }

                    }
                    else {
                        if ($res->correct) {
                            echo $ligreen . $res->answer . $eli;
                        }
                        else {
                            echo $li . $res->answer . $eli;
                        }
                    }
                    break;

                 case 3: //checkbox question
                 case 4: // option as checkbox
                          if($res->correct) {
                              $debut = $ligreen . $res->answer;
                          }
                          else {
                              $debut = $li      . $res->answer;
                          }
                          if (is_null($res->status)) {
                              $fin = $eli;
                          }
                          else
                          {
                              switch($res->status)
                              {
                                  case -2: $fin = $eli;           break;
                                  case  0: $fin = $incorr . $eli; break;
                                  case  1: $fin = $corr   . $eli; break;
                                  case  2: $fin = $omi    . $eli; break;
                              }
                          }
                          echo $debut.$fin;
                
         endswitch;
    endforeach;
?>
</div>

Open in new window

0
TonyReba
Asked:
TonyReba
  • 15
  • 11
1 Solution
 
Eddie ShipmanAll-around developerCommented:
1. Create your certificate in Acrobat.
2. Create a form field in the PDf for the user's name, call it txtName
3. use the following code to populate the PDF:
<?php
/*
Note that this line: /F (http://www.mysite.com/CompletionForm.pdf)
determines the PDF File to be filled in. Change to point to the
PDF file on your site.

txtName variable is the user's name to populate.

*/
$txtName  = $_GET['txtName'];
header("Content-type: application/vnd.fdf");
echo <<<EOT
%FDF-1.2
1 0 obj
<<
/FDF
<< 
/Fields
[ 
<<
/T (txtName)
/V ({$txtName})
>> 
]
/F (http://www.mysite.com/CompletionForm.pdf)
>> 
>>
endobj
trailer
<<
/Root 1 0 R
>>
%%EOF
EOT;
?>

Open in new window

0
 
TonyRebaAuthor Commented:
This is not working...

Meabe change
vnd.fdf       -> something else since is an adobe pdf file???
0
 
Eddie ShipmanAll-around developerCommented:
no, it requires  it. What is not working mean? Are there errors?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
TonyRebaAuthor Commented:
No, but i cannot get to Get the Values from the Joomla Page sent to the pdf form ,  when comes to Joomla I dont know how do the values are sent..

This is the page that comes out at the end of taking the quiz , meabe you can understand how the values are sent??
<?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");
?>
<style type="text/css">
#errormsg p {
	color: #F00;
}
</style>


<div class="componentheading">
	<?php echo JText::_('Quiz 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 %---><br />
<div class="contentheading">
<p>
     <span class="session-title"><?php echo JText::_('QUIZ').': ' ;?></span>
    <?php echo $this->session->title; ?>
 </p>
 <p>
     <span class="session-title"><?php echo JText::_('SCORE').': ' ;?></span>
    <?php echo  round($percent, 2) . '%&nbsp;&nbsp;&nbsp;'; ?>
     <span class="note-small">
          <?php echo JText::_('INPUT_QUESTIONS_ARE_NOT_RECORDED_IN_THE_SCORE'); ?>
     </span>
 </p>
 <p>
     <span class="session-title"><?php echo JText::_('IS_UNANSWERED').': ' ; ?></span>
    <?php echo $this->session->unanswered; ?>
 </p>
</div>
 
 <div id="errormsg">
 <!-- Rick added Line to show 100 percent is required to pass test --> 
 
 </br>
  <p>
  
  
  <?php
if( $percent >=100 )
{ 
echo " Congratulations, you passed this course \n";
echo '<br>' ;
echo " Print this page and turn in to your supervisor";
} 

else 
{
    echo "A score of 100 is required to complete this course.
	Please click the link below to re-take the test !!.";
	echo '<br>' ;
	echo '</br>';
    echo '<a href="index.php?option=com_jquarks&view=quiz&id=1&Itemid=2">Re-take test</a>.'; 
}
 ?>



  <a href="http://appdevelsvr:8080/shquiz/components/com_jquarks/views/_session/tmpl/certificate.php" title="Sexual Harassment Certificate of Completion" target="_blank">Print Certificate</a>  
</div>

<!-- Answers details -->
<br />



<div >

<?php

     //defining format for evaluated propositions
    $li      = '<li>';
    $eli     = '</li>';
    $ligreen = '<li class="green-li">';
    $corr    = '<span class="li-highlight-green">  ('  . JText::_('GOOD')    . ')</span>';
    $incorr  = '<span class="li-highlight-red">  ('    . JText::_('WRONG')   . ')</span>';
    $omi     = '<span class="li-highlight-orange">  (' . JText::_('OMITTED') . ')</span>';


     $idq = NULL; // contains the actual question id
     foreach ($this->results as $res) :

        // show question statement if this latter doesn't exist
        $idq_temp = $res->question_id;
        if ($idq_temp != $idq)
        {
            $idq = $idq_temp;
            if ($idq != NULL) {
                echo '</ul>';
            }
            echo '<br /><span class="session-title">' . $res->statement . '</span>';
            echo '<ul class="result-list">';
        }

        switch($res->type_id) :
                case 1: // input question
                    echo $li . $res->altanswer. $eli;
                    break;

                case 2: // option question
                    if ($res->answer_id != NULL) // exists in answers
                    {
                        if($res->correct) {
                            echo $ligreen . $res->answer . $corr . $eli; //correct
                        }
                        else {
                            echo $li . $res->answer . $incorr . $eli;  // incorrect
                        }

                    }
                    else {
                        if ($res->correct) {
                            echo $ligreen . $res->answer . $eli;
                        }
                        else {
                            echo $li . $res->answer . $eli;
                        }
                    }
                    break;

                 case 3: //checkbox question
                 case 4: // option as checkbox
                          if($res->correct) {
                              $debut = $ligreen . $res->answer;
                          }
                          else {
                              $debut = $li      . $res->answer;
                          }
                          if (is_null($res->status)) {
                              $fin = $eli;
                          }
                          else
                          {
                              switch($res->status)
                              {
                                  case -2: $fin = $eli;           break;
                                  case  0: $fin = $incorr . $eli; break;
                                  case  1: $fin = $corr   . $eli; break;
                                  case  2: $fin = $omi    . $eli; break;
                              }
                          }
                          echo $debut.$fin;
                
         endswitch;
    endforeach;
?>
</div>

Open in new window

0
 
Eddie ShipmanAll-around developerCommented:
Instead of having a link:
<a href="http://appdevelsvr:8080/shquiz/components/com_jquarks/views/_session/tmpl/certificate.php" title="Sexual Harassment Certificate of Completion" target="_blank">Print Certificate</a> 

Open in new window


create a form with a hidden field to pass the user's name to the certificate.php script when a submit button is pressed.
I don't know how or where you get the user's name unless it is in the $this->session variable.
0
 
Eddie ShipmanAll-around developerCommented:
Looks like it may be because the score is being set in the session variable. You access it here:
$this->session->score

Open in new window

0
 
TonyRebaAuthor Commented:
I am complety lost on php  , can you please modify this code at least just one field to send to another page??



default.php
<?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");
?>
<style type="text/css">
#errormsg p {
	color: #F00;
}
</style>


<div class="componentheading">
	<?php echo JText::_('Quiz 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 %---><br />
<div class="contentheading">
<p>
     <span class="session-title"><?php echo JText::_('QUIZ').': ' ;?></span>
    <?php echo $this->session->title; ?>
 </p>
 <p>
     <span class="session-title"><?php echo JText::_('SCORE').': ' ;?></span>
    <?php echo  round($percent, 2) . '%&nbsp;&nbsp;&nbsp;'; ?>
     <span class="note-small">
          <?php echo JText::_('INPUT_QUESTIONS_ARE_NOT_RECORDED_IN_THE_SCORE'); ?>
     </span>
 </p>
 <p>
     <span class="session-title"><?php echo JText::_('IS_UNANSWERED').': ' ; ?></span>
    <?php echo $this->session->unanswered; ?>
 </p>
</div>
 
 <div id="errormsg">
 <!-- Rick added Line to show 100 percent is required to pass test --> 
 
 </br>
  <p>
  
  
  <?php
if( $percent >=100 )
{ 
echo " Congratulations, you passed this course \n";
echo '<br>' ;
echo " Print this page and turn in to your supervisor";
} 

else 
{
    echo "A score of 100 is required to complete this course.
	Please click the link below to re-take the test !!.";
	echo '<br>' ;
	echo '</br>';
    echo '<a href="index.php?option=com_jquarks&view=quiz&id=1&Itemid=2">Re-take test</a>.'; 
}
 ?>

<form method="post" onsubmit="return checkForm();">

  <a href="http://appdevelsvr:8080/shquiz/components/com_jquarks/views/_session/tmpl/certificate.php" title="Sexual Harassment Certificate of Completion" target="_blank">Print Certificate</a>
</form>
<!-- Answers details -->
<br />

<div >
</div>
<?php

     //defining format for evaluated propositions
    $li      = '<li>';
    $eli     = '</li>';
    $ligreen = '<li class="green-li">';
    $corr    = '<span class="li-highlight-green">  ('  . JText::_('GOOD')    . ')</span>';
    $incorr  = '<span class="li-highlight-red">  ('    . JText::_('WRONG')   . ')</span>';
    $omi     = '<span class="li-highlight-orange">  (' . JText::_('OMITTED') . ')</span>';


     $idq = NULL; // contains the actual question id
     foreach ($this->results as $res) :

        // show question statement if this latter doesn't exist
        $idq_temp = $res->question_id;
        if ($idq_temp != $idq)
        {
            $idq = $idq_temp;
            if ($idq != NULL) {
                echo '</ul>';
            }
            echo '<br /><span class="session-title">' . $res->statement . '</span>';
            echo '<ul class="result-list">';
        }

        switch($res->type_id) :
                case 1: // input question
                    echo $li . $res->altanswer. $eli;
                    break;

                case 2: // option question
                    if ($res->answer_id != NULL) // exists in answers
                    {
                        if($res->correct) {
                            echo $ligreen . $res->answer . $corr . $eli; //correct
                        }
                        else {
                            echo $li . $res->answer . $incorr . $eli;  // incorrect
                        }

                    }
                    else {
                        if ($res->correct) {
                            echo $ligreen . $res->answer . $eli;
                        }
                        else {
                            echo $li . $res->answer . $eli;
                        }
                    }
                    break;

                 case 3: //checkbox question
                 case 4: // option as checkbox
                          if($res->correct) {
                              $debut = $ligreen . $res->answer;
                          }
                          else {
                              $debut = $li      . $res->answer;
                          }
                          if (is_null($res->status)) {
                              $fin = $eli;
                          }
                          else
                          {
                              switch($res->status)
                              {
                                  case -2: $fin = $eli;           break;
                                  case  0: $fin = $incorr . $eli; break;
                                  case  1: $fin = $corr   . $eli; break;
                                  case  2: $fin = $omi    . $eli; break;
                              }
                          }
                          echo $debut.$fin;
                
         endswitch;
    endforeach;
?>
</div>

Open in new window

0
 
TonyRebaAuthor Commented:
This is the form where user enters their info and goes into the Database,



<?php
defined( '_JEXEC' ) or die( 'Restricted access' );
JHTML::_('behavior.mootools');
?>
<script type="text/javascript" language="javascript">

	function validEmail(email) 
	{
		pattern = new RegExp("^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$") ;

		return pattern.test(email) ;
	} 

	function checkForm() 
	{
		lastname = document.getElementById('lastname').value ;
		firstname = document.getElementById('firstname').value ;
		email = document.getElementById('email').value ;
		department = document.getElementById('department').value;
		employeeid = document.getElementById('EmployeeID').value;
		
		
		if (lastname != '' && firstname != '' && department != '' && employeeid != '' && validEmail(email))
		
		
		 {
			return true ;
		} 
		else 
		{
			alert("<?php echo JText::_('ERROR_FILL_REQUIRED_FIELDS_PRVOIDE_VALIDE_EMAIL') ; ?>") ;
			return false ;
		}
	}

</script>

<p style="font-style: normal; font-size: 16px;font-weight: bold; color: #333;"><?php echo JText::_('Thank you for taking this quiz') ; ?></p>
</br>
<form method="post" onsubmit="return checkForm();">
  <table>
		<tr>
			<td><?php echo JText::_('First Name') ; ?> :</td>
			<td><input type="text" id="firstname" name="firstname" size="15" /> *</td>
		</tr>
		<tr>
			<td><?php echo JText::_('Last Name') ; ?> :</td>
			<td><input type="text" id="lastname" name="lastname" size="15" /> *</td>
		</tr>
        
                
		<tr>
		  <td><?php echo JText::_('Department') ; ?></td>
		  <td><input type="text" id="department" name="department" size="15" />	        *</td>
    </tr>
		<tr>
		  <td><?php echo JText::_('Employee ID') ; ?></td>
		  <td><input type="text" id="EmployeeID" name="EmployeeID" size="15" />
	      *</td>
    </tr>
		<tr>
			<td><?php echo JText::_('EMAIL') ; ?> :</td>
			<td><input type="text" id="email" name="email" size="30"/> *</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
			<td></tr>
		
  </table>
<input type="hidden" name="option"     value="com_jquarks" />
	<input type="hidden" name="controller" value="who" />
	<input type="hidden" name="task"       value="store" />
	<input type="hidden" name="sessionId"  value="<?php echo $this->sessionId ; ?>"/>
	<?php echo JHTML::_( 'form.token' ); ?>
  <input type="reset" value="<?php echo JText::_('RESET') ;?>" />
  <input type="submit" value="<?php echo ($this->isShowResults)? JText::_('SEND_AND_VIEW_RESULTS') : JText::_('SEND'); ?>"/>
</form>

Open in new window

0
 
Eddie ShipmanAll-around developerCommented:
PHP really has nothing to do with the form.
Give this a try:
<form method="get" action="http://appdevelsvr:8080/shquiz/components/com_jquarks/views/_session/tmpl/certificate.php">
  <input type="hidden" name="txtName" value="{need to populate with your username here}">
  <input type="submit" value="Print Certificate" />
</form>

Open in new window


As I said earlier, I don't know how or where the user's name is being stored, it may be in the session object or it may not. Without seeing more of your code,
I can't tell you where to get the name and place it in the area I noted above in the form code.
0
 
Eddie ShipmanAll-around developerCommented:
Give this a try to populate with the username:
<?php
 $user =& JFactory::getUser();
?>
 <form method="get" action="http://appdevelsvr:8080/shquiz/components/com_jquarks/views/_session/tmpl/certificate.php">
  <input type="hidden" name="txtName" value="<?php echo $user->username;?>">
  <input type="submit" value="Print Certificate" />
</form>

Open in new window

0
 
TonyRebaAuthor Commented:
Eddie , please take a look of this structure of the component I am using in joomla,  I am pretty sure there is a 'simple' way to have the fields I need posted into a custom php page , but I cannot find how.....

attached is the whole component folder

and the custom page I am trying to make is under



views->_session-> tmpl > certificate.php


THANKS FOR ALL YOUR HELP SO FAR com-jquarksfolder.zip
0
 
Eddie ShipmanAll-around developerCommented:
I downloaded and looked at the jQuarks module. I showed you above how to get the user's name and send it to the cretificate.php
script that is supposed to insert their name into the PDF and show it.

What else is wrong?

What other "custom php page" are you talking about? What fields do you want sent?
0
 
Eddie ShipmanAll-around developerCommented:
I would think that txtCompletionDate would be today's date, correct?
The txtCourseName should come from $this->session->title

So modify your form like this:
<?php
 $user =& JFactory::getUser();
?>
 <form method="get" action="http://appdevelsvr:8080/shquiz/components/com_jquarks/views/_session/tmpl/certificate.php">
  <input type="hidden" name="txtName" value="<?php echo $user->username;?>">
  <input type="hidden" name="txtCourseName" value="<?php echo $this->session->title?>">
  <input type="hidden" name="txtCompletionDate" value="<?php echo date('F j, Y')?>">
  <input type="submit" value="Print Certificate" />
</form>
0
 
Eddie ShipmanAll-around developerCommented:
Also, modify this:
$txtName  = $_GET['givenname'];

Open in new window

to this:
$txtName  = $_GET['txtName'];

Open in new window

0
 
TonyRebaAuthor Commented:
Nothing comes out when I post to the certificate.php
not even using session , or posting the form , I dont know what can be wrong.....

I need to pass

firstname, lastname, quizname,  using the generated session id or quiz id...
0
 
TonyRebaAuthor Commented:
the code below is on certificate.php?
So modify your form like this:
<?php
 $user =& JFactory::getUser();
?>
 <form method="get" action="http://appdevelsvr:8080/shquiz/components/com_jquarks/views/_session/tmpl/certificate.php">
  <input type="hidden" name="txtName" value="<?php echo $user->username;?>">
  <input type="hidden" name="txtCourseName" value="<?php echo $this->session->title?>">
  <input type="hidden" name="txtCompletionDate" value="<?php echo date('F j, Y')?>">
  <input type="submit" value="Print Certificate" />
</form>

Open in new window

0
 
Eddie ShipmanAll-around developerCommented:
This is how I'd modify the certificate.php file, too:
<?php
/*
Note that this line: /F (http://www.mysite.com/CompletionForm.pdf)
determines the PDF File to be filled in. Change to point to the
PDF file on your site. txtName variable is the user's name to populate.
*/
$txtName       = $_GET['txtName'];
$txtCourseName = $_GET['txtCourseName'];
$txtCourseName = $_GET['txtCompletionDate'];

header("Content-type: application/vnd.fdf");
echo <<<EOT
%FDF-1.2
1 0 obj
<<
/FDF
<< 
/Fields
[ 
<<
/T (txtName)
/V ({$txtName})
>> 
<<
/T (txtCourseName)
/V ({$txtCourseName})
>> 
<<
/T (txtCompletionDate)
/V ({$txtCompletionDate})
>> 
]
/F (http://appdevelsvr:8080/shquiz/media/certificate/CourseCertificate.pdf)

>> 
>>
endobj
trailer
<<
/Root 1 0 R
>>
%%EOF
EOT;
?>

Open in new window


Have you already created the PDF with the form fields? Mind posting a copy?
0
 
Eddie ShipmanAll-around developerCommented:
*quote* the code below is on certificate.php? *quote*

No, it goes in the code you originally posted where you had the anchor to print the certificate.
0
 
TonyRebaAuthor Commented:
Sure please find it attached
CourseCertificate.pdf
0
 
Eddie ShipmanAll-around developerCommented:
Without downloading Joomla! and installing the JQuarks module, I don't know where to get the other values that you require.
0
 
TonyRebaAuthor Commented:
Does the pdf looks ok?
0
 
Eddie ShipmanAll-around developerCommented:
Yes, and on my localhost it populates it correctly, You need to make the fields as wide as the page, though because my name overflowed the form field and it was cut off.
I used the same code as in certificate.php I posted above in ID:35701766

I passed the name, course title and date from an HTML form just like I showed in ID:35701745 (although I passed static values)
0
 
TonyRebaAuthor Commented:
In the attached jquarks folder you can find _form , which has some of the information I need to pass to the pdf ....


<form method="post" onsubmit="return checkForm();">
  <table>
		<tr>
			<td><?php echo JText::_('First Name') ; ?> :</td>
			<td><input type="text" id="firstname" name="firstname" size="15" /> *</td>
		</tr>
		<tr>
			<td><?php echo JText::_('Last Name') ; ?> :</td>
			<td><input type="text" id="lastname" name="lastname" size="15" /> *</td>
		</tr>
                        
		<tr>
		  <td><?php echo JText::_('Department') ; ?></td>
		  <td>  
<select name="department" id="department" class="inputbox" size="0" > 
	<option value="">Select</option> 
	<option value="7520-ACCOUNTING">7520-ACCOUNTING</option> 

	<option value="Not Listed">Not Listed </option> 
</select> 	        *</td>
    </tr>
		<tr>
		  <td><?php echo JText::_('Employee ID') ; ?></td>
		  <td><input type="text" id="EmployeeID" name="EmployeeID" size="15" />
	      *</td>
    </tr>
		
		<tr>
			<td>&nbsp;</td>
			<td></tr>
		
  </table>
<input type="hidden" name="option"     value="com_jquarks" />
	<input type="hidden" name="controller" value="who" />
	<input type="hidden" name="task"       value="store" />
	<input type="hidden" name="sessionId"  value="<?php echo $this->sessionId ; ?>"/>
	<?php echo JHTML::_( 'form.token' ); ?>
  <input type="reset" value="<?php echo JText::_('RESET') ;?>" />
  <input type="submit" value="<?php echo ($this->isShowResults)? JText::_('SEND_AND_VIEW_RESULTS') : JText::_('SEND'); ?>"/>
</form>

Open in new window

0
 
Eddie ShipmanAll-around developerCommented:
That still does not tell me where to get the information. Besides, have you tried making the changes that I showed EXACTLY like I said?

0
 
Eddie ShipmanAll-around developerCommented:
So, did you get it working or not?
0
 
TonyRebaAuthor Commented:
Yes
 Thanks.  I had to declare and test the variables first then added the PDF writting code
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 15
  • 11
Tackle projects and never again get stuck behind a technical roadblock.
Join Now