Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Creating Dynamic URLs


I feel dumb having to ask this question in the first place, but I just
can not figure it out. I am wanting to set my site up using dynamic
urls (I'm assuming that's what they're called, an example of what I
have in mind is index.php?page=[pagename]). However, I can not figure
out how to do this. I will eventually want to use SEF urls, but for now
I'll be content just to have the dynamic urls. If anyone can tell me
how to do this,




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Creating URLs
I'm having problems creating urls when taking info from a mySQL table. For example a table with user_id, name, email and description. Then you've set up a template there this information will be displayed. You have this information in the database:

user_id: 1
name: myname
email: myname@myemail.com
description: information about me

Now in this template it should create an URL for this info that looks something like: www.myhost.com/page.php3?id=1

when they click on this link, another page will popup by using a second template with the name, email, description etc.

Dynamically Creating URLS Based On User Input !
I am looking to create pages on the fly or dynamically based on user input. For example if i have www.example.com and they visit this and enter 'bob' in a textfield and press submit they create www.example.com/bob.html . How would I go about this ? I am guessing I need to create a folder when submit is pressed in my website directory ?

Mod_rewrite - Changing Dynamic Urls For Search Indexing
is it worth it? or will search engines other than google soon come around and start indexing past the '?' symbol ?

Creating Dynamic Graph?
I know nuts on this area but I know PHP have a module that can create a dynamic graph based on the data fetched by the database.

Can anyone guide me with this technology? I don't even know where to start -- but I heard that it start with some 'GD' letters.

Any suggestion & help would be much appreciated.


Thanks.

Creating A Dynamic Include
I am trying create an include ( ) string built from user defined variables. PHP Code:

Creating Dynamic ANCHORS !
I'm developing a system where i'm uploading Profiles of different
famous persons. Now i need to create ANCOHORS inside the page so that
i can jump to different sections form the top of the page, all my data
are coming from the database. My main page is a dynamic page, which
comes depending on the Profile Id (GjProfId). and inside that page I'm
trying to call these Anchors. All these are the different parts of
that profile. lets say- Birth, Childhood, Education, Working Life,
Achievements, Death these are some section to display. I want to
display all these as links at the top of the page and make anchors to
the sections where they are in the page. I hope i could make myself clear!

The top links are created nicely but when i click them it does not
navigate to the section in that page. Say, i want to go to "education
" who's ID is 108, in the address bar I get some location like ::
http://localhost/gj_new/pagelink.php?GjProfId=5#108 (This page is
Dynamically generated ofcourse)

I tried one idea -- I had put the link in the different Titles of
sections and then put a NAME Anchor by that Title name near the main
Section. but it is not working. (This matter works in Static pages.)
here is a sample of my code....

