Hello! 🙂
I do have this code, which is working fine:
<?php
$value = trim($value);
$dbh=mysql_connect ("localhost", "user", "xxxxxx") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("urls");
$Query = "SELECT * FROM redirect WHERE qs = '$value'";
$Result = mysql_query($Query) or die("Error: ".mysql_error()." in query: ".$Query);
$row=mysql_fetch_array($Result);
$url = $row['url'];
mysql_close($dbh);
header("Location: $url");
?>
The $value is from the querystring in the url.
Examples
movies -> redirect to http://www.imdb.com
Depending of the querustring the user is sent to different urls(url in the table).
The table has the columns: qs and url.
My question is, if there is no value fitting the querystring in the database the user now is for some reason sent to "index.php", is there any way to make so nothing happends then instead please?
Thanks in advance.