Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 01-17-2006, 12:47 PM clever redirection?
hiptobesquare's Avatar
Extreme Talker

Posts: 186
Location: London UK
Trades: 0
Hello again

Can anybody tell me if php has a function that will detect what page a user has come from?
Ive several page on my site from which a user can add to their cart. Once they click an add to cart button from any page they will be sent to a script which adds data to the cart table and redirects them automatically to the showcart page. I want to change this so that after the info has been added to the cart table the user is redirected to the page they added to cart from. Any Ideas?????

here is the add to cart script
PHP Code:

<?php
session_start
();
include(
'dbinfo.php');

$query "SELECT * FROM $_POST[table] WHERE item_ID='$_POST[item_id]' and size='$_POST[size]'"
$result mysql_query($query
or die(
"Query failed: " mysql_error());
while ( 
$row mysql_fetch_array($result) ) {
$item_id$row[item_id];
$item=$row[item];
$one_weight=$row[weight];
$description$row[description];
$one_price$row[price];
}

$system_name="$_SESSION[sysname]";
$overall_aperture="$_SESSION[apwidth]x$_SESSION[apheight]";
$hinged_or_sliding="$_SESSION[hingeslid]";
$finish="$_POST[finish]";
$extras="$_POST[extras]";
$quantity="$_POST[quantity]";
$size="$_POST[size]";
$weight=($one_weight $quantity);
$price=($one_price $quantity);

$insert "INSERT INTO cart_items VALUES (''
         ,'
$PHPSESSID','$system_name','$item_id','$item','$weight'
         ,'
$overall_aperture','$size','$hinged_or_sliding','$finish','$extras'
         ,'
$quantity','$price')";
mysql_query($insert);
mysql_close();?>
<?php header
("Location: SEND_TO_PREVIUOS_PAGE.php"); exit; ?>
hiptobesquare is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-17-2006, 01:46 PM
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
$http_server_vars["http_referer"]
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-28-2007, 03:11 PM Re: clever redirection?
Average Talker

Posts: 29
Trades: 0
well the answer is
$http_server_vars["http_referer"] as chrishirst wrote.
i have notecd that you do not do any check for user inputs. this is a big risk for your data base any one can attack your site using a basic SQL Injection.
you should not trust user inputes , user inputs is Devel.
make some research on how to protect agensit SQL Injection. or PM me i will show you how to do so.
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
mokka14 is offline
Reply With Quote
View Public Profile
 
Old 01-29-2007, 03:29 AM Re: clever redirection?
Novice Talker

Posts: 8
Name: Matt
Trades: 0
Beware of trusting the referer var because people can fake it and whatnot.... not like it's a security risk in your example but just in general.
Devourer09 is offline
Reply With Quote
View Public Profile
 
Old 01-29-2007, 10:59 PM Re: clever redirection?
vivekar's Avatar
Webmaster Talker

Posts: 612
Trades: 0
Check out this thread.
Can PHP site be hacked easily...

Browsers can be configured to stop sending referer information also.
Making a shopping cart application relying on referer information is very dangerous, IMHO.
__________________

Please login or register to view this content. Registration is FREE
(Active since 2003) |
Please login or register to view this content. Registration is FREE
vivekar is offline
Reply With Quote
View Public Profile Visit vivekar's homepage!
 
Reply     « Reply to clever redirection?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.15440 seconds with 12 queries