$sql="SELECT * FROM gjprof WHERE GjProfId='$GjProfId' ORDER BY GProfId
ASC";
$resultlnk=mysql_query($sql);
while($rowlnk=mysql_fetch_array($resultlnk))
{
$GProfIdlnk=$rowlnk['GProfId'];
$GjProfHeadinglnk=$rowlnk['GjProfHeading'];

<a href="#<? echo $GProfIdlnk ; ?>"><? echo $GjProfHeadinglnk; ?></a>

Some other stuffs ........... .. .. . . . .. ...... ... ..........and
then the anchor beside the Main Heading of the Section .......

<a name="<? echo $GProfIdlnk;?>"></a><? echo $GjProfHeading; ?>

Will someone please help me with it!

Creating Dynamic Variables
I'm trying to pass 100 variables (named gain1, gain2...gain100) from a swf to a php file then write these variables to a text file.  Sending the data works fine. 

I just need help creating the variables in the php file.  Since all the files have partly the same name, I was hoping to create the variables dynamically.  I was hoping to do something like this:

$myFileName = "myfile.txt";
$myFileHandle = fopen($myFileName, 'a') or die("can't open file");

for (i=1; i<100; i++) {
$gaintext + i= $_POST['gaintxt1' + i];
fwrite($myFileHandle, $gain + i);}

However, this isn't working obviously. 

Creating Dynamic Forms
I am trying to create a form will populate and display in real time.
For example:

Ln 1. Name: [ ] Sex: [/] Favourite Sport:

Creating Dynamic Drop Down Menu
I have a mysql database called Auditions with a table called Sept7. The table has two columns Time and Name. I want to create a dynamic pull down menu and populate it with items pulled from the table based on a query. Code:

Creating Dynamic Hyperlinks With User Id's In Php Query
Im dabbling with PHP and trying to write a new search.php file to scan for specic users in my dating website and then display the users along with individual links to their profile.

$profile = $row["id"];       -- this field takes profile ID from mysql database
The profile field pulls in an ID field from a mysql database for each record. I need to integrate this fields value into the hyperlink when the results are returned so it has a list of all users each with an individual hyperlink to their profile. Then users can click and access the profile of a specific user. Code:

Creating "dynamic" Links
I am creating a directory of local business where I live and need some help on the navigation I want to build for the site.

How it works:
I have 8 categories at the top of the page (Dining, Bars, Entertainment, etc).  When a user clicks on say the Dining button, it loads client_list.php and lists all businesses under that category.

Then on the left it loads a list of the sub categories (Pizza, Chinese, Fast Food, etc).  I have all that working, but what I want to do is when a user clicks on one of those side categories it loads a page called client_filter.php and loads only the businesses under that sub-category (say all the businesses under Pizza).  Now I have that link code partially done: client_filter.php/?category=$category_num&

but how do I code in the sub_category id number so that is only displays the Pizza places.

If any needs to see any of the other code just let me know.  Just don't want to show to much for security and such.

URLs
I'm trying to set something up where I will need to get some information from a page of links. there will be an html page with a list of links and names next to them. I need to search for certain names and if they are found, I need to go save that page's URL in a file. I'm experienced in java so I know how to set up all the condition statements, what I don't know is the syntax to doing this.. the URL part.

SEF URLs
I have finally got the spaces to replace with - in php but although the page now links there seems to be no output here if I remove the - and put in %20
the page comes up fine it also work with using + instead of space

can someone please help with this MYSQL coding or maybe soemthing in htaccess needs to be defined? Code:

Get All URLS From A Page
I'm creating a little function, something like this:

Transforming URLS
I ran across an article a while ago explaining how to convert page.php?page=hello to page.php/hello for better search engine indexing. Can anybody point me to this article?

2 Passwords.2 Different URLs?
Did a search on Google regarding a login form where 2 different passwords can take you to 2 different URLs in the site but the script I found had some bug in it.

So I don't if it's possible or if it's just a script bug.

This is code, let me know if you see where the bug is....

Simple URLs
I want to have a lot of control over my short urls. My site has guitar lessons and articles and I want to have short urls of the form:

mysite.com/guitarlessons-scalelesson.html

The original url is of the form:

mysite/modules.php?op=modload&name=mainlessons&file=index&req=view_fulllesson&lessonid=8

In this case $lessonid 8 refers to scalelesson. All short URL examples I have seen take the original URL and directly translate it. In may case, the short URL scheme would have to query the database. I would like my forum to function similarly. That is, forum posts and forum pages would have forum category and post title in the short URL. Anyone know how to do advacned simple URLs of this sort?

I really like how this forum does short urls actually. I can't imagine this is done with mod_rewrite() since the simple urls appear to be generated dynamically based on database calls.

Strange URLs

I administer a large site mainly consisting of php pages. Error messages are handled by custom pages, which also email me the essential problem so I can fix navigation and other problems.

For the past couple of weeks we keep getting Error 404 messages indicating that 'strange' page addresses are being requested from links within other pages of the site. For example:

/%E2%80%9Dsupport.php

Has anyone please got any idea what the '%E2%80%9D' might be and how it could be creeping in?

Clean Urls
I'm looking for a way to come up with clean urls like
http://www.mysite.com/products/233 instead of
http://www.mysite.com/products.php?pid=233 without having to rely on
mod_rewrite or other server-specific solutions.

URLs And Preg_match (again)
I found a thread that out from a while back (Oct 9, 2002) to
give me this pattern:

`(((f|ht)tp://)(([^@:]+)([^@]+)?@)?([^:/])+(:d+)?(/[^s]+)?)`i

all is well and good with this until the URL is used at the end of a
sentance. I am assuming that I will need a negative lookahead somehow,
but I just can't wrap my mind around this one...

Want to match only the URL...

$string="... http://www.example.com.";
$string="... http://www.example.com/.";
$string="... http://www.example.com/page1.html?";
$string="... http://www.example.com/info.php?id=4!";
etc...

The pattern above is pulling the last character from each string when I
don't want it. Unfortunately, the URL can be _anything_ valid, and I
don't have control of how it will be input.

Add Parameter To All URLs
I am trying to make something similar to citysearch.com. For example:

If you search for a city, say Raleigh, NC, it will find it for you,
but then all other URLs on the page will have the location parameter
attached. For example, say "city=raleigh" So, if you go back to the
home page, or any other page on the site, that will still be attached to
the URL. Is there any easy way to do that? I know PHP has a way to
automatically attach a session ID to every URL.

Is there a way I can attach a parameter of my own choosing automatically?

I don't think cookies will work in this situation. The problem with
cookies is that there is only one cookie with one location in it, where
the user may have several pages open for different locations.

Regex And URLS
What I am looking to do is parse a string, looking for certain words, and if they are in a url, then ignore them, and if they are not a url, to turn them into one.

example:

if the word is test...

<a href="index.php">test</a> //This would get ignored.

test // This would get turned into a link, link <a href="glossary.php?term=test">test</a>

How To Use Sessid On Urls
I am new to PHP and I am building a website for fun. I have experience some problems with it. When I dont have my cookies enabled, I can't access the webpages that require authentication. Thus, I am thinking of using PHPSESSID to solve the problem. But, then I dont know how. So, I hope someone can give me some hands. Code:

Grabbing Urls
user lands on page with info from url. ie: /page.php3?123456

How do I retrieve the value and place in a variable? ie: $reffString = ??'

Getting Urls Of The Site
Say if I have a website xyz.com for example, and it has 5 static pages, how do I get the urls of 5 pages using PHP? Sure, I know how to get the url of first page which is http//www.xyz.com, then I need to get 4 urls of the remaining 4 pages without knowing what they are.

Rewriting URLs
here's my problem. On my pages I have URL souch as these
"page.php?id=2&subpage=3&param=65". For security reasons I would like to add
another parameter. It would be created like this
md5($param1.$param2.$some_constant). I would then add that MD5 string to my URL
and stop users from altering URL manually.
I would like PHP to rewrite all my URLs in a page adding this string to each
URL. I thought that I can pass a custom function to the session URL rewriting
but I cant it just adds the session ID. I know about
output_add_rewrite_var('var', 'value'); but the $value is fixed and in my case
it should depend on the specific URL being rewritten.
I know I could cache all my output and then write a regular expression to
rewrite URLs but that just seems slow and wrong :-)

Simpler Urls
I want to have urls that work like the php.net pages where there's just
a word after a slash, maybe a few folders deep. Right now I've got urls
& code like this:
http://www.edgehill.net/1/?SC=go.php&DIR=California

But I'd prefer:
http://www.edgehill.net/California

<?php
function chk_screen(){
$default_screen = 'home.php' # the default screen
if(isset($_REQUEST['SC'])) {
if(is_file(SCREEN_DIR . "/" . basename($_REQUEST['SC']))) {
$SCREEN = basename($_REQUEST['SC']);
} else {
$SCREEN = $default_screen;
}

if($SCREEN == 'main.php') {
$SCREEN = 'home.php'
$_REQUEST['SC'] = $SCREEN;
}
} else {
$SCREEN = $default_screen;
}
return $SCREEN;
}?>

Grabbing Urls
Is there anyway of me grabbing the previous link the user has been on ? Say for example the user was on www.awebsite.com and then clicks my link through that site, is it possible for a script or something to grab the www.awebsite.com url ?

XML Parser Breaking Up URLs
I'm having a problem parsing an xml file in which one of an elements character data is a url which contains multiple "&" characters. For some reason the parser breaks up the data into multiple pieces. For instance, when I call this function(abbreviated):

function characterDataHandler ($parser, $data)
{
global $element;
global $url;
if ($element == "URL") {
$url = $data;
echo "url=".$url."<br>";
}
}

I get some output like this:


url=http://www.somewebsite.com/index.jsp?s=af

url=&

url=filter=1

url=&

url=show=all


Do urls with querystrings have to be handled differently then regular character data?

Masking Variables In URLs
When I pass variables to a new page, my URL string becomes impossibly long. I'd
like to hide the variables in the URL. How would I do that?

Retrive URLs From Webpage
How can you get urls from a webpage? For example, there's 15 links on a page and you want the last 13 links and store them into an array like $array so I can use them later.

Handling Special URLs In PHP
I'm creating a classified ad site where each ad is identified by a
number - say 234563. The user wishing to view the ad will something
like this -

http://www.abcclassfieds.com/234563

I want this url to be redirect to a php display page say -

http://www.abcclassfieds.com/showad.php?adid=234563
How does one do this?

Preg_match Function For URLs
Below is a function I've written for validating URLs.

function isURL ($string, $fieldname)
{
if(preg_match("/^[http://www.|www.][S]+$/", $string))
{
return TRUE;
}
else
{
$this->number_of_errors++;
$this->error_message_list[]="The " .$fieldname. " is not a valid URL.";
return FALSE;
}
}

However I keep getting the error message:
Warning: preg_match() [function.preg-match]: Unknown modifier '/'

This is the code that I call it:

if ($testValidate->isURL($testString11,"String 11"))
{
echo "The string <b>".$testString11."</bpassed.";
}
else
{
echo "The string <b>".$testString11."</bfailed.";
}

What have I obviously missed?

Protecting Dyanmic Urls?
I have a question and nobody seems to want to help me. I want to make dynamic urls for my site http://www.example.com/index.php?module=staff

however if i do it the easy way hackers can put in (http://www.example of a bad site.com) for example. (http://www.example.com/index.php?module=http://www.example of a bad site.com)

I dont want that to be possible so how would I go about preventing that on my server so I dont have problems with my Network Admin.

I dont want to have to have a list, I just want to beable to check for specifc characters like http:// and then have them removed and then it try and display the page but cause a 404 error or tell them NO DIRTY SITES. It would be much better to have the 404 but anwayz, how would i go about checking for and removing http:// from the query!?

Preg Replace And URLs
Hi, I'm having some problems with my URL-code, which automatically turns adressess into urls.

Problems is that when people type "something.something else" that's also turned into an url.

So what I'd like to do is change the below expression to only turn it into urls when you type either "www" in front (www.google.com) or when you use "http://" (http://google.com,http://www.google.com).

$text_s = preg_replace("/(?<=^¦s)((https?¦ftps?)://)?(([-_a-zA-Z0-9]+.)+)([a-zA-Z0-9]{2,6})(/[^][s]*)?(?=s¦$)/e","'$1'!=''? '<a href="$1$3$5$6" target="_blank">$1$3$5$6</a>':'<a href="http://$3$5$6" target="_blank">$3$5$6</a>'",$text_s);

Mysql, Php And Erratic URLs
i have db with text field contents links
<A href="http://www.in.world" target=_blank>In.World</A>,
After system upgrading links appears as:
http://www.my.server/"http://www.in.world/" in MSIE (Win),
and:
http://www.my.server/"http://www.in.world" in Mozilla (Lin)
Before upgrade all was correct.
my system is now:
Linux MDK 2.4.18, glibc 2.2.4, MySQL 3.23.52, php 4.2.3, Apache 1.3.26

Replacing Words With URLs
I have built a script that searches out words in a glossery of a string and links it to the word in the glossery. by doing this...PHP Code:

Invalid Characters In URLs
I'm trying to develop my own sitemap generator. If I have a (1 quarter) symbol in the URL to be generated, I need to convert the symbol to a URL friendly equivalent. Previously, the 3rd part sitemap generator converted this symbol to &#188; yet I can only convert to &frac14; using htmlspecialchars/htmlentities which Google rejects.

Passing Arrays In URLs
Passing Arrays in URLs. I.e passing arrays between two pages. This has been delt with here before but I can't help feeling there is a better way. The two current options are:
serialize and urlencode .... then ... urldecode and unserialize OR implode ... then ... explode But if you create a form with a multiple select in it like so:
<SELECT NAME=selectname[]> etc

.. the array $selectname appears automatically in the backend when the form is submitted. Note that $selectname is an array. This means that php must automatically create arrays from data POSTed in a particular format.

If we could pass an array in this format in a url or a hidden form then we wouldn't have to do anything on the recieving page. Anyone know what this format is?

Passing Session IDs In URLs
I am going to replace my code that uses cookies with code that passes the session ID along in the URL for greater compatibility. I have seen a bunch of examples of how this works in straight HTML code, as in <a href="testing.php?<?=SID?> ">asdf</a> and that seems to work fine for me.

Unfortunately, most of my links are within PHP code, so I need to know how to place these into the URLs in the PHP code. I'm sure it's just a variable or something I just didn't see it while scanning thru the sessions intro on php.net.

I suppose the thing I would really like to do is re-compile php with the --enable-trans-sid flag but I can't make it compile, I guess it's having problems with apxs but I have apache installed. It's a pretty stock RH7.1 system so maybe if anyone has helpful hints on getting PHP to compile those would be appreciated as well.

Trapping File_get_contents For Bad Urls
I've got a section of code that takes a user supplied $url and
essentially does:
function redirectRequest($url) {
$resultRemote = @file_get_contents($url);
return $resultRemote; }

Is there a reasonable way to trap for and differentiate between the
major (most common) types of failure?

For example, common scenarios in which I would not get back a desired
response include: malformed url, the domain can't be mapped (ie. the
DNS servers don't return an IP address), the domain is not reachable,
the directory or file is not found, standard HTTP error response
header.

I'm sure it's been solved many times over, but my searches didn't lead
me to substantive results. My initial attempt only captures the fact
that there was a problem, but not the nature of it:

function redirectRequest($url) {
$oldTrack = ini_set("track_errors","true"); // allow $php_errormsg
to be set
$php_errormsg = ""; // initialize; will be set
if error with next line
$resultRemote = @file_get_contents($url);
ini_set("track_errors",$oldTrack); // restore setting
if ($php_errormsg) return -1; // this site had a problem
return $resultRemote; }

Fastest Way To Read URLs.
I would like to know what is fastest way to read contents of web page? I would like to know what possibilities are there. Currently with "file_get_contents()" reads around 10-13 pages in 30 seconds (Default max execution time). I know I can change max execution time so it can read more pages but I would like to find another way if it is possible...

Also I would like to know is it possible to print out the results while still loading page? Maybe it is browser(my settings), php setup or script fault so I'm not sure.

SEO Friendly URLs Without .htaccess
I want to display search engine friendly URLs, but I don't have access to a .htaccess file (Yahoo!, what the heck?!?!?). Is there another way? If so, can anyone point me in the right direction?

Accessing Urls With Fopen
I'm having trouble accessing urls from a remote server. For example:

<?php
$myFile = "http://www.google.com";
$c = fopen($myFile, "r");
echo $c;
?>

This times out. I'm not sure how to configure a wrappers to allow or disallow reading from urls. I'm brand new to php, and I've spent a couple hours surfing, trying to figure this out.

Hiding The Urls Of Your Php Files
Is there a way to hide all urls like masking them so that instead of:

www.name.com/code.php

it'll be www.name.com

similar to when you are on a flash website and the url remains the same but your going to many pages .. ?

Reason i ask is i have like thousands of pages and i have a feature whereby if the user is locked they cannot access the pages until they are unlocked.. but to put a script on all of these pages would be the last case scenario, if i could remove the url showing the entire name, they can't know what to type into the url to avoid this locking feature.

Personalized Urls Like Myspace
Here's what I'd like to do: create a personlized url on a directory site like: http://www.somesite.com/myurl

Now, obviously, you could make a folder for each person, but after a shorty time, this really clogs up your site's root. What I thought might work was capturing the $PHP_SELF and querying the database and redirecting. Does anyone know a sure way to do this or can point me in the right direction? 

Mail() > Strip_tags() But Keep The Urls
ok i've got a php mail function. Sends as html + plaintext. It's all working fine except for the fact that the email has links inside it. I'm using strip_tags to generate the plaintext version, so it just removes all the urls that I need in the email.

HTML Code:

<a href="http://www.bbc.co.uk">beeb</a>

becomes

HTML Code:
beeb

I've googled for ages and searched through php.net with no results... Does anyone here by any chance have any idea how to maintain the url part of the <a> tag before stripping it?

Pcntl_fork & Grabbing Multiple URLS
I would like to be able to open multiple Web sites simultaneously. I know that some programming languages support opening multiple files, for example, C++. Is there a way todo so in PHP, perhaps using pcntl_fork or some other method?
Ideally, I would like to be able to open up to 30 plus Web sites using a query string.

At the moment, it takes 5 to 8 seconds for each Web site to open using fopen, and then to read so me data from each
site using fread.

Searching External URLs For A String
I'm looking to use php to search an external HTML page for a certain
string that will occur the same way across many pages. Is there a
built-in function that I can use to search an external HTML page for a
string and store it in a variable?


Copyright © 2005-08 www.BigResource.com, All rights reserved