User Tools

Site Tools


portals:plan-page

Plan.php

This is the page that subscribers see when there is no default billing plan configured.

   <?php
      require_once($_SERVER['DOCUMENT_ROOT']."/hsm/include/initialize.php");     
      require($_SERVER['DOCUMENT_ROOT']."/hsm/plan_execute.php");                
   ?>

Initialize.php will initialize all the standard functions and variables. Plan_execute.php will perform the plan buying action and will login the subscriber automatically.

   <form name="selectPlan" action="<?=$form_action?>" method="post" onSubmit="this.submitbutton.disabled=true;"> 
      <input type="hidden" name="username" value="<?=$_SESSION['PORTAL']['user']?>">      
      <input type="hidden" name="password" value="<?=$_SESSION['PORTAL']['pass']?>"> 
      <input type="hidden" name="login" value="true">                                    
      <select  name="plan" id="billingPlans">
         <?php
            $plan=hsm_fetch_object($plans); 
            echo '<option value="'.$plan->id.'">'.$plan->name.': '.$plan->price. ' EUR</option>';  
            while($plan = hsm_fetch_object($plans))
            {		
               echo '<option value="'.$plan->id.'" label="'.$plan->name.'" '.($plan->id==$currentplan->id?'selected="selected"':'').'>'.$plan->name.': '.$plan->price.' EUR</option>';       		
             }
          ?>     
       </select>                    
       <input id="buy_button" name="submitbutton" type="submit" value="Buy" <?=(isset($_SESSION['PORTAL']['preview'])?"disabled":"")?>>
   </form>

The first and the third hidden field are required the second (<input type=“hidden” name=“password” value=“<?=$_SESSION['PORTAL']['pass']?>”> ) is optional. The billing plans are shown in a dropdownlist in this example. You can also use a radio button to let the subscriber select the billing plan that he want to use. It's important that the name of the select list is plan and that the value of the <option> item is the id from the billing plan.

portals/plan-page.txt · Last modified: 2015/03/18 15:29 by maarten