Jump to content

Need Helping passing an associative array to 2 pages


DaveYadallee

Recommended Posts

 

Running a huge php/mysql pages that needs to pass data three times. 

Here is the initial page with the relevant snippets 

 

<!DOCTYPE html > 
<html lang="en"> 
<head> 

<script > 

<?php 
        $connect = mysqli_connect("localhost", "customer", "pw","customer") or die ("Cannot connect"); 
mysqli_select_db($connect,"customer") or die("Cannot select database"); 


/////////////////////////Filtering Generes//////////////////////////////////////// 

$jresult =  mysqli_query ($connect,"SELECT sessions.sessionid  FROM sessions WHERE sessions.sessionid > 712 ORDER BY sessions.sessionid   ") or die('cannot show tables'); 
$getcount = mysqli_query ($connect,"SELECT COUNT(*) FROM sessions");         
?> 

function load() 
{ 
window.status = " " 
} 

function count( 
<?php 
while ( 
//$row = mysqli_fetch_row($jresult,MYSQL_ASSOC) ; 

$row = mysqli_fetch_assoc ($jresult) 
){ 
            if ( 400 > $row['sessionid'] ){ 
                echo "quans".$row['sessionid'].","; 
                } else  { 
                echo "quans".$row['sessionid'];         
                } 
        } 
?> 
) 
{ 

//Getting Values 
<?php                                 
        $connect = mysqli_connect("localhost", "customer", "pw") or die ("Cannot connect"); 
mysqli_select_db($connect,"customer") or die("Cannot select database"); 


/////////////////////////Filtering Generes//////////////////////////////////////// 

$jresult1 =  mysqli_query ($connect,"SELECT sessions.sessionid FROM sessions WHERE sessions.sessionid >712   ORDER BY sessions.sessionid   ") or die('cannot show tables'); 

         
?> 

<?php 
while($row = mysqli_fetch_assoc($jresult1)){ 

                echo "var quan".$row['sessionid']." = parseInt(document.getElementById('quans".$row['sessionid']. "').value);\n"; 

        } 
?> 



//Stored Values 

<?php                                 
        $connect = mysqli_connect("localhost", "customer", "pw") or die ("Cannot connect"); 
mysqli_select_db($connect,"customer") or die("Cannot select database"); 


/////////////////////////Filtering Generes//////////////////////////////////////// 

$jresult =  mysqli_query ($connect,"SELECT sessions.sessionid FROM sessions WHERE  sessions.sessionid > 712 ORDER BY sessions.sessionid ") or die('cannot show tables'); 

?> 

if 
  ( 0 
  <?php 
while($row = mysqli_fetch_assoc($jresult)){ 
                echo "|| (quan".$row['sessionid']." > 0 )  \n"; 
        } 
?> 
) 

{ 
         
<?php                                 
        $connect = mysqli_connect("localhost", "customer", "pw") or die ("Cannot connect"); 

mysqli_select_db($connect,"customer") or die("Cannot select database"); 


/////////////////////////Filtering Generes//////////////////////////////////////// 

$jresult =  mysqli_query ($connect,"SELECT sessions.sessionid FROM sessions WHERE sessions.sessionid > 712  ORDER BY sessions.sessionid  ") or die('cannot show tables'); 
         
?> 

<?php 
while($row = mysqli_fetch_assoc($jresult)){ 
                echo "var price".$row['sessionid']." = 63.00 * quan".$row['sessionid'].";\n"; 
        } 
?> 

} 
else 
{ 
         
<?php                                 
        $connect = mysqli_connect("localhost", "customer", "pw") or die ("Cannot connect"); 
mysqli_select_db($connect,"customer") or die("Cannot select database"); 


/////////////////////////Filtering Generes//////////////////////////////////////// 

$jresult =  mysqli_query ($connect,"SELECT sessions.sessionid FROM sessions WHERE  sessions.sessionid > 712 ORDER BY sessions.sessionid ") or die('cannot show tables'); 
         
?> 

<?php 
while($row = mysqli_fetch_assoc($jresult)){ 
                echo "var price".$row['sessionid']." = 0;\n"; 
        } 
?> 

} 




// kortti 

<?php                                 

        $connect = mysqli_connect("localhost", "customer", "pw") or die ("Cannot connect"); 
mysqli_select_db($connect,"customer") or die("Cannot select database"); 


/////////////////////////Filtering Generes//////////////////////////////////////// 

$jresult =  mysqli_query ($connect,"SELECT sessions.sessionid FROM sessions WHERE sessions.sessionid > 712 ORDER BY sessions.sessionid  ") or die('cannot show tables'); 
         
?> 

<?php 
while($row = mysqli_fetch_assoc($jresult)){ 
                echo "if (calc.price".$row['sessionid'].".checked){\n 
                     var wprice".$row['sessionid']." = document.calc.price".$row['sessionid'].".value = price".$row['sessionid'].";\n 
                } else { \n 
                var wprice".$row['sessionid']." = document.calc.price".$row['sessionid'].".value = 0;\n}\n 
                "; 
        } 
?> 




//document.getElementById("total").innerHTML = (wprice315 + wprice316  ) + ".00"; 

document.calc.charge_total.value = ( 0 

<?php                                 
        $connect = mysqli_connect("localhost", "customer", "pw") or die ("Cannot connect"); 

mysqli_select_db($connect,"customer") or die("Cannot select database"); 





/////////////////////////Filtering Generes//////////////////////////////////////// 



$jresult =  mysqli_query ($connect,"SELECT sessions.sessionid FROM sessions WHERE sessions.sessionid > 712  ORDER BY sessions.sessionid  ") or die('cannot show tables'); 

         

?> 



<?php 

while($row = mysqli_fetch_assoc($jresult)){ 

                echo " + wprice".$row['sessionid']." "; 

        } 

?> 



) + ".00"; 

return charge_total; 

} 
</script> 

<!-- valid --> 

<!-- LOAD THE NECESSARY JQUERY LIBRARY--> 

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript" charset="utf-8"></script> 

<script src="js/jquery-latest.js"></script> 

<script type="text/javascript" src="js/jquery.validate.js"></script> 

<!--  USE THE READY FUNCTION --> 

<script type="text/javascript"> 

  $(document).ready(function(){ 

    $("#blogm").validate({ 

                 

                 

                rules:{ 

                        bill_first_name:{ 

                                required:true, 

                                 

                                         

                        }, 

                        bill_last_name:{ 

                                required:true, 

                                 

                                         

                        }, 

                         

                        bill_address_one:{ 

                                required:false, 

                                 

                                         

                        }, 

                         

                        bill_company_name:{ 

                                required:false, 

                                 

                                         

                        }, 

                         

                        bill_city:{ 

                                required:false, 

                                 

                                         

                        }, 

                         

                        bill_state_or_province:{ 

                                required:false, 

                                 

                                         

                        }, 

                         

                        bill_country:{ 

                                required:false, 

                                 

                                         

                        }, 

                         

                        bill_postal_code:{ 

                                required:false, 

                                 

                                         

                        }, 

                         

                        bill_phone:{ 

                                required:true, 

                                 

                                         

                        }, 

                         

                         

                        email:{ 

                                required:true, 

                                 

                                         

                        }, 

                         
                        CaptchaInput:{ 
                                required:true, 
                                 
                                         
                        }, 
                         
                         

                        note:{ 

                                required:false, 

                                 

                                         

                        } 

                 

                         

                         

                         

                },//////rules ends/////// 

                 

                 

                 

                messages:{ 

                        bill_first_name:{ 

                                required: "*",         

                                 

                        }, 

                        bill_last_name:{ 

                                required: "*",         

                 

                                 

                        }, 

                        bill_address_one:{ 

                                required: "*",         

                 

                                 

                        }, 

                        bill_company_name:{ 

                                required: "*",         

                 

                                 

                        }, 

                         

                        bill_city:{ 

                                required: "*", 

                                 

                                         

                        }, 

                         

                        bill_state_or_province:{ 

                                required: "*", 

                                 

                                         

                        }, 

                         

                        bill_country:{ 

                                required: "*", 

                                 

                                         

                        }, 

                         

                        bill_postal_code:{ 

                                required: "*", 

                                 

                                         

                        }, 

                         

                        bill_phone:{ 

                                required: "*", 

                                 

                                         

                        }, 

                 

                         

                        email:{ 

                                required: "*", 

                                 

                                         

                        }, 

                         
                        CaptchaInput:{ 
                                required:true, 
                                 
                                         
                        }, 
                         
                         

                        note:{ 

                                required: "*", 

                                 

                                         

                        } 

                        /*message:{ 

                                required: "*",         

                                 

                        }*/ 

                         

         

                         

                }//////message ends/////// 

                 

         

         

        }); 







  }); 

</script> 





    <script src="js/jquery.uniform.js" type="text/javascript" charset="utf-8"></script> 

    <script type="text/javascript" > 

      $(function(){ 

        $("input, textarea, select, button, radio").uniform(); 

                $(":file").uniform({fileBtnText: 'Phil is Cool;'}); 

      }); 

    </script> 

    <link rel="stylesheet" href="css/uniform.default.css" type="text/css" media="screen"> 

    <link rel="stylesheet" href="css/uniform.agent.css" type="text/css" media="screen"> 

