473,486 Members | 2,394 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Confirm user is logged in before he download from site

4 New Member
Hello All,
I want to confirm that the user is registered member before he is redirected to download link. How do i read URL stored in DB and redirect user to this URL in PHP, if there is no product with that id it will show message product not found

User will click on link like
www.url.com/download.php?do=12 where 12 no is product id, Now @ download.php it will check wheter the user has logged in or not, if not he will be redirected to login page, else it will read download URL from db and redirect to that link.

i tried to rite following code but it is no functioning properly.

[PHP]
<?php
include("config.php");
include("head.php");
if(!isset($_COOKIE['userId'])) echo '<script>window.location="login.php"</script>';
$id=$_GET['Id'];
$sql=mysql_query("SELECT * FROM affiliate_planpages WHERE ppageId='".$id."' AND status='u'")or die(mysql_error());
$fetch=mysql_fetch_array($sql);
if(isset($_GET['do']))
{
$Do=$_GET['do'];
$sql12=mysql_query("SELECT * FROM affiliate_product WHERE productId='".$Do."'")or die(mysql_error());
$fetch=mysql_fetch_array($sql12);
echo '<script>window.location="$fetch[dlink]"</script>';
}
else
{
echo "<strong>Product Not Found</strong> ";
}
include("foot.php"); ?>
[/PHP]


the database structure is as follows

[PHP]CREATE TABLE `affiliate_product` (
`productId` int(10) NOT NULL auto_increment,
`title` varchar(200) NOT NULL default '',
`dlink` varchar(200) NOT NULL default '',
`imgurl` varchar(200) NOT NULL default '',
`price` varchar(200) NOT NULL default '',
`description` text NOT NULL,
`pr` varchar(100) NOT NULL default '',
PRIMARY KEY (`productId`)
) AUTO_INCREMENT=1 ;[/PHP]

Also is there any way by which end user never comes to know the actual URL, i.e even during download progress the URL shown will be www.url.com/download.php?do=12

Thanxs in advance,
Best Regards,
Ritesh Jain
Mar 7 '08 #1
3 2043
hsriat
1,654 Recognized Expert Top Contributor
Line 4:[php]if(!isset($_COOKIE['userId']))
header("Location=login.php");[/php]
Also modify line 13 accordingly.

For Server, JavaScript code is just a string, and nothing more then that. Also keep in mind that JavaScript and PHP don't run together. PHP (hypertext preprocessor) runs on server while JS runs on client (after the server sends the HTML to the browser).

Harpreet
Mar 7 '08 #2
jainritesh
4 New Member
Hello Harpreet,
I am able to confirm wheter the user is registered member and has logged in, my problem how to redirect user to the download file after confirming the same. the download link is stored in database.

Best Regards,
Ritesh Jain
Mar 8 '08 #3
hsriat
1,654 Recognized Expert Top Contributor
Hello Harpreet,
I am able to confirm wheter the user is registered member and has logged in, my problem how to redirect user to the download file after confirming the same. the download link is stored in database.

Best Regards,
Ritesh Jain
I told you in my above post to modify line 13 also...[php] header ("Location:".$fetch[dlink]);[/php]
Mar 8 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
1931
by: ad | last post by:
I use the code below to export the content of a data set to Excel, the code come form http://www.dotnetjohn.com/articles.aspx?articleid=36 It will take a long time to dolwnload if the excel...
2
1163
by: Patrick.O.Ige | last post by:
Whats the easiest way to list USERS that are logged on to ur site? Thx
15
6370
by: Snedker | last post by:
I'm using (HttpWebRequest and HttpWebResponse to check for updates. But how do I determine the size of the file before download? What I have in mind is a status text like "You have downloaded...
0
1681
by: meepleep | last post by:
www.newsgarbage.com, a new user-controlled technology news site has now gone into beta. Newsgarbage works in a similar way to other news sites, such as slashdot or digg.com, but allows much...
4
1740
by: Rik Hemsley | last post by:
Hi, Our web application impersonates a domain user when it runs. Usually, the printers visible to the application are the same as those visible to the domain user. At one installation, the...
1
1355
by: ruky | last post by:
Can any one help me. I need to capture the length of time a user spend on my site. I need to capture this information in an SQL database. Thanks
6
1223
by: ddeme | last post by:
Can u please tell me how can i get keywords by which user is visiting my site. I read some where by using Request.ServerVariables we can get keywords. But not sure how can i do that... please help...
1
3242
by: Nate.Baxley | last post by:
I have a site that I want to keep the user logged in after they leave the site if they check the "Remember Me" box. How do I go about doing this? Lengthen the session length? Any help would be...
1
1093
ifedi
by: ifedi | last post by:
I've been trying to understand user categories on this site ('Newbie', 'Moderator', etc). Can someone please educate my on how these work? When for instance do I stop being 'Newbie'. And again,...
0
6967
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7132
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6846
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
4870
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4564
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1381
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
600
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
266
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.