Forum Moderators: coopster
Is it possible for me to write a script that let the user enters the image ID (thru a form) then redirect the user to the download URL, so that the user can download the content (jpg/wav/etc.)?
The reason why i am doing this: i am using 4images, which has a table for storing image iD, download URL, etc. but I want to make it possible for users to just key in the image ID and get to download the file thru wap. Can anyone please help me? any help is appreciated. If it's possible, can please walk me through step by step, so that i can learn as i go? thanks.
<?PHP
if ($imageId) {
doQuery ("SELECT downloadURL FROM table WHERE id='$imageid'");
$downloadURL = <result of query>
Header ("Location: $downloadURL");
echo "show me the image";
exit;
} else {
# error
}
?>
<?php
$host = "localhost";
$user = "user";
$pass = "pass";
$dbname = dbname";$connection = mysql_connect($host,$user,$pass) or die (mysql_errno().": ".mysql_error()."<BR>");
mysql_select_db($dbname);$query= "select * from 4images_images where image_id='" . $_POST['image'] . "'";
$result= mysql_query($query);
// $num_results = mysql_num_rows($result);
$row = mysql_fetch_array($result);
$filename=$row['image_media_file'];
$category=$row['cat_id'];$file="http://...".$category."/".$filename;
header("Location:$file"); /* Redirect browser */
exit;
?>
Am i missing anything? Will this work on wap as well?
<?php$browser = $HTTP_USER_AGENT;
$arrbrowser = array("mozilla","opera","MSIE") // put all the UA's in here
$test = "no";
$counter = 0;while (isset($arrbrowser[$counter]))
{
if (strstr($browser,$arrbrowser[$counter])) $test = "yes";
$counter++;
}if ($test == "yes") // then we have a browser from our array
{
echo "not allowed access";
}
else {$host = "host";
$user = "user";
$pass = "pass";
$dbname = "db";$connection = mysql_connect($host,$user,$pass) or die (mysql_errno().": ".mysql_error()."<BR>");
mysql_select_db($dbname);$query= "select * from 4images_images where image_id='" . $_POST['image'] . "'";
$result= mysql_query($query);
// $num_results = mysql_num_rows($result);
$row = mysql_fetch_array($result);
$filename=$row['image_media_file'];
$category=$row['cat_id'];$file="http://..."."/".$category."/".$filename;
header("Location:$file"); /* Redirect browser */
/* Make sure that code below does not get executed when we redirect. */
exit;
?>
}
it says parse error on line 5...anybody?