<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no"> 



</head> 

<body> 

<!--wrapper begins--> 
<div id="wrapper"> 

        <!--header begins--> 
         
        <?php 

        include("includes/header.php"); 

        ?> 
         
    <!--header ends--> 






                <!--nav begins--> 

                    <div id="nav"> 

                         

                <!--holder begins--> 

                <div id="holder"><ul> 

                        <li><a href="index.php">Home</a></li> 

                    <li><a href="courses.php#nav2" >Courses</a></li> 

                    <li><a href="" >Archive</a></li> 

                    <li><a href="https://admin.acrobat.com/common/help/en/support/meeting_test.htm" >Connection</a></li> 

                    <li><a href="" >Biographies</a></li> 

                    <li><a href="contactus.php" >Contact Us</a></li> 

                    <li><a href="form.php#content" >Register</a></li> 

</ul> 

                </div><!--holder ends--> 

        

                        </div><!--nav ends--> 

            

            

         <!--mainbanner begins--> 

         <div id="mainbanner"> 

            

          

            

        <!--banner begins--> 

            <div id="banner"> 

            <h2 class="order"> 

OnLine Order Form 

</h2> 

            <p></p> 

            

             <div id="canada"> 

              <img src="images/canada.png" alt="Canada" width="336" height="298" /></div> 

            

            

                   </div> <!--banner ends--> 

              

              

  </div><!--mainbanner ends--> 

          

          

<!--content begins--> 

                    <div id="content"> 

         <div id="left"> 

        



<?php                                 

        $connect = mysqli_connect("localhost", "customer", "pw") or die ("Cannot connect"); 

mysqli_select_db($connect,"customer") or die("Cannot select database"); 





/////////////////////////Filtering Generes//////////////////////////////////////// 



$result =  mysqli_query ($connect,"SELECT sessions.sessionid, courses.abbr, courses.seminar, sessions.date, sessions.time FROM sessions,courses WHERE sessions.courseid=courses.id AND sessions.sessionid > 712  ORDER BY sessions.sessionid ") or die('cannot show tables'); 

         
?>         
         
<form action="https://secure.nl2k.ab.ca/customer/step2.php" id="blogm" method="post" name="calc" onSubmit="return ( checkform(this) && count());" onKeyUp="highlight(event)" onClick="highlight(event)"> 
  <input name="rvar_cc_visitor" value="1" type="hidden" /> 
<input name="ps_store_id" value="F9X7J04390" type="hidden"> 
<input name="hpp_key" value="hpQGBHH9EAGZ" type="hidden"> 
<input name="hpp_preload" value="" type="hidden"> 
<input name="rvar_subject" value="PD Solutions Order Form" type="hidden"> 
<input name="rvar_recipients" value="tgarner@customer.ca" type="hidden"> 
<input name="rvar_required" value="bill_first_name,bill_last_name,email,bill_phone,CaptchaInput" type="hidden"> 
<input name="rvar_title" value="PD Solutions Order" type="hidden"> 
<input name="rvar_bad_url" value="https://secure.nl2k.ab.ca/customer/" type="hidden"> 
<input name="rvar_env_report" value="REMOTE_HOST,REMOTE_ADDR" type="hidden"> 
<input name="rvar_redirect" value="https://secure.nl2k.ab.ca/customer/" type="hidden"> 

<h2 class="courses1">Orders</h2> 
<div class="divider3"></div> 
<ul> 
<li class="order0"><b>Online Orders</b> - Complete and submit this form</li> 
<li class="order0"><b>Phone Orders</b> - Call <b>1-877-977-6774</b></li> 
<li class="order0"><b>Fax Orders</b> - Print the Order Form and FAX to 1-780-351-2029<br></li>         
<li class="order0"><b>Mail Orders</b> - Print the Order Form and mail to: P D Solutions 15422-104A Street Grande Prairie, AB T8X 0J5</li>         

</ul> 

<h2 class="proceed">This page uses javascript. Please turn javascript on the browser. </h2> 



<h2 class="courses1">Note</h2> 
<div class="divider3"></div> 

<ol id="order"> 
<li class="order">All prices in CANADIAN Funds.</li> 
<li class="order">Canadian Residents 5% GST applies and will be added to your order</li> 

<li class="order">Each course cost $60.00 + $3.00 GST<br /><a href="formnogst.php">Click 

