URL/SubDirectory Help

Okay…

This is going to be hard to explain…

I have these folders

public/applications/

applications/core

core/module

module/global

Now inside ‘module’ I have a ‘register.php’, and I have seen this on a couple sites, how do I make my URL to that register document something like…

www.site.com/index.php?application=core&module=global&do=register

to do that register link? A quick example would be IP.Board. :slight_smile:

Any help?

-Improvizionz

Well, not sure if this is what you are asking, but…

The sample:

www.site.com/index.php?application=core&module=global&do=register

Has “arguments” in the url. These are read using the $_GET[] options. Basically a form is “POSTED”, so you use $_POST[‘fieldname’], etc. But, for a URL version of this, you “GET” the arguments. So, this sample code might pull the samples you showed above in the sample URL…

$app=$_GET[‘application’];
$mod=$_GET[‘module’];
$do=$_GET[‘do’];

Notes on this… You can use ANYTHING for the arguments, but, some can get confusing. Some programmers use arg1, arg2, etc… I prefer names that make sense. Now how do you call these? You create a string something like this:
$app=“core”; // actually this would be a selection from the user, such as app, pix, whatever…
$mod=“global”; // sameo sameo…
$do=“register”;
$url=“www.site.com/index.php?application=” . $app . “&module=” . $mod . “l&do=” . $do;
Then, echo it on the page so someone can click on it. Of course that would be with the $url as part of an HREF. Something like this:
echo “Press here to go to your page!”;

This is very useful for blog’s and side-list’s of links. The user does not see the arguments, just what you type.
Hope that is what you want! Good luck…

That could work for somethings, but also if I have something like login in the same place or elsewhere on the page, it would conflict. :L I can try it, but I think other links like that could cause errors with the variables like $app. Ill give it a try. Thanks. :slight_smile:

Well, I am not sure what you really are asking. You talked about it like that is what you wanted.

You could just use SESSION variables and hide it all from everyone… That might be easier…

What exactly are you attempting to do? Perhaps a little more info might able us to steer you to the correct project ideas…

Im working on a script for pastie (how original, I know, yada yada).

Well, I am trying to organize everything into folders (pastie, core, etc) are the applicatin folders, then I divide the modules. Global, Public, Private.

Well, I don’t know what “Pastie” is…

Just saw your previous post again… I don’t think you understand…

These two links can be on one page and still work correctly:

Register page!
Login page!

And, they would be sorted out in the index.php page which would change it to the real pages…

Okay, just found out what “pastie” is… LOL… Silly use for folders, the overhead is crazy for that!
Why are you not using just MySQL??? You could do a pastie-type site in one or two days using
“TinyMCE” and a simple MySQL database. Very easy, quick and all in one folder with two or three pages…
Each “Pastie” would be one row in the database with a bunch of tags… Simple to display, etc…

Thats kinda what I was going for, I am working on the multiple pages in 1 folder, I know that.

But also, I was thinking of storing things in the database, which is what I am going to do for the pastie. But I was also looking at how I would do what others do, with the site.com/1 for pastie 1, site.com/2 for pastie 2, and so on and so forth, i was wondering how to do that.

Well, what is going to be stored in a “Pastie”???

Text? If so, easy! Something else, let me know.

In general, site.com/1 , site.com/2 , site.com/3 would just be a database with a table with the first field as the 1,2,3… Lets call the first field a “folder”, and let’s call the “Pastie” field “pastie”.

So, a simple table in the database would be something like:

ID, Folder, Pastie

When a new Pastie is entered, it is assigned an ID (using auto-increment), a folder selected by the user or your code. So, to list them back the user would click on the folder and only the Pastie’s in that folder would be listed on the screen. Since this would be done with a simple query, it would be fast and simple to code.

All depends on what data you are storing. So, what do your “Pastie’s” contain?

Well, I still don’t understan ms the whole site.com/1 etc. But these pastes would contain anything that the paster would want them to contain, codes, messages, etc. I am learning how to protect this in the pastes, but now I want to get the www.site.com/1 for pastes to work. Database would be simple to store/edit everything in case you want to fix things later unlike a PHP. Although it could be done in PHP it would take up a lot of space and create clusters in the FTP.

If you could help with the code for site.com/1 and stuff, I would appreciate it. :slight_smile:

Thanks for your help so far too.

I looked at the Pasties site again and all I see anywhere in them is just plain text! So, nothing else is there.

If that is all you want to store, just use a database. Store everything in one table with fields as I mentioned
before. If someone posts a pastie with “hello, everyone” or “234921” or “:LKJSFOPINV0dsfasf”, it does not
matter, it is just text. (you said:

would want them to contain, codes, messages, etc.

Also, you said:

Although it could be done in PHP it would take up a lot of space and create clusters in the FTP.
I have no idea what that means? If the pastie is text and stored in files, it could be messy, but, in a database, it is just one text field and is not an issue.

Perhaps I do not understand what you want help with. A second look at pastie.com shows just text. (Not really anything I can understand.) But, it is just text so do it with a database…

For pastes, you can simply enter whatever you want. Examples:

<?php

// Whatever coding they want

?>
<html>
<head>
<title>Hello</title>
</head>
<body>
<p>hi</p>
</body>
</html>

And share it or something. :slight_smile:

But now, I just need to know how to make it refer to the post ID from the database when you go to a url like www.site.com/1

Okay, I get Pastie’s… BUT, you can’t type in a site like “www.site.com/1”. You have to type in a full www.site.com/webpage.php (or .html or .asp or…)

Well, actually, you could use the .htaccess file and do a rewrite command to change it to www.site.com/index.php?id=1 or something like that. Then, you could have an index.php file that reads the id=1 with a $_GET[‘id’]; and then do whatever you want.

But, why would you want a user to type in a 1 for the page? Wouldn’t you just want them to select that page from the first page? Or, is this some secret way to hide something? I really do not understand your needs for this. Oh, well, I gave it a try…

Sorry, maybe I didn’t specify enough.

I want the pastes to be pulled from the database. Like other paste sites, I don’t want a PHP document to be made for every paste made, or else if REALLY Clutters the FTP, so to simplify this, I want it so when you goto like: site.com/1 it loads the first paste. I want each paste stored in numerical order based on ID in the database. Then when made they create the URL of “site.com/#” where “#” represents the the number that that paste is. Simply so first paste would be “site.com/1”, the fifth paste would be “site.com/5”, etc. But so that each number after is a paste made by a user. Get it?

Based upon there ID in the database, going to something like “site.com/13” will enter the database, find the Paste with ID “13”, take the paste itself, the author, etc. and display it on the page. If you don’t understand how to do this, I will understand, I think this is some expert PHP or something while I am still kinda new to PHP but have some experience.

Well, I understand what you want. It’s just you really cant do that without using server rewrites.
First, any page you type in, like www.site.com/2 , would have to be a page, not a number.
Something like www.site.com/index.php or www.site.com/paste.php,?id=2 or some other actual page.

You can get around this by using server-side rewrites. Basically a rewrite is done inside the server’s “.htaccess” file with is a simple text file. In that you can do rewrites of the files posted to the server. So, you could tell the rewrite code to take the page given as www.site.com/2 and rewrite it as www.site.com/paste.php?id=2
So, then, the user sees www.site.com/2 at the top of the page, but it would really call paste.php with an argument of “id=2”. Then, inside that code, you can process the #2 paste. Is that what you want?

If so, here are a couple links on .htaccess URL rewrites… Hope it helps…
http://httpd.apache.org/docs/current/mod/mod_rewrite.html
http://www.blogstorm.co.uk/htaccess-mod_rewrite-ultimate-guide/

Sponsor our Newsletter | Privacy Policy | Terms of Service