TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 02-24-2010, 04:07 AM   #1 (permalink)
The Acquainted
 
Randy's Avatar
 
Join Date: May 2007
Location: Your G/F's Closet
Posts: 114
Thanks: 7
Randy is on a distinguished road
Default view.php?=4aFA3a

Alright so I am working on a project (still/again) and I am stuck here again.. It is sort of like pagination but not exactly.

I want to allow the user to go to the url with a string, the string is then checked in the mysql database if it exists it pulls data from the database of the row with that info, and then have the information in the database displayed to the user on that page.

Cheers,
Randy
__________________
Real Programmers always confuse Christmas and Halloween because Oct31 == Dec25 - Andrew Rutherford
Send a message via AIM to Randy Send a message via MSN to Randy
Randy is offline  
Reply With Quote
Old 02-24-2010, 10:14 AM   #2 (permalink)
is cute and cuddly
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
delayedinsanity is on a distinguished road
Default

Where in your code are you getting stuck?
delayedinsanity is offline  
Reply With Quote
Old 02-24-2010, 11:22 PM   #3 (permalink)
The Acquainted
 
Randy's Avatar
 
Join Date: May 2007
Location: Your G/F's Closet
Posts: 114
Thanks: 7
Randy is on a distinguished road
Default

I am unsure about how to create the url and then how to get the code from that url.
__________________
Real Programmers always confuse Christmas and Halloween because Oct31 == Dec25 - Andrew Rutherford
Send a message via AIM to Randy Send a message via MSN to Randy
Randy is offline  
Reply With Quote
Old 02-25-2010, 12:36 AM   #4 (permalink)
is cute and cuddly
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
delayedinsanity is on a distinguished road
Default

This page would be a good starting point for reviewing the material you need to understand for this type of situation. In particular read the section immediately following Example #2.

Just to summarize, your query string is based on key->value pairs, and is considered a GET request. PHP automatically stores all values it finds in either a POST or GET request in similarily named superglobals, such as in your case $_GET.

To apply a GET query string, you're going append a question mark, followed by the key->value pairs, such as http://mydomain.com/mypage.php?key=value&this=that (multiple key->value pairs are appended with an ampersand). From within PHP you can access these with $_GET['key'], which would for the previous example return 'value', or $_GET['this'] would return 'that'.

From there, your options are wide open to interpret the values and act upon them.
delayedinsanity is offline  
Reply With Quote
Old 02-25-2010, 04:44 AM   #5 (permalink)
The Acquainted
 
Randy's Avatar
 
Join Date: May 2007
Location: Your G/F's Closet
Posts: 114
Thanks: 7
Randy is on a distinguished road
Default

That looks like it will work for getting the data but then how do i create that url.

I am unsure how to create the url:
http://mydomain.com/view.php?view=3fa5D
__________________
Real Programmers always confuse Christmas and Halloween because Oct31 == Dec25 - Andrew Rutherford
Send a message via AIM to Randy Send a message via MSN to Randy
Randy is offline  
Reply With Quote
Old 02-25-2010, 05:10 AM   #6 (permalink)
is cute and cuddly
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
delayedinsanity is on a distinguished road
Default

Well I can't code the whole thing for you, so you're going to have to help us by explaining the sequence of events that you're planning for, and what you've accomplished so far codewise.
delayedinsanity is offline  
Reply With Quote
Old 02-25-2010, 04:11 PM   #7 (permalink)
The Acquainted
 
Hightower's Avatar
 
Join Date: May 2009
Location: Durham, UK
Posts: 134
Thanks: 9
Hightower is on a distinguished road
Default

Surely it's just a case of creating a random string using the relevant function, and then quickly checking if that string exists in the database. If it does the random function runs again and checks. If it doesn't already exist in the database then you have your random string to insert into for that record?
__________________
Hightower's Softpolio
Send a message via MSN to Hightower
Hightower is offline  
Reply With Quote
Old 07-25-2010, 08:19 PM   #8 (permalink)
The Visitor
 
Join Date: Oct 2007
Posts: 3
Thanks: 2
EHJamie is on a distinguished road
Default

Hey

You've probably solved this by now, but anybody else looking for the solution, just thought I'd post what I'd do..

Code:
<?php

	/* 
		Examples of how to access these pages:
		
		Call pages by url.php?action=new
		Call pages by url.php?action=edit
		Call pages by url.php?action=delete
	*/

	$page = htmlentities(trim($_GET['action']), ENT_QUOTES);

	switch($page){
		
		// What shows by default if not ?action chosen
		default:
		
			// HTML or code in here to view...
		
		break;
		
		case "new":
		
			// HTML or code in here to view...
		
		break;
		
		case "edit":
		
			// HTML or code in here to view...
		
		break;
		
		case "delete":
		
			// HTML or code in here to view...
		
		break;
		
	}

?>
EHJamie is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 09:46 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design