here if you are exempt from GST (federal, provincial and municipal 

government)</a></li>         







<li class="order"></li> 

</ol><ul> 

<li class="order2"> -Select the course you wish to take </li> 

<li class="order2"> -place the number one (1) in the quantity box </li> 

<li class="order2">-then click the "Calculate" button at the bottom 

of the page to give you a total. </li> 

<li class="order2"> -if you have made an error click on the reset 

button at the bottom of the page</li> 

</ul> 





<h2 class="courses1">Courses</h2> 

<div class="divider3"></div> 

<table  align="center" border="0" cellpadding="0" cellspacing="10" width="677"> 

<tbody class="style3"> 

<tr> 

<td align="center" width="44"><span class="top">Course ID</span></td> 

<td align="center" width="41"><span class="top">Select Course</span></td> 

<td align="center" width="144"><span class="top">Description</span></td> 

<td align="center" width="144"><span class="top">Select Quantity</span></td> 

<td align="center" width="175"><span class="top">Course Date</span></td> 



</tr> 

 //here is the section giving me an issue // 
<?php         
session_start(); 
$_SESSION['sessionid'] = $sessionid1; 
if(mysqli_num_rows($result)){ 
 $results = array(); $i = 0; 
 while($row = mysqli_fetch_assoc($result)){ 

$i++;         
         
        $sessionid1=$row['sessionid']; 
        $abbr1=$row['abbr']; 
        $seminar1=$row['seminar']; 
        $date1=$row['date']; 
        $time1=$row['time']; 
         
        echo '<tr>'; 

echo " <td class=\"style3\" align=\"center\"> 
<input name=\"id" .  $row['sessionid'] .  "\" id=\"id". $row['sessionid'].  "\" value=\"" .$row['abbr'].  "-" .$row['sessionid'].  "\" size=\"10\"></td> 
<td align=\"center\"><input name=\"price".  $row['sessionid'].  "\" id=\"price".  $row['sessionid'].  "\" value=\"63.00\" size=\"7\" type=\"checkbox\" ></td> 
 <td class=\"style3\" align=\"center\"><input class=\"style3\" name=\"description".  $row['sessionid']. "\" id=\"description".  $row['sessionid'].  "\" value=\"".  $row['seminar'].  "\" type=\"text\"></td> 
 <td class=\"style3\" align=\"center\"><input class=\"style3\" name=\"quantity".  $row['sessionid'].  "\" value=\"0\" size=\"4\" type=\"text\" id=\"quans".  $row['sessionid'].  "\"></td> 
 <td align=\"center\"><div align=\"center\"><span class=\"style3\">".  $row['date'].  "&nbsp;".  $row['time'].  "</span></div>  </td>"; 

        echo "</tr>"; 

 } 
$results[]=$row; 
} 

echo $i; 
var_export($results); 
                                        ?> 
</table> 


<br> 
<p class="please">Please 
note: Checkmark Select 
Course and also the Corresponding Select Quantity is entered as 1, or 
as many as required. 
</p> 
<br> 


<ul class="list1"> 

<li class="list1"> 
     <label class="calculate">Price</label> 
     <input type="text" name="charge_total" id="box1"/> 
     <!--<em>*</em>--> 
     </li> 
     </ul> 
      

      



                         <ul class="last1"> 

            <input onClick="count()" value="Calculate" id="submit1" type="button"> 

                        <input value="Reset" id="reset1" type="reset"> </center> 

            </ul> 







// The below is passing fine! 



