so I have a link, for example, http://www.mypage.com/index.php?id=green and when I click on it, I receive my id, which I needed. The problem is - I can't imagine how is it possible to check if my 'id' is valid, by which I mean that the section exists in the database (DB), because obviously someone could type http://www.mypage.com/index.php?id=mynameisjohn manually and receive a blank page, however it would be nice to tell them something like "The page that you're viewing, doesn't exist".
I added my code, however it's a simple code, I would rather say that it's just a connection to my DB.
Code: Select all
<?
if(isset($_GET['id'])) $id = $_GET['id']; else $id = 'info'; \\ this only works, if the id is empty
// this is where the actions should be
$konekcija=mysql_connect('127.0.0.1','*','*') or die ("Unable to connect");
mysql_select_db('*',$konekcija);
$vaicajums2="select * from `text` where section='$id' and `lang`='lv'";
$rezultats=mysql_query($vaicajums2,$konekcija);
$rezultats2=mysql_fetch_array($rezultats);
echo "$rezultats2[1]";
mysql_close($konekcija);
?>