Anyone know how to insert dynamic data to a webpage?

  • giant
  • Born
  • Born
  • No Avatar
  • Joined: Jan 18, 2010
  • Posts: 2
  • Status: Offline

Post January 18th, 2010, 10:55 am

Hi Everyone!

Honestly, I am not sure this is html question or a php one :) Sorry if I post it to the wrong place.

I would like to create a web page that has a dynamic data to insert from the url.

For example:
The url is : DomainDotCom/index.html?=dynamic-data

When the visitor click the above url, he/she will arrive to a web page showing:
"Welcome to dynamic-data's Page" in the content.

Does anyone can help telling how to make that?
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post January 18th, 2010, 10:55 am

  • UPSGuy
  • Lurker ಠ_ಠ
  • Web Master
  • User avatar
  • Joined: Jul 25, 2005
  • Posts: 2735
  • Loc: Nashville, TN
  • Status: Offline

Post January 18th, 2010, 11:34 am

You need a Server-side language. Since you mentioned PHP, I'll give you that.

Following your (slightly modified) example URL of:
domain.com/index.php?name=dynamic-data
Code: [ Select ]
<html>
<head>
<title>Welcome to <?= $_REQUEST['name'] ?>'s Page</title>
</head>
<body>
Welcome to <?= $_REQUEST['name'] ?>'s Page
</body>
</html>
  1. <html>
  2. <head>
  3. <title>Welcome to <?= $_REQUEST['name'] ?>'s Page</title>
  4. </head>
  5. <body>
  6. Welcome to <?= $_REQUEST['name'] ?>'s Page
  7. </body>
  8. </html>

Live example here
I'd love to change the world, but they won't give me the source code.
  • Bogey
  • Bogey
  • Genius
  • User avatar
  • Joined: Jul 14, 2005
  • Posts: 8211
  • Loc: USA
  • Status: Offline

Post January 20th, 2010, 8:03 pm

The way UPSGuy said isn't wrong, but I think that having either POST or GET method is much safer then REQUEST, since on REQUEST, it's either way, meaning that no matter what the hacker uses, it will work.

To accomplish what the original poster asked for you would replace all those REQUEST with GET, so $_REQUEST['name'] on line 3 and 6 would become $_GET['name'].

@giant: not sure that your URL example would work. It would benefit you more by doing it the way UPSGuy showed it... by actually providing the URL variable a name. It could be whatever you want... just make sure you have it changed in the PHP where you change the variable name...
"Bring forth therefore fruits meet for repentance:" Matthew 3:8
  • spork
  • Brewmaster
  • Silver Member
  • User avatar
  • Joined: Sep 22, 2003
  • Posts: 6130
  • Loc: Seattle, WA
  • Status: Offline

Post January 21st, 2010, 2:41 am

Actually, both of them are equally unsafe, since the data isn't being sanitized before being displayed on the page.

The source of the data isn't the issue; it what you do before allowing it to appear in output that matters.
The Beer Monocle. Classy.
  • UPSGuy
  • Lurker ಠ_ಠ
  • Web Master
  • User avatar
  • Joined: Jul 25, 2005
  • Posts: 2735
  • Loc: Nashville, TN
  • Status: Offline

Post January 21st, 2010, 5:59 am

Using get or post won't win any security battles - it just takes a little extra effort on the part of the person wanting access.
I'd love to change the world, but they won't give me the source code.
  • Bogey
  • Bogey
  • Genius
  • User avatar
  • Joined: Jul 14, 2005
  • Posts: 8211
  • Loc: USA
  • Status: Offline

Post January 22nd, 2010, 2:33 pm

I was just thinking that if the method is post and you use request, the person could easily change the value using the GET method... and vice versa. Not trying to say that GET is better then POST or vice versa, just saying having one option to access the variable from the outside is a little better then two options to access that same variable.
"Bring forth therefore fruits meet for repentance:" Matthew 3:8
  • giant
  • Born
  • Born
  • No Avatar
  • Joined: Jan 18, 2010
  • Posts: 2
  • Status: Offline

Post January 28th, 2010, 10:02 am

Hey Bogey, UPS Guy, Spork,

You guys are awesome. I use UPS Guy method. It is good enough to use at the time being. I will refine the codes later on.

Thanks so much for helping!

Warmly
Frank

Post Information

  • Total Posts in this topic: 7 posts
  • Users browsing this forum: No registered users and 260 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.