<ul class="list"> 

        <h2>Student Personal Information</h2> 

    <div class="divider4"></div> 

         

     <li class="list"> 

     <label>First Name:</label> 

     <input type="text" name="bill_first_name" id="box" /> 

     <em>*(Required)</em> 

     </li> 



    

        <li class="list"> 

    <label>Last Name:</label> 

    <input type="text" name="bill_last_name" id="box2"  /> 

       <em>*(Required)</em> 

    </li> 



            

    <li class="list"> 

    <label>Address</label> 

    <input type="text" name="bill_address_one" id="box3"  /> 

    <!--<em>*</em>--> 

    </li> 

    

         

    <li class="list"> 

    <label>Company</label> 

    <input type="text" name="bill_company_name" id="box4" /> 

    <!--<em>*</em>--> 

    </li> 

    

    <li class="list"> 

    <label>City</label> 

    <input type="text" name="bill_city" id="box5" /> 

    <!--<em>*</em>--> 

    </li> 

    

        <li class="list"> 

    <label>Province:</label> 

    <input type="text" name="bill_state_or_province" id="box6" /> 

    <!--<em>*</em>--> 

    </li> 

    

    <!--li class="list"> 

    <label>Country:</label> 

    <input type="text" name="bill_country" id="box7" /> 

    <em>*</em> 

    </li--> 



        <li class="list"> 

    <label>Postal Code:</label> 

    <input type="text" name="bill_postal_code" id="box8" /> 

    <!--<em>*</em>--> 

    </li> 

    

    <li class="list"> 

    <label>Phone:</label> 

    <input type="text" name="bill_phone" id="box9" /> 

       <em>*(Required)</em> 

    </li> 

    

    <!--li class="list"> 

    <label>Fax:</label> 

    <input type="text" name="bill_fax"id="box10" /> 

    <em>*</em> 

    </li--> 

    

    <li class="list"> 

    <label>Email:</label> 

    <input type="text" name="email" id="box11" /> 

       <em>*(Required)</em> 

    </li> 

    

    <!--li class="list"> 

    <label>Date of Birth(MM/DD):</label> 

    <input type="text" name="note" id="box12" maxlength="5" /> 

    <em>*</em> 

    </li--> 

    

    





</ul> 



<li class="warning">**Please doublecheck your e-mail address as it is used to send you a receipt.**</li> 









<h2 class="proceed"> Proceed with your order</h2> 

  

  



<p class="check">Please check that all information has 

been included and is accurate. Select 

the 'Place Your Order' button. When you place your order you will receive a screen confirmation. 

Please fill in the credit card information and proceed with the transaction. 

</p> 



<ul class="last"> 


<!-- START CAPTCHA --> 
<br> 
<div class="capbox"> 

<div id="CaptchaDiv"></div> 

<div class="capbox-inner"> 
Type the above number:<br> 

<input type="hidden" id="txtCaptcha"> 
<input type="text" name="CaptchaInput" id="CaptchaInput" size="15"><br> 

</div> 
</div> 
<br><br> 
<!-- END CAPTCHA --> 

        <input type="submit"  value="Place Your Order" name="submit" id="submit" > 

    <input type="reset"  value="Clear the Form" id="reset" /> 

    </ul> 

</form> 



            

                              </div><!--left ends--> 

                

                <div id="right"> 

                

                 <!--nav begins--> 

                    <div id="nav100"> 

                         

                    <!--holder begins--> 

                <div id="holder100"> 

                                   

                    <li><a href="http://www.customer.ca/index.php" >Home</a></li> 

                    <li><a href="http://www.customer.ca/courses.php#nav2">Courses</a></li> 

                    <li><a href="http://www.customer.ca/archive.php">Archive</a></li> 

                    

                                        <li><a href="https://admin.acrobat.com/common/help/en/support/meeting_test.htm">Connection</a></li> 

                    <li><a href="http://www.customer.ca/contactus.php">Contact Us</a></li> 

                    <li><a href="https://secure.nl2k.ab.ca/customer/">Register</a></li> 

                </div><!--holder ends--> 

              

        

                        </div><!--nav ends--> 

                

                

                

                

                </div><!--right ends--> 

                

                <div id="bottomcontent"> 

                </div><!--bottom content ends--> 

                

                    </div> <!--content ends--> 

                

      

  

            



<div class="clearfooter"> 

</div> 





</div><!--wrapper ends--> 



<?php 



include("includes/footer.php"); 



?> 









            

</body> 

</html> 



And the second step 


<!DOCTYPE html > 
<html lang="en"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Professional Development Solutions - Online Form</title> 
<meta name="description" content="PD Solutions is an educational company that delivers on-line webinars and webcasts to various organizations or people" /> 
<meta name="robots" content="index, follow" /> 
<link rel="stylesheet" type="text/css" href="css/css.css"/> 
<link rel="stylesheet" type="text/css" href="css/css2.css"/> 
    <link rel="stylesheet" href="css/uniform.default.css" type="text/css" media="screen"> 
    <link rel="stylesheet" href="css/uniform.agent.css" type="text/css" media="screen"> 
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no"> 
</head> 
<body> 


<div id="wrapper"> 

        <!--header begins--> 
         
        <?php 

        include("includes/header.php"); 

        ?> 
         
    <!--header ends--> 
<?php 
//Setup data to send to Moneris 
session_start(); 
if (isset($_POST['submit'])){ 
$sessValue = $_POST['sessionid']; 
}; 
$store_id = "ID"; 
$hpp_key = "KEY"; 
$charge_total = $_POST[charge_total]; 

