The program is for users to download the file using ftp...actually..
Previously, there are 3 files (form.php, search.php, index.php) that work together to make a download page program..but now..i have to change these 3 files into one file by split it into functions..
Named it as function form , function search and function index..
function form()
{
/This function will display a form that will fetch a result from 'function result'. when requested/
echo "
<FORM method=\"GET\" ACTION=$PHP_SELF>\n";
echo "<input type=hidden name=action value=\"result\">";
echo "Keyword : ";
echo "<INPUT type=\"text\" name=\"keyword\" maxlength=\"40\" size=\"22\" value=\"\">";
bla..bla..bla..
}
function result()
{
//will carry a variable that fetch the results from database..
// Fetch result from database by carrying $programid and $subprogramid
//After displaying the result
If the user want to download the file ...
The program then check/carry the variable in the index.php..file...(let say it will carry $programid,$subprogramid, $id)..
so that , it can verify..the url...
and ftp it
this is a part of the coding..
global $theme, $PHP_SELF, $QUERY_STRING, $keyword, $category, $license, $platform, $company, $programid, $subpr
ogramid, $id, $st, $qt, $qp, $nh, $rf, $recURL;
/********/
$fp = fsockopen("search.skali.com.my", 80, &$errno, &$errstr, 30);
if (!$fp) {
echo "$errstr ($errno)\n";
} else {
$header = 1;
fputs($fp, $query);
while ($buf = fgets($fp, 4096)) {
$buf = trim($buf);
if ($header == 0) {
if (ereg("Hits=(.)", $buf, $regs)) {
$total = $regs[1];
} else if (ereg("end=(.)", $buf, $regs)) {
$end = $regs[1];
} else if (ereg("Title=(.)", $buf, $regs)) {
$article[] = $regs[1];
} else if (ereg("URL=(.)", $buf, $regs)) {
if (ereg("index.php?(.)", $buf, $regs1)) {
$url[] = $regs1[1];
}
} else if (ereg("Summary=(.*)", $buf, $regs)) {
$summary[] = $regs[1];
}
} else if (strlen($buf) == 0) {
$header = 0;
}
}
fclose($fp);
}
/***????So how do i declare the "index.php" stated above to function...I mean the way of the syntax should be coded..cause the index.php file has been changed into function..
}
function index()
{
// is for the program to update the database on how many users download the file..
//Part of the coding ...
global $PHP_SELF, $QUERY_STRING, $programid, $subprogramid, $id, $st, $qt, $qp, $nh, $rf, $code, $download, $url;
if (isset($code) && isset($download) && isset($url)) {
$query = "UPDATE $code SET hits=hits+1 WHERE id=$download;";
$result = mysql_db_query ('skali_downloads', $query);
if (!$result) {
echo mysql_errno().": ".mysql_error()."<br>\n";
return;
}
header("Location: $url");
exit;
}
Or if i make it confuse again I will e-mail the codes to you...cause i am still new in this PHP... so i think it's just a simple thing that i cant handle..Thank you...