Page 3 of 3

Re: HMG + PHP simplexml_load_file()

Posted: Mon May 25, 2020 6:27 pm
by franco
I have set up a local server. I need help at start of code to get username and password, also what is in clist3.txt to put in folder.

AT START
????? $user = input(user) ???? an input box to pass parameter
?????? $ cCode = input(Password)
I can get following code to work but no data in report. I took out get cCode and entered my own but no table info

Code: Select all

>html
<meta http-equiv="Content-Type" content="text/html; charset=utf-8;" />
<head>
<style>
table {
	width:70%;
}
table, td, th {
	border: 1px solid black;
	border-collapse: collapse;
}
h1 {
	color: #00A;
}
</style>
</head>
<body>
<?PHP
//include('./settings.php'); 

//if ( $_GET["cCode"] == false )
//{                                                                                              I TOOK THIS AREA OUT
//	print "You dind't send client code!";
//	exit;
//}
$cRequestedClient = '10001';                    //$_GET["cCode"];
print "<h1>Sale of client: ".$cRequestedClient."</h1><br>";
print '<table>';
print "<th>No</th><th>Item</th><th>Description</th><th>Price</th><th>Saleprice</th>";
$SalesFile = './CLLIST3.TXT';
$lines = file($SalesFile);
$no=1;
$total1=0;
$total2=0;
foreach ($lines as $line) {
	$aline=explode(',',$line);
	$cCodeClientSale = trim($aline[0]);
	
 	if($cCodeClientSale==$cRequestedClient	)
	{
		print "<tr>";
		print "<td>".$no."</td>";
		print "<td>".$aline[1]."</td>";
		print "<td>".$aline[2]."</td>";
		print "<td>".$aline[3]."</td>";
		print "<td>".$aline[4]."</td></tr>";
		$total1+=$aline[3];
		$total2+=$aline[4];
		$no++;
	}
}
print "<tr>";
print "<td></td>";
print "<td></td>";
print "<td>TOTAL</td>";
print "<td>".$total1."</td>";
print "<td>".$total2."</td></tr>";
print "</table>";
?>
</body>
</html>
Thanks this is getting me started with php.
Franco

Re: HMG + PHP simplexml_load_file()

Posted: Mon May 25, 2020 8:29 pm
by mol
Php code is running on the server side. You can't do interaction with user in php.
You can create html code to enter username and password and then sent it with POST to php file.
If you want to secure it, you have to use session at least.

Re: HMG + PHP simplexml_load_file()

Posted: Mon May 25, 2020 9:46 pm
by franco
Is this the html code you mean

<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8;" />
<head>
<style>
table { >>>>>>>>>>>>>>>

Franco

Re: HMG + PHP simplexml_load_file()

Posted: Thu May 28, 2020 2:19 am
by apais
This is Roberto's HMGWEB running on apache + mod_harbour:
https://www.mod-harbour.com/hmgweb/tableadv_a.prg