Jump to content

Recommended Posts

Hi,

 

I wrote a simple php page and tested it locally via WAMP. It is OK. I decided to upload this code onto joomla. I set the menu items and add this page as a new artice as follows:

<p>{jumi [test.php]}</p>

Here is my sample test.php:

<html>
<head>
<title>TEST</title>
<style type="text/css">
table.imagetable {
	font-family: verdana,arial,sans-serif;
	font-size:11px;
	color:#333333;
	border-width: 1px;
	border-color: #999999;
	border-collapse: collapse;
}
table.imagetable th {
	background:#b5cfd2 url('cell-blue.jpg');
	border-width: 1px;
	padding: 8px;
	border-style: solid;
	border-color: #999999;
}
table.imagetable td {
	background:#dcddc0 url('cell-grey.jpg');
	border-width: 1px;
	padding: 8px;
	border-style: solid;
	border-color: #999999;
}
table.center {
    margin-left:auto; 
    margin-right:auto;
  }

</style>
</head>
<BODY >

<br>

<?php
function form($imageURL536,$imageURL640,$drawNo){
echo "
<form method='get'>
<center><img border='0' src='contest_winner.jpg' alt='' width='452' height='384' class='center'></center>
<table class='imagetable center'>
<tr>
	<th>5/36</th>
	<th>6/40</th>
</tr>
<tr>
	<td>
		<select name='game1'>
			<option value='1'>$drawNo</option>
			
		</select>
	</td>
	<td>
		<select name='game2'>
			<option value='1'>$drawNo</option>
			
		</select>
	</td>
</tr>
<tr>
	<td>
		<center><input name='send536' type='submit' value='Check'></center>
	</td>
	<td>
		<center><input name='send640' type='submit' value='Check'></center>
	</td>
</tr>
<tr>
	<td>
		<center><img border='0' src='$imageURL536' width='24' height='24' ></center>
	</td>
	<td>
		<center><img border='0' src='$imageURL640' width='24' height='24' ></center>
	</td>
</tr>
</table>


</form>";

}

function sendEmail($msg){
//Send Mail.
    require_once("class.phpmailer.php");

    $cbsmail = new phpmailer();
    $cbsmail->IsSMTP ();
	$cbsmail->IsHTML(true);
    $cbsmail->SMTPAuth = "TRUE";

    $cbsmail->Username = "info";
    $cbsmail->Password = "info/";

    $cbsmail->Hostname = "111.11.11.1";
    $cbsmail->Host = "111.11.11.1";
    $cbsmail->port = '25';

    $cbsmail->From = "test@test.com.tr";
    $cbsmail->FromName = "Information";

    $cbsmail->Subject = 'TEST ' .date("d/m/Y");


    $body = chr(13) ."Dear All, " ."<br>"."<br>";

    $cbsmail->Body = $body;

    $cbsmail->AddAddress("test@test.com.tr");
   
    $cbsmail->Send();

    unset($cbsmail);
}

 $imageURL536 = "FAQ-icon.png";
 $imageURL640 = "FAQ-icon.png";
 $drawNo = "123456";
 
if (isset($_GET['send536'])){

ConnectFTP($drawNo);

$imageURL536 = "Circle-apply-icon.png";



}
if (isset($_GET['send640'])){

ConnectFTP($drawNo);

$imageURL640 = "Circle-remove-icon.png";

}

//Prepare Markup
form($imageURL536,$imageURL640,$drawNo);

function ConnectFTP($drawNo)
{
	$ftp_server = "111.11.111.111";
	$ftp_user = "user";
	$ftp_pass = "pass!!!";
	$ftp_port = "21";
	$path536 = "/536/RESULTS/";
	$path640 = "/640/RESULTS/";
	$check_file536_exist = $path536."test-wins_5-36-1006.txt";
	$check_file640_exist = $path640."test-wins_6-40-1456.txt";

	// Open connection
	$conn_id = ftp_connect($ftp_server,$ftp_port) or die(
             "$ftp_server sunucusuna bağlantı kurulamadı");

	// Login
	if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
		// get the size of $file
		$res = ftp_size($conn_id, $check_file536_exist);

		if ($res != -1) {
			
			parseFile($check_file536_exist);
		} else {
			
			sendEmail("Couldn't find the file on FTP ".$check_file536_exist);
		}
	
	} else {
		
		sendEmail("Couldn't establish connection with $ftp_user ");
	}

	// Close connection
	ftp_close($conn_id);
}
	
		
function parseFile($check_file536_exist)
{
	
	//Get Files to Parse
	 $homepage = file_get_contents('ftp://user:pass!!!@111.11.111.1:21/640/RESULTS/test-wins_6-40-1010.txt');
	
	
	$kw = explode("\n", $homepage);
	$totalNumRow = 0;
	$totalAmount = 0;

	// Loop the relevant records
	for($i=0;$i<count($kw);$i++){
		
		
		if(substr($kw[$i], 0, 1) == "5" && substr($kw[$i], 1, 1) <> "/")
		{
			// echo $kw[$i];
			
			$totalNumRow = $totalNumRow + 1;
			
			$originalstring = $kw[$i];
			
			$delimiter = ",";
			if(strpos($originalstring,$delimiter) > 0){
					$outarray = explode($delimiter,$originalstring);
					
					$amount = $outarray[1];
					// echo $amount;
					$totalAmount = $totalAmount + $amount;
			}
			
			// echo "<br>";
		}
		
		
	}
}

		
	
?>

The problem is, when I click the check buttons, the page becomes blank! But when I tried on local machine, after button click, page displays the table again. What is wrong with this?

 

Best Regards.

Link to comment
https://forums.phpfreaks.com/topic/278890-button-click-showing-blank-page/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.