$bill_first_name = $_POST[bill_first_name]; 
$bill_last_name = $_POST[bill_last_name]; 
$bill_company_name = $_POST[bill_company_name]; 
$bill_address_one = $_POST[bill_address_one]; 
$bill_city = $_POST[bill_city]; 
$bill_state_or_province = $_POST[bill_state_or_province]; 
$bill_postal_code = $_POST[bill_postal_code]; 
$bill_phone = $_POST[bill_phone]; 
$email = $_POST; 

//the above is so far so good. 

// Below is at issue. 

//$connect = mysqli_connect("localhost", "pdsolutions", "tgarner7460","pdsolutions") or die ("Cannot connect"); 
//mysqli_select_db($connect,"pdsolutions") or die("Cannot select database"); 
//$result =  mysqli_query ($connect,"SELECT sessions.sessionid, courses.abbr, courses.seminar, sessions.date, sessions.time FROM sessions,courses WHERE sessions.courseid=courses.id AND sessions.sessionid > 712   ORDER BY sessions.sessionid ") or die('cannot show tables'); 
//$numRows = mysqli_num_rows($result); 
//echo "NUMBER OF ROWSC = ". $numRows .  "<br /><br />"; 
//$numRows = $_POST[count(results)]; 
//echo "NUMBER OF ROWSC = ". $numRows .  "<br /><br />"; 
echo "Session". print_R($sessValue) .   "<br /><br />"; 
$results = $_POST[$results]; 
echo "<br />results : ". print_r($results) ."<br />"; 
//$i = 0; 
while ($row = mysqli_fetch_assoc($results)) { 
         $id[]=$row['id']; 
         $price[]=$row['price']; 
         $description[]=$row['description']; 
         $quantity[]=$row['quantity']; 
        $date[]=$row['date']; 

} 
var_export($description); 
for ($n =700 ; $n < 900; $n++) 
{ 

//id[$n]=$_POST[id($n)]; 
//description[$n]=$_POST[description($n)]; 
//quantity[$n]=$_POST[quantity($n)]; 
//price[$n]=$_POST[price($n)]; 
//subtotal[$n]=$_POST[subtotal($n)]; 

echo "<br />". description[$n] . "<br />" . quantity[$n].  "<br />" . price[$n].  "<br />" .  subtotal[$n] ."<br />"; 
} 
$url ="https://esqa.moneris.com/HPPDP/index.php"; //QA Url 
$dataToSend = "ps_store_id=$store_id&hpp_key=$hpp_key&charge_total=$charge_total&bill_first_name=$bill_first_name&bill_last_name=$bill_last_name&bill_company_name=$bill_company_name&bill_address_one=$bill_address_one&bill_city=$bill_city&bill_state_or_province=$bill_state_or_province&bill_postal_code=$bill_postal_code&bill_phone=$bill_phone&email=$email&hpp_preload="; 

//send transaction to Moneris via an HTTPS Post using php Curl 
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $url); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_HEADER, 0); 
curl_setopt($ch, CURLOPT_POST, 1); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $dataToSend); 
curl_setopt($ch, CURLOPT_TIMEOUT, $gArray['CLIENT_TIMEOUT']); 
curl_setopt($ch, CURLOPT_USERAGENT, $gArray['API_VERSION']); 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 

$response = curl_exec($ch); 
curl_close($ch); 
//echo "Id :" . $id .  "<br /><br />"; 
//echo "Description :" . $description .  "<br /><br />"; 

//echo "Quantity :" . $quantity .  "<br /><br />"; 

//echo "Raw Response : " . $response . "<br/>"; 
if(!$response){ 
$response="Error preloading page"; 
}else{ 
$xmlString = new SimpleXMLElement($response); 

$ticket = $xmlString -> ticket; 
$order_id = $xmlString -> order_id; 
$response_code = $xmlString -> response_code; 

//echo "Data recieved : <BR/>"; 
//echo "Ticket : " . $ticket . "<br/>"; 
//echo "Order ID : " . $order_id . "<br/>"; 
echo "<br />Total : " . $charge_total . "<br/>"; 
//echo "Response Code : " . $response_code . "<br/>"; 

if($response_code <50) 
{ 
//echo "OK: Data successfully loaded <BR/> <br/>"; 
echo'<FORM METHOD="POST" ACTION="https://www3.moneris.com/HPPDP/index.php">'; 
echo'<INPUT TYPE="HIDDEN" NAME="hpp_id" VALUE="'.$store_id.'">'; 
echo'<INPUT TYPE="hidden" NAME="hpp_preload" >'; 
echo'<INPUT TYPE="hidden" NAME="ticket" VALUE="'.$ticket.'">'; 
echo'<INPUT TYPE="SUBMIT" NAME="SUBMIT" VALUE="Click to proceed to Secure Page">'; 
echo'</FORM>'; 
} 
else{ 
echo "Error: Data was not successfully loaded <br>"; 
} 

} 

