Anyone know how to insert dynamic data to a webpage?

  • giant
  • Born
  • Born
  • giant
  • Posts: 2

Post 3+ Months Ago

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
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • UPSGuy
  • Lurker ಠ_ಠ
  • Web Master
  • User avatar
  • Posts: 2733
  • Loc: Nashville, TN

Post 3+ Months Ago

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
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8399
  • Loc: USA

Post 3+ Months Ago

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...
  • spork
  • Brewmaster
  • Silver Member
  • User avatar
  • Posts: 6252
  • Loc: Seattle, WA

Post 3+ Months Ago

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.
  • UPSGuy
  • Lurker ಠ_ಠ
  • Web Master
  • User avatar
  • Posts: 2733
  • Loc: Nashville, TN

Post 3+ Months Ago

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.
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8399
  • Loc: USA

Post 3+ Months Ago

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.
  • giant
  • Born
  • Born
  • giant
  • Posts: 2

Post 3+ Months Ago

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 100 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
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.