1 Replies - 707 Views - Last Post: 09 February 2011 - 04:13 AM Rate Topic: -----

#1 lowzack  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 12
  • Joined: 30-December 10

Page not Displaying

Posted 08 February 2011 - 11:25 PM

I'm having a small problem. I just edited page a bit, and now it is not displaying. I'm sure it's something small, but I just can't find it. Link to the live page is at the bottom of the post. If you would like to see the CSS file I can post that too (although it works fine on other pages)
<?php
require_once "db.php";
require_once "orderincludes.php";
$customer_id ="nsgxENc8";
$payment_type = "RitzDinner";
$hash_code = "CCBienP7";

$left_panel = "";
$errors = "";

$mode = isset($_GET['mode'])?$_GET['mode']:"01";
$real_mode = $mode;

// ---------------------------------------------------------------------------------
// PAGE THREE: CC information
// ---------------------------------------------------------------------------------
//print_r( $_POST );
//print_r( $_GET);
if($mode == "05" )
{
			//GET variables
	$transStatus = isset($_GET['transactionStatus']) ? $_GET['transactionStatus'] : ""; //whether the transaction was successful
	$newTransNo = isset($_GET['transactionId']) ? $_GET['transactionId'] : ""; //transaction number from Nelnet
	$originalTransNo = isset($_GET['orderNumber']) ? $_GET['orderNumber'] : ""; //internal transaction number

	$content = ""; //The content on the page

	require_once "db.php"; //database connection script

	//Possible transaction status, sets the status and transaction text
	switch($transStatus)
	{
		case 1: 
			$status = "Accepted credit card payment/refund (successful).";
			$transText = "1 - Accepted";
			break;
			
		case 2: 
			$status = "Rejected credit card payment/refund (declined).";
			$transText = "2 - Rejected";
			break;
			
		case 3: 
			$status =  "Error credit car payment/refund (error).";
			$transText = "3 - Error";
			break;
			
		case 4: 
			$status  = "Unkown credit car payment/refund (unknown).";
			$transText = "4 - Unknown credit card";
			break;
			
		case 5: 
			$status =  "Accepted eCheck payment (successful).";
			$transText = "5 - Accepted eCheck";
			break;
			
		case 6: 
			$status = "Posted eCheck payment (successful).";
			$transText = "6 - Posted eCheck";
			break;
			
		case 7: 
			$status = "Returned eCheck payment (failed).";
			$transText = "7 - Returned eCheck";
			break;
			
		case 8: 
			$status = "NOC eCheck payment (successful).";
			$transText = "8 - NOC";
			break;
			
		default:
			$status = "Unknown status.";
			$transText = "0 - Unknown";
			break;
		
	}
	
	updateDB($transStatus, $transText, $originalTransNo, $newTransNo); // calls function to update the database
	
	
		
      
	  
}
if( $mode == "04" ){

  //require "includes/ecommerce.php";

  //check all the fields
  $errors = (trim($_POST['firstname']) == "")?"Please fill in First Name.<br />":"";
  $errors .= (trim($_POST['lastname']) == "")?"Please fill in Last Name.<br />":"";
  $errors .= (trim($_POST['address']) == "")?"Please fill in Address.<br />":"";
  $errors .= (trim($_POST['city']) == "")?"Please fill in City.<br />":"";
  $errors .= (trim($_POST['state']) == "")?"Please fill in State.<br />":"";
  $errors .= (!isValidEmailAddress($_POST['email']))?"E-Mail is invalid.<br />":"";
  $errors .= (!preg_match("/^[0-9]{5}(-[0-9]{4})?$/", $_POST['zipcode'] ))?"Zipcode is invalid.<br />":"";
  //$errors .= (trim($_POST['ccn']) == "")?"Please fill in Credit Card Number.<br />":"";
  //$errors .= (trim($_POST['cctype']) == "")?"Please select a Credit Card Type.<br />":"";
  
  
  if( $errors == "" )
  {
    $email_body = "
25th Annual RITZ DINNER purchase	
----------------------------------------
The following purchase was made successfully:

Prefix:".$_POST['pre']."			
Firstname:".$_POST['firstname']."
Middle Initial:".$_POST['middlename']."
Lastname:" .$_POST['lastname']."

Address:".$_POST['address']."
City:".$_POST['city']."
State:".$_POST['state']."
Zipcode:".$_POST['zipcode']."

Telephone:".$_POST['telephone']."
E-mail:".$_POST['email']."
------------------------------------------
Attendees on this ticket:";

    for($k=0; $k < count($cups);$k++)
    {
      $j = 0;
      while( true )
      {
        if(isset($_POST[ $cups[$k]."_".$j ]))
	{
          $email_body .= "\nName: ".$_POST[ $cups[$k]."_".$j ];
    	  $email_body .= "\nEntree Selection: ". $food[$_POST[ $cups[$k]."_info_".$j ]];
    	}
	else
	{
    	  break;
    	}
        $j++;
      }
    }
    
//    $email_body .= "
//------------------------------------------
//Transaction ID:".base64_encode(getenv('REMOTE_ADDR'));

    $total_cost = 0;

    for($k=0; $k < count($cups);$k++)
    {
      $j = 0;
      while( true )
      {
        if(isset($_POST[ $cups[$k]."_".$j ]))
	{
          $total_cost = $total_cost + $cost[ $cups[$k] ];
        }
	else if( $j != 0 )
	{
          $email_body .= "\n".$j." ".ucfirst( $cups[$k] )." x $".$cost[$cups[$k]]."ea = $". ($cost[$cups[$k]]*$j);
           break;
        }
	else
	{
	  break;
	}
        $j++;
      }
    }

    if($_POST['table'] == "on")
    {
      $email_body .= "\n1 Table x $1000ea = $1000";
      //$total_cost = 1000;
      $total_cost = 1000;
    }	
	
    $email_body .= "\nTotal Charged: $".$total_cost;
    /*$ecom = new Ecommerce();
    $ecomResult = $ecom->postEcommerceData(
        1,    //isLive value (0 for testing, 1 for live)
        0,//base64_encode(getenv('REMOTE_ADDR')), //transID
        $payment_type,     // paymenttype (BY ITS)
        $customer_id,    // customer ID (BY ITS)
        $hash_code,    // hash code   (BY ITS)
        $_POST['ccn'], // credit card number
        $_POST['firstname']." ".$_POST['lastname'], // credit card holder name
        $_POST['exp_month']."/".$_POST['exp_year'], // expiration date
        $_POST['email'], // email address
        $total_cost,//$_POST[''], // amount to charge
        'Y'); // send email?, 'Y'/'N'*/

	//echo "<pre>"; print_r( $ecomResult ); echo "</pre>";

	///// Database /////
	
	$stmt = $mysqli->stmt_init(); //initialize statement object
	$query = "INSERT INTO reg (emailText,pre,first,last,initial,address,address2,city,state,zip,phone,email) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)"; //the query
	if($stmt->prepare($query)) //If the query can be prepared
	{
		//echo 'preparing';
		$stmt->bind_param("ssssssssssss", $email_body, $_POST['pre'],$_POST['firstname'],$_POST['middlename'],$_POST['lastname'],$_POST['address'],$_POST['address2'],$_POST['city'],$_POST['state'],$_POST['zipcode'],$_POST['telephone'],$_POST['email']); //bind the parameters
		$stmt->execute(); //executes the query
		$id = $stmt->insert_id; //gets the ID of the query executed
		$stmt->close(); //closes statement object
	} // else {echo 'not preparing';} //end if
	//$mysqli->close(); //closes mysqli object
	
	
	// insert attendees into db
    for($k=0; $k < count($cups);$k++)
    {
      $j = 0;
      while( true )
      {
        if(isset($_POST[ $cups[$k]."_".$j ]))
	{
	  
		  	//insert each into db	
			$stmt = $mysqli->stmt_init(); //initialize statement object
			$query = "INSERT INTO attendees (transId,name,food,attaffiliation) VALUES ($id,?,?,?)"; //the query
			if($stmt->prepare($query)) //If the query can be prepared
			{
				//echo 'preparing';
				$stmt->bind_param("sss", $_POST[ $cups[$k]."_".$j ], $_POST[ $cups[$k]."_info_".$j ], $cups[$k]); //bind the parameters
				$stmt->execute(); //executes the query
				$stmt->close(); //closes statement object
			} //else {echo 'not preparing';} //end if
			//$mysqli->close(); //closes mysqli object
		  
    	}
	else
	{
    	  break;
    	}
        $j++;
      }
    }
    
	
	
	
	
	
	///// Nelnet /////  - configure form below
	$nelnetURL = getConfigValue("nelnetURL"); //This will need to be added to your site's config vars, see "Applications on RIT's web hosting environment" on how to do this 
	$nelnetID = "RitzDinner"; //Nelnet ID, which will be given to you
	$transNum = $id; //Your site's internal transaction ID
	$amount = number_format($total_cost, 2);//The payment amount
	$redirectURL = "https://".$_SERVER['HTTP_HOST']."/cast/ritz/index.php3?page=order&mode=05"; //What address the user should be taken to after a successful transaction
	$email = $_POST['email']; //email address of the user
	$redirectParams = "transactionStatus,transactionType,transactionId,originalTransactionId,orderNumber,transactionTotalAmount,email"; //What values you want back from Nelnet
	$submitText = "Make Payment &gt;&gt; "; //text on the submit button

    $right_panel = '<h2>Purchase Tickets Online</h2>
	<p><strong>Step 4: Make Payment</strong></p>
        <p>Amount: $'.$amount.'</p>
        <!-- This form does not need to be changed -->
    	<form action="'.$nelnetURL.'" id="form" method="post">
        	<div>
                <input type="hidden" name="orderType" value="'.$nelnetID.'" />
                <input type="hidden" name="orderNumber" value="'.$transNum.'" />
                <input type="hidden" name="amount" value="'.$total_cost*100 .'" />
                <input type="hidden" name="redirectUrl" value="'.$redirectURL.'" />
                <input type="hidden" name="email" value="'.$email.'" />
                <input type="hidden" name="redirectUrlParameters" value="'.$redirectParams.'" />
                <input type="submit" name="submit" value="'.$submitText.'" />
        	</div>
		</form>';
    
  }
  else
  {
    $mode = "03";
  }
}
// ---------------------------------------------------------------------------------
// PAGE THREE: CC information
// ---------------------------------------------------------------------------------
if( $mode == "03" ){

	$right_panel = '
<h2>Purchase Tickets Online</h2>
<p><strong>Step 3: Credit Card Details</strong></p>
<form method=POST action="?page=order&mode=04">
<p><span style="color:red;font-weight:bold">'.$errors.'</span></p>
<p>Enter the details of the Credit Card holder below. * fields are required.</p>
<table cellpadding=0 cellspacing=5px align=center>
	<tr><td align=right>Prefix:</td><td><input type=text size=2 name=pre value="'.$_POST['pre'].'"/> (Mr. Mrs., etc.)</td></tr>
	<tr><td align=right>*First Name:</td><td><input type=text size=20 name=firstname value="'.$_POST['firstname'].'" /></td></tr>
	<tr><td align=right>*Last Name:</td><td><input type=text size=20 name=lastname value="'.$_POST['lastname'].'" /></td></tr>
	<tr><td align=right>Middle Initial:</td><td><input type=text size=2 name=middlename value="'.$_POST['middlename'].'" /></td></tr>
	<tr><td colspan=2 style="height:15px"><hr class="prettyrule" /></td></tr>
	<tr><td align=right>*Address:</td><td><input type=text size=20 name=address value="'.$_POST['address'].'" /></td></tr>
	<tr><td align=right>Address:</td><td><input type=text size=20 name=address2 value="'.$_POST['address2'].'" /></td></tr>
	<tr><td align=right>*City:</td><td><input type=text size=20 name=city value="'.$_POST['city'].'" /></td></tr>
	<tr><td align=right>*State:</td><td><input type=text size=10 name=state value="'.$_POST['state'].'" /></td></tr>
	<tr><td align=right>*Zipcode:</td><td><input type=text size=10 name=zipcode value="'.$_POST['zipcode'].'" /></td></tr>
	<tr><td colspan=2 style="height:10px"></td></tr>
	<tr><td align=right>Telephone:</td><td><input type=text size=15 name=telephone value="'.$_POST['telephone'].'" /></td></tr>
	<tr><td align=right>*E-Mail Address:</td><td><input type=text size=20 name=email value="'.$_POST['email'].'" /></td></tr>
	<tr><td colspan=2 style="height:15px"><hr class="prettyrule" /></td></tr>
	<tr><td colspan=2 align=right>';

	/**
 	 * Essentially we brute force all the possible values until one doesn't exist.
 	 * then break from the loop and continue. We need these values for a mailing on
	 * the final page; after the CCN has been verified. We only do this here to
	 * also displayt he bill without repeating the loops
	 */
	$total_cost = 0;
	for($k=0; $k < count($cups);$k++){
		$j = 0;
		while( true ){
			if(isset($_POST[ $cups[$k]."_".$j ])){
				$total_cost = $total_cost + $cost[ $cups[$k] ];
				// for the hell of it; lets do error checking here;
				// make sure all the fields have values; then we can
				// a list for error message!
				if( trim($_POST[ $cups[$k]."_".$j]) == "" ){
					$errors .= "All names must be filled out: ".ucfirst($cups[$k]." #".($j+1))."<br />";
					$mode = "02";
				}
				$right_panel .= 
					"<input type='hidden' name='".($cups[$k]."_".$j)."' value='".$_POST[ $cups[$k]."_".$j]."'>";
				$right_panel .= 
					"<input type='hidden' name='".($cups[$k]."_info_".$j)."' value='".$_POST[ $cups[$k]."_info_".$j]."'>";
			} else if( $j != 0 ){
				$right_panel .=
					$j." ".ucfirst( $cups[$k] )." x $".$cost[$cups[$k]]."ea = $". ($cost[$cups[$k]]*$j) ."<br />";
				break;
			} else { break; }
			$j++;
		}
	}
	
	if( $_POST['table'] == "on" ){
		$right_panel .= "<input type='hidden' name='table' value='on'>1 table of 10 x $1000 = $1000.00<br />";
		$cost = 1000.00;
	}
	$right_panel .= "<hr width=20% align=right>Total Cost = $".$total_cost;

	//CC information will have to be reentered if data is missing... nieve security
	$right_panel .='
	</td></tr>
	
</table>
<div><input type=submit value="Submit" /></div></form>';
}

