HighDots Forums  

Checking multiple variables in URL

Macromedia Dreamweaver Macromedia Dreamweaver Discussions (macromedia.dreamweaver)


Discuss Checking multiple variables in URL in the Macromedia Dreamweaver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
SyKeSnr1
 
Posts: n/a

Default Checking multiple variables in URL - 11-16-2007 , 07:38 AM






Hello,

Problem is as follows:
All my pages have products linking to my detail page as such:
<a href="http://www.mysite.com/detailpage.php?ID=<?php echo
$row_Recordset1['ID'] . "&amp;Name=" . $row_Recordset1['Product'] . "&amp;Cat="
.. $row_Recordset1['Productcategorie']; ?>" class="Roze">

So, the ID, product name and products category are all successfully being sent
with a get to the detailpage. However, the detailpage ONLY uses the ID to show
the product. The other variables in the URL do not matter, e.g. both examples
now work when entering the url directly:
http://www.mysite.com/detailpage.php...me=BBB&Cat=CCC
http://www.mysite.com/detailpage.php?ID=AAA
What i want to accomplish is that the detailpage needs all thge variables in
the url, and only then it shows the product, else it should send a 404 error
page not found. I want to do this because for some reasons in the past google
indexed a lot of my products with both
"http://www.mysite.com/detailpage.php?ID=AAA&Name=BBB&Cat=CCC" and
"http://www.mysite.com/detailpage.php?ID=AAA" URL's, which means that a lot of
products keep being indexed double because both urls still work.

The sql on the detailpage now looks like this:

mysql_select_db($database_SODB, $SODB);
$query_Recordset1 = sprintf("SELECT * FROM products WHERE ID = %s",
GetSQLValueString($colname_Recordset1, "text"));
$Recordset1 = mysql_query($query_Recordset1, $SODB) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);

thanks


Reply With Quote
  #2  
Old   
bregent
 
Posts: n/a

Default Re: Checking multiple variables in URL - 11-16-2007 , 10:49 AM






I don't really understand the underlying issue. Sounds like you might want to
look into url rewriting. But to solve your immediate problem you would check
that the querystring contains values in all parameters and then redirect to 404
if it doesn't.


Reply With Quote
  #3  
Old   
Sonjay
 
Posts: n/a

Default Re: Checking multiple variables in URL - 11-16-2007 , 02:32 PM



Perhaps I'm misunderstanding, but shouldn't it be:

<?php
if (!isset($_GET['ID']) || !isset($_GET['Name']) || !isset($_GET['cat'])) {
header('HTTP/1.0 404 Not Found');
exit;
?>

The OP said he wanted ALL the variables in the URL or it should 404. Which
means that if any one of them is missing, it should 404. Which would mean
using double-pipes rather than double-ampersands.

--
Sonjay



On 11/16/07 12:21 PM, "David Powers" wrote:

Quote:
SyKeSnr1 wrote:
http://www.mysite.com/detailpage.php...me=BBB&Cat=CCC
http://www.mysite.com/detailpage.php?ID=AAA
What i want to accomplish is that the detailpage needs all thge variables in
the url, and only then it shows the product, else it should send a 404 error
page not found.

Put this right at the top of detailpage.php before anything else:

?php
if (!isset($_GET['ID']) && !isset($_GET['Name']) && !isset($_GET['cat'])) {
header('HTTP/1.0 404 Not Found');
exit;
?



Reply With Quote
Reply




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.