include("includes/footer.php"); 

?> 
</div> 
</body> 

Step 2 ends. 

How do I pass the information from a complex database drive derived information 
in 3 steps? 

Link to comment
Share on other sites

3 minutes ago, Barand said:

TLDR

Post relevant code only and use code tags.

Thank you :  Here is what I am trying to focus on:

<?php         
session_start(); 
$_SESSION['sessionid'] = $sessionid1; 
if(mysqli_num_rows($result)){ 
 $results = array(); $i = 0; 
 while($row = mysqli_fetch_assoc($result)){ 

$i++;         
         
        $sessionid1=$row['sessionid']; 
        $abbr1=$row['abbr']; 
        $seminar1=$row['seminar']; 
        $date1=$row['date']; 
        $time1=$row['time']; 
         
        echo '<tr>'; 

echo " <td class=\"style3\" align=\"center\"> 
<input name=\"id" .  $row['sessionid'] .  "\" id=\"id". $row['sessionid'].  "\" value=\"" .$row['abbr'].  "-" .$row['sessionid'].  "\" size=\"10\"></td> 
<td align=\"center\"><input name=\"price".  $row['sessionid'].  "\" id=\"price".  $row['sessionid'].  "\" value=\"63.00\" size=\"7\" type=\"checkbox\" ></td> 
 <td class=\"style3\" align=\"center\"><input class=\"style3\" name=\"description".  $row['sessionid']. "\" id=\"description".  $row['sessionid'].  "\" value=\"".  $row['seminar'].  "\" type=\"text\"></td> 
 <td class=\"style3\" align=\"center\"><input class=\"style3\" name=\"quantity".  $row['sessionid'].  "\" value=\"0\" size=\"4\" type=\"text\" id=\"quans".  $row['sessionid'].  "\"></td> 
 <td align=\"center\"><div align=\"center\"><span class=\"style3\">".  $row['date'].  "&nbsp;".  $row['time'].  "</span></div>  </td>"; 

        echo "</tr>"; 

 } 
$results[]=$row; 
} 

echo $i; 
var_export($results); 
                                        ?> 

 

FRom the 1st page 

 

and for the step 2 page:

 

// Below is at issue. 

//$connect = mysqli_connect("localhost", "pdsolutions", "tgarner7460","pdsolutions") or die ("Cannot connect"); 
//mysqli_select_db($connect,"pdsolutions") or die("Cannot select database"); 
//$result =  mysqli_query ($connect,"SELECT sessions.sessionid, courses.abbr, courses.seminar, sessions.date, sessions.time FROM sessions,courses WHERE sessions.courseid=courses.id AND sessions.sessionid > 712   ORDER BY sessions.sessionid ") or die('cannot show tables'); 
//$numRows = mysqli_num_rows($result); 
//echo "NUMBER OF ROWSC = ". $numRows .  "<br /><br />"; 
//$numRows = $_POST[count(results)]; 
//echo "NUMBER OF ROWSC = ". $numRows .  "<br /><br />"; 
echo "Session". print_R($sessValue) .   "<br /><br />"; 
$results = $_POST[$results]; 
echo "<br />results : ". print_r($results) ."<br />"; 
//$i = 0; 
while ($row = mysqli_fetch_assoc($results)) { 
         $id[]=$row['id']; 
         $price[]=$row['price']; 
         $description[]=$row['description']; 
         $quantity[]=$row['quantity']; 
        $date[]=$row['date']; 

} 
var_export($description); 
for ($n =700 ; $n < 900; $n++) 
{ 

//id[$n]=$_POST[id($n)]; 
//description[$n]=$_POST[description($n)]; 
//quantity[$n]=$_POST[quantity($n)]; 
//price[$n]=$_POST[price($n)]; 
//subtotal[$n]=$_POST[subtotal($n)]; 

echo "<br />". description[$n] . "<br />" . quantity[$n].  "<br />" . price[$n].  "<br />" .  subtotal[$n] ."<br />"; 
} 
$url ="https://esqa.moneris.com/HPPDP/index.php"; //QA Url 
$dataToSend = "ps_store_id=$store_id&hpp_key=$hpp_key&charge_total=$charge_total&bill_first_name=$bill_first_name&bill_last_name=$bill_last_name&bill_company_name=$bill_company_name&bill_address_one=$bill_address_one&bill_city=$bill_city&bill_state_or_province=$bill_state_or_province&bill_postal_code=$bill_postal_code&bill_phone=$bill_phone&email=$email&hpp_preload="; 

 

Link to comment
Share on other sites

Update on snippets:

1st Step:

<?php
session_start();
//$_SESSION['sessiondata'] = $results;
if(mysqli_num_rows($result)){
 $results = array(); $i = 0;
 while($row = mysqli_fetch_assoc($result)){

$i++;

        $sessionid1=$row['sessionid'];
        $abbr1=$row['abbr'];
        $seminar1=$row['seminar'];
        $date1=$row['date'];
        $time1=$row['time'];

        echo '<tr>';

echo " <td class=\"style3\" align=\"center\">
<input name=\"id" .  $row['sessionid'] .  "\" id=\"id". $row['sessionid'].  "\" v
alue=\"" .$row['abbr'].  "-" .$row['sessionid'].  "\" size=\"10\"></td>
<td align=\"center\"><input name=\"price".  $row['sessionid'].  "\" id=\"price".
 $row['sessionid'].  "\" value=\"63.00\" size=\"7\" type=\"checkbox\" ></td>
 <td class=\"style3\" align=\"center\"><input class=\"style3\" name=\"description
".  $row['sessionid']. "\" id=\"description".  $row['sessionid'].  "\" value=\"".
  $row['seminar'].  "\" type=\"text\"></td>
 <td class=\"style3\" align=\"center\"><input class=\"style3\" name=\"quantity".
 $row['sessionid'].  "\" value=\"0\" size=\"4\" type=\"text\" id=\"quans".  $row[
'sessionid'].  "\"></td>
 <td align=\"center\"><div align=\"center\"><span class=\"style3\">".  $row['date
'].  "&nbsp;".  $row['time'].  "</span></div>  </td>";

        echo "</tr>";^M
 }
$_SESSION['sessiondata'] = $results;
$results[$i][]=$row;
}

echo $i;
echo $results;
                                        ?>

 

2nd Step

<?php
...

if (isset($_POST['submit'])){
$sessValue = $_POST['sessionid'];
};
...

echo "Session :". print_r($sessValue) .   "<br /><br />";
$results = $_SESSION[$results];
echo "<br />results : ". print_r(array_values($results)) ."<br />";
//$i = 0;
//while ($row = mysqli_fetch_assoc($results)){
while ($results){
         $id=$row['id'];
         $price=$row['price'];
         $description=$row['description'];
         $quantity=$row['quantity'];
        $date=$row['date'];

echo "<br />" . $id . "<br />" . $price . "<br />" . $description . "<br />" . $
quantity . "<br />". $date . "<br />";
}
var_export($description);
//for ($n =700 ; $n < 900; $n++)
//{

//id[$n]=$_POST[id($n)];
//description[$n]=$_POST[description($n)];
//quantity[$n]=$_POST[quantity($n)];
//price[$n]=$_POST[price($n)];
//subtotal[$n]=$_POST[subtotal($n)];

//echo "<br />". description[$n] . "<br />" . quantity[$n].  "<br />" . price[$n
].  "<br />" .  subtotal[$n] ."<br />";
//}
$url ="https://www3.moneris.com/HPPDP/index.php"; //QA Url
$dataToSend = "ps_store_id=$store_id&hpp_key=$hpp_key&charge_total=$charge_total
&bill_first_name=$bill_first_name&bill_last_name=$bill_last_name&bill_company_na
me=$bill_company_name&bill_address_one=$bill_address_one&bill_city=$bill_city&bi
ll_state_or_province=$bill_state_or_province&bill_postal_code=$bill_postal_code&
bill_phone=$bill_phone&email=$email&hpp_preload=";
//unset  $_SESSION['results'];
 

Link to comment
Share on other sites

Are you FKM?  All this code for the simple question of passing an array?

OK - pass an array.  Simply assign your data to a session variable and then be sure to always start a new script with a session_start().  Voila!

BTW - As I scrolled thru your first thousand lines of code I couldn't help but see multiple calls to make a db connection.  Unless there is something unique about all of those connections why do you not simply make your connection at the start of the script and then reference the handle that was created wherever you need to access the db?  Also why do you enter and exit php mode so often instead of just writing your php code in one big block?  If it is (I didn't look at your huge post at all) to go from using php to sending out html then you need to learn how to write good logical scripts that perform the php tasks up front and then send the html out later, with php vars embedded in it to provide the dynamically generated output where they need to be placed.  Mixing html/js/css in the midst of php code is to be avoided.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.