General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old September 11th, 2002, 05:13 PM
eokorie eokorie is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 10 eokorie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 m 53 sec
Reputation Power: 0
Send a message via ICQ to eokorie
Question Parsing URL + Form parameters

I wrote the code below so as to allow a user to choose variables he wishes to parse on a website. He could either choose not to parse any, parse a URL parameter, a form paramater or both parameter.

I would like the code when run to display something like:

http://localhost/testme/test.php?ex...ategory=actions

Am I on the right path with the code below or is there something wrong with it?

Can anybody help me out?

Thanks,

Emmanuel Okorie
PHP Rookie

PHP Code:
<?php require_once('../Connections/GKaosCONN.php'); ?>
<?php
mysql_select_db
($database_GKaosCONN$GKaosCONN);
$query_Recordset1 "SELECT * FROM extensions";
$Recordset1 mysql_query($query_Recordset1$GKaosCONN) or die(mysql_error());
$row_Recordset1 mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 mysql_num_rows($Recordset1);

$ParamID "";
?>

<?php

$Remove_List 
"&index=";

if (
$ParamID != "")
{
  
$Remove_List $Remove_List "&" $ParamID "=";
}

$KeepURL "";
$KeepForm "";
$KeepBoth "";
$KeepNone "";

$Page_Item "";
$Next_Item "";

foreach (
$HTTP_GET_VARS as $Page_Item)
{
    echo 
"&" $Page_Item "=";
    if (((
strpos(1$Remove_List$Next_Item,1) ? strpos(1$Remove_List$Next_Item1) + 0) == 0))
    {
      
$KeepURL $KeepURL $Next_Item rawurlencode($HTTP_GET_VARS[$Page_Item]);
    }
}

foreach (
$HTTP_POST_VARS as $Page_Item)
{
      echo 
"&" $Page_Item "=";
    if (((
strpos(1,$Remove_List,$Next_Item,1) ? strpos(1,$Remove_List,$Next_Item,1)+0)==0))
    {
          
$KeepForm $KeepForm $Next_Item rawurlencode($HTTP_POST_VARS[$Page_Item]);
    }
}

// create the Form + URL string and remove the intial '&' from each of the strings
$KeepBoth $KeepURL $KeepForm;

if (
$KeepBoth != "")
{
  
$KeepBoth substr($KeepBothstrlen($KeepBoth)-(strlen($KeepBoth)-1));
}

if (
$KeepURL != "")
{
  
$KeepURL substr($KeepURL,strlen($KeepURL)-(strlen($KeepURL)-1));
}

if (
$KeepForm != "")
{
  
$KeepForm substr($KeepForm,strlen($KeepForm)-(strlen($KeepForm)-1));
}



function 
KeepChar($mainItem)
{
   
extract($GLOBALS);
   if (
$mainItem != "")
   {
    
$mainItem "&";
   }
  else
      {
    
$mainItem "";
    }

  return 
$mainItem;
}

?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<p>
<p><A HREF="test.php?<?php echo $KeepURL KeepChar($KeepURL) . "ExtID=" $row_Recordset1['ext_id'];
  
?>"><?php echo $row_Recordset1['extName']; ?></A> </p>
</body>
</html>
<?php
mysql_free_result
($Recordset1);
?>


Edit: Please read the rules before posting

Reply With Quote
  #2  
Old September 17th, 2002, 08:26 PM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
What errors are you getting?

Reply With Quote
  #3  
Old September 18th, 2002, 05:20 AM
eokorie eokorie is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 10 eokorie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 m 53 sec
Reputation Power: 0
Send a message via ICQ to eokorie
Re:

I don't seem to be getting any error but then instead of parsing the url and form parameter, nothing shows up... i only get some like:

http://localhost/testme/test.php?

it does not display anything else after the test.php?


could there be something wrong with the code itself?

Thanks for replying Ben,

Emmanuel

__________________
Good Things Come To Those Who Wait!!!

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Parsing URL + Form parameters


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway