Using PHP $_GET to grab data and define content -


i want use php's $_get in url grab data define content within page.

basically, want url this-

/page.php?p=1

then, php automatically include ../content/1.txt later in code, because 1 after p=. if url /page.php?p=2, include ../content/2.txt because in url. want automatically, , within page, basic skeleton can put together, , file included in skeleton. want php automatically, instead of having define every single p= , have that.

try this...

<?php      if(isset($_get['p'])){          $filename = $_get['p'];          /* validate user input here */          $filename = "../content/" . $filename . ".txt";          //include file         include($filename);          //or echo link file         echo "<a href=\"" . $filename . "\">link</a>";          //or echo file's contents         echo file_get_contents($filename);     } ?> 

Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -