Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1]   Go Down

Author Topic: PHP Question  (Read 1748 times)

0 Members and 1 Guest are viewing this topic.
PHP Question
« on: April 26, 2008, 10:01:45 pm »
  • :'O
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 929
How do you make your pages all like

http://website.com/?page=5

Do you have to use MySQL?
Logged
Re: PHP Question
« Reply #1 on: April 26, 2008, 10:18:50 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 531
How do you make your pages all like

http://website.com/?page=5

Do you have to use MySQL?
No, just a if statement on the variable.
Logged
So give me you're code and add mine:
Code: 4296-2644-3642

Sorry guys.  I just don't have the time anymore for the CP.  Working two jobs and just having a couple hours to play my Wii and continue learning programming just is not leaving me free time to focus on the CP.  I feel that it's my obligation to step aside as Level Director.  It's just a time issue.  Since I am also a global mod that also takes some of my focus from the CP.  So, it's nothing against anybody or what not, I'm just out of time anymore it seems.  Sorry again.
wtf, i remember posts that used to have content explaining reasons rather than ways to get rises out of users with a youtube video and no reason as to why!


How to post maturely:
epic intolerance, I caught aids from the stupidity in your post

why not issue everyone 5 opinion tokens for each year, if they voice their opinion without presenting a token- they can be legally murdered
Make sure every post you make is mature like these two (and there's many more). You just can't beat ZFGC's friendliness and maturity!
Re: PHP Question
« Reply #2 on: April 26, 2008, 10:23:10 pm »
  • *
  • Reputation: +3/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6629
Code: [Select]
if (isset($_GET['action']) == false)
{
// The ?action=xxx variable is not set so just show the homepage here.
}
else
{
// Work out what page we want to go to by looking at the ?action=xxx variable.
switch ($_GET['action'])
{
case 'home':
// Show homepage here.
break;
case 'forum':
// Show forum here.
break;
case 'help':
// Show help here.
break;
}
}

Quick crappy example.
Logged
Re: PHP Question
« Reply #3 on: April 26, 2008, 10:26:56 pm »
  • :'O
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 929
Edit: NVM I got it down

Seriously thanks man I would have never figured this out
« Last Edit: April 26, 2008, 10:30:04 pm by Jigga Man »
Logged
Re: PHP Question
« Reply #4 on: April 26, 2008, 10:45:38 pm »
  • :'O
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 929
Now that you mentioned it that does seem like a really crappy way to do it. I would have to have that on every page wouldn't I? Which means I cannot change just 1 thing and add it to all the pages.

How would I make it easier?

I understand I could work with the code but it just seems like there is an easier way to do all of this. Because if I wanted reviews couldn't I make a function that finds a file such as "review-0001.dat" then prints the contents in a certain are of the page?

Code: [Select]
...
<body>
<a href="?action=home">Home</a> | <a href="?action=forum">Forums</a>
<?php echo $recentnews?>
<!-- Start Area that changes -->

Here is where the different content would be displayed as nothing else changes on any page

<!-- End Area that changes -->
<?php echo $copyright?>
</body>
...

I mean I would have to have

case '0001':, case '0002', etc...
Logged
Re: PHP Question
« Reply #5 on: April 26, 2008, 10:54:10 pm »
  • *
  • Reputation: +3/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6629
Oh right, sorry I was assuming you wanted to know how to move between pages of a website using url variables (which is done in that way, using sub-url-variables to define extra settings like files to view, eg. ?action=viewfile&file=myfile.txt). If you want to emit large datasets of information there are obviously easy ways to do it. You way of checking for the file and emitting it is a good idea (obviously you want to limit what files they can access or they may trick your scripting into emitting the source code for your website, or something stupid like that), althrough using a MySQL database is a better idea.

But either way if you wanted to do that, you could do it like this;
Code: [Select]
if (isset($_GET['action']) == false)
{
// The ?action=xxx variable is not set so just show homepage here.
}
else
{
// Check if our file exists (huge security hole here, you can emit pretty much any file on the server, you need to validate the url first).
if (file_exists('MyStorageDirectory\' . $_GET['action']) == true)
{
echo file('MyStorageDirectory\' . $_GET['action']);
}
else
{
echo 'File dosen't exist.';
}
}



If you can give me a more exact view of what your intending to do I may be able to help better.
« Last Edit: April 26, 2008, 10:56:14 pm by Infini »
Logged
Re: PHP Question
« Reply #6 on: April 26, 2008, 11:04:40 pm »
  • :'O
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 929
Here
« Last Edit: September 03, 2014, 12:59:56 am by Oni_Link »
Logged
Re: PHP Question
« Reply #7 on: April 26, 2008, 11:15:31 pm »
  • *
  • Reputation: +3/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6629
I'll explain over IM.
Logged
Another PHP Question
« Reply #8 on: May 02, 2008, 11:33:08 pm »
  • :'O
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 929
New Question!
How do you have PHP generate an image with text in it?
Logged
Re: Another PHP Question
« Reply #9 on: May 03, 2008, 12:42:35 am »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 256
New Question!
How do you have PHP generate an image with text in it?

Quote from: google
http://ranacse05.wordpress.com/2008/03/24/convert-string-to-image/
Logged
  • My Myspace?
Pages: [1]   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.025 seconds with 73 queries.

anything