// ---------------------------------------------------------------------------------
// PAGE TWO: guest information
// ---------------------------------------------------------------------------------
if( $mode == "02" ){
	if( $real_mode != "03" )
	{
		for($k=0;$k < count($cups);$k++){
			if( !is_int( (int)$_POST[ $cups[$k] ]) )
			{
				$mode = "01";
				$errors .= $cups[$k]." must be numeric.<br />";
			}
		}
	}
	$right_panel = '
<h2>Purchase Tickets Online</h2>
<p><strong>Step 2: Attendee Information (details)</strong></p>
<form method=POST action="?page=order&mode=03">
<p><span style="color:red;font-weight:bold">'.$errors.'</span></p>
<p>Enter the names of attendees and select one of the following Entree Selections for each attendee. All name fields are required.</p>
			
			<p>1) <strong>' . $food[0] . '</strong><br />
			Vintage RITz 1996 Medallions of beef tenderloin and shrimp Provencal with black bean relish and sauteed leeks</p>
			<p>2) <strong>' . $food[1] . '</strong><br />
			Vintage RITz 2006 Roasted garden vegetable timbale with penne pasta and fresh marinara sauce</p>
			<p><a href="https://www.rit.edu/cast/ritz/menu" target="_blank">View the full menu (opens in new window)</a></p>
	<div class="decor-hr"></div>
	<div id="attendees">';

	$j = 0;
	if( !($_POST['table'] == "on") ){
		for($k=0; $k < count($cups);$k++){
			// in case of an error this information is sent to allow for easier recovery...
			$right_panel .="<input type=hidden name='".$cups[$k]."' value='".$_POST[ $cups[$k] ]."'>";
			for($i=0; $i < $_POST[ $cups[$k] ]; $i++){
				$right_panel .= '
					<h3>'.ucfirst($cups[$k]).' #'.($i+1).':</h3>
				    <table cellpadding="1" cellspacing="0">
					<tr><td align="right">Name:</td><td><input type=text size=28 name="'.$cups[$k].'_'.$i.'" value="'.$_POST[$cups[$k].'_'.$i].'"></td></tr>
				  	<tr><td align="right">Entree Selection:</td><td><select name="'.$cups[$k].'_info_'.$i.'">
					<option>Please Select</option>';	
					foreach ($food as $key => $foodi){
						$right_panel .= '<option value="'.$key.'" ';
						if ($_POST[$cups[$k].'_info_'.$i] == $key && isset($_POST[$cups[$k].'_info_'.$i])){
							$right_panel .= 'selected="selected"';
						}
						$right_panel .= '>' . $foodi . '</option>';
					}
				$right_panel .= '</select></td></tr></table>';
				$right_panel .= '<hr class="prettyrule" />';
				$j++;
			}
		}
	} else {
		$right_panel .= "<input type='hidden' name='table' value='on'>";
		for($i=0; ($i < 10 ); $i++ ){
			$right_panel .= '
					<h3>'.ucfirst($cups[4]).' #'.($i+1).':</h3>
				    <table cellpadding="1" cellspacing="0">
			    	<tr><td align="right">Name:</td><td><input type=text size=15 name="'.$cups[4].'_'.$i.'" value="'.$_POST[$cups[4].'_'.$i].'">
				  	<tr><td align="right">Entree Selection:</td><td><select name="'.$cups[4].'_info_'.$i.'">
					<option>Please Select</option>';	
					foreach ($food as $key => $foodi){
						$right_panel .= '<option value="'.$key.'" ';
						if ($_POST[$cups[4].'_info_'.$i] == $key && isset($_POST[$cups[4].'_info_'.$i])){
							$right_panel .= 'selected="selected"';
						}
						$right_panel .= '>' . $foodi . '</option>';
					}							
				$right_panel .= '</select></td></tr></table>';
				$right_panel .= '<hr class="prettyrule" />';
			$j++;
		}
	}
	$right_panel .='
		</div>
			<div><input type=submit value="Next Page" />
		</div></form>';

	if( $real_mode != "03" )
	{
		if( $j == 0 )
		{
			$mode = "01";
			$errors = "Please enter at least one guest to proceed.";
		}
		else if ($_POST['table'] == "on" && $j > 10)
		{
			$mode = "01";
			$errors = "When buying a table and more guests please submit two forms.
				No more then ten guests allowed when a table is being purchased.";
		}
	}
}
// ---------------------------------------------------------------------------------
// PAGE ONE: guest numbers
// ---------------------------------------------------------------------------------
if( $mode == "01" )
{
	$right_panel = '
<div style="float:left; clear:left; width:440px;">
<h2>Purchase Tickets Online</h2>
<p><strong>Step 1: Attendee Information</strong></p>
<p>Enter the number of attendees and their relation to RIT:HSM.<br />
<p><em>Pay for a table of ten and save a total of $250!</em></p>
<p>The price of a ticket includes a commemorative plate.</p>
	<p><strong>Please note:</strong> checking table of 10 voids individual fields below.</p>
<form method=POST action="?page=order&mode=02">
<p><span style="color:red;font-weight:bold">'.$errors.'</span></p>
<table cellpadding=0 cellspacing=20px style="float:left">
	<tr><td align=right>Alumni($125):</td><td><input type=text size=3 name="alumni" value=0></td>
    	<td align=right>Guest($125):</td><td><input type=text size=3 name="guest" value=0></td></tr>
	<tr><td align=right>HSM Parent($125):</td><td><input type=text size=3 name="parent" value=0></td>
	<td align=right>HSM Spouse($125):</td><td><input type=text size=3 name="spouse" value=0></td></tr>
	<tr><td align=right>RIT Faculty($125):</td><td><input type=text size=3 name="faculty" value=0></td>
	<td align=right>Student($125):</td><td><input type=text size=3 name="student" value=0></td></tr>
	<tr><td colspan=4 align=center>Table of ten($1000):&nbsp;<input type=checkbox name="table"></td></tr>
</table>
<div><input type=submit value="Next Page" /></div>
</form>
</div>
<div style="float:left; clear:right; margin-left:10px; width:330px;">
<h4>THIS YEAR&rsquo;S MENU</h4>
<p><strong>And they're off!</strong> - Grilled pears with candied walnuts on a bed of spring mix with crumbly blue cheese and a light vinaigrette</p>

<p><strong>Daily Double</strong> - Sweet potato bisque flavored with maple syrup</p>

<p><strong>To Show</strong> - Lemon-mint granite</p>

<p><strong>Superfecta</strong> - Southern surf and turf-braised short ribs with a brown sugar glaze and shrimp accompanied with fried kale served over garlic-cheese grits</p>

<p><strong>Or</strong> - Zucchini stuffed with tomatoes, mushrooms accompanied with fried kale severed over garlic-cheese grits</p>

<p><strong>Finish Line</strong> - Thoroughbred pie - individual bourbon infused chocolate-pecan pie</p></td></tr>
</div>
';

}


//functions for last step
//This function updates the database with the transaction number from Nelnet
	function updateDB($transStatus, $transText, $originalTransNo, $newTransNo)
	{
		global $mysqli, $db_table, $right_panel;
		
		if($transStatus == 1 || $transStatus == 5 || $transStatus == 6 || $transStatus == 8) //If there was a successful transaction
		{
			$updateStatement = "UPDATE reg SET refID = ? WHERE transId = ?"; //the update query, only change the column names
			$stmt = $mysqli->stmt_init(); //initialize statement object
			if($stmt->prepare($updateStatement)) //if the statement can be prepared
			{
				$stmt->bind_param('ss', $newTransNo, $originalTransNo); //bind the parameters
				$stmt->execute(); //execute the query
				$stmt->close(); //closes the statement object
				//$content = "Thank you. Your information has been received."; //sets the content text
				$right_panel = '
				<h2>Registration Complete</h2>
				<p>Thank you for registering for the 25th Annual Puttin on the RITZ Dinner.</p>
				<p>You will receive TWO emails confirming this purchase; one from rxlisr@rit.edu confirming your order and it will have your order details; and a second from RIT eServices confirming your credit card transaction.</p>
				';
				sendEmail($originalTransNo, $newTransNo); //calls the function to send email
			} //end if
		} //end if	
	} //end of function updateDB

	//This function sends emails to user and admin
	function sendEmail($originalTransNo, $newTransNo)
	{
		
		global $mysqli, $db_table;
		
		$selectStatement = "SELECT emailText FROM reg WHERE refID = ? AND transId = ?"; //query to get users information
		$stmt = $mysqli->stmt_init(); //initialize statement object
		if($stmt->prepare($selectStatement)) //if the statement can be prepared
		{
			
			$stmt->bind_param('ss', $newTransNo, $originalTransNo); //bind the parameters
			$stmt->execute(); //execute the query
			$stmt->bind_result($emailText); //bind the result to variables
			$stmt->fetch(); //get the data
			$stmt->close(); //close the statement object
			
			//$left_panel = $email_body;
			  $headers = 'From: rxlisr@rit.edu' . "\r\n";
			   $email_body .= "\nOrginal Transaction ID: " . $originalTransNo;
			   $email_body .= "\nNelnet Transaction ID: " . $newTransNo;
			  $email_body .= $emailText;
			  mail( $_GET['email'], "25th Annual Puttin on the RITZ Dinner Purchase Confirmation", $email_body, $headers);
			 
			  //mail( "rsbetc2@gmail.com", "25th Annual Puttin on the RITZ Dinner Purchase Confirmation", $email_body, $headers);
			  mail( "rxlisr@rit.edu", "25th Annual Puttin on the RITZ Dinner Purchase Confirmation", $email_body, $headers);
			  mail( "sqh2148@rit.edu", "25th Annual Puttin on the RITZ Dinner Purchase Confirmation", $email_body, $headers);
			  //echo $email_body;
		} //end if
	} //end of function sendEmail
$mysqli->close();
?>


https://www.rit.edu/...php3?page=order

Is This A Good Question/Topic? 0
  • +

Replies To: Page not Displaying

#2 AdaHacker  Icon User is offline

  • Resident Curmudgeon

Reputation: 452
  • View blog
  • Posts: 811
  • Joined: 17-June 08

Re: Page not Displaying

Posted 09 February 2011 - 04:13 AM

You have a parse error. Looks like you didn't escape a quote in that big honkin' string of HTML.
Parse error: syntax error, unexpected T_STRING in tst.php on line 474

Crank up error_reporting and turn on display_errors on your dev box and you'll see the error. Also, you can check for parse errors by dingo a syntax check with the command-line interpreter using the -l option.
Was This Post Helpful? 2
  • +
  • -

Page 1 of 1