PDA

View Full Version : how to produce link /review/thank-you instead



luvvips
17 Feb 2010, 05:52 AM
Hi,
I am newbie in php script and learning day by day.
My site is on php script, I am having the problem when I am rewriting rule .htaccess.
I have review database of my customers and I am randomly generating 5 reviews from database for e.g.
$nav = '';
// print the random numbers
while($row = mysql_fetch_array($result))
{
echo '<strong>' . $row['reviewwriter'] . '&nbsp;&nbsp;(' . $row['country'] . ')</strong><br>';
echo '<i>"' . $row['reviewtitle'] . '..."</i><br>';
$page = $row['page'];
$nav .= '<a class="read" href="http://www.testsite.com/review.php?page=' . $page . '">read more</a>';
echo $nav. '<br><br>';
$nav = '';
}
... Here page = pageurl in db.
When we click on "READ MORE" ... It goes to review.php page which looks like ...
review.php?page=thank-you-for-making-everything-easier-for-us
Everything is fine here, all the review I can see whenever we click on any review 's read more. But here are the problems...

1. Security ... How to check this page is in url or not? Here is my code below, but it is not working properly.
if (!isset($_GET['page'])) {
$page = 'home';
}
else {
$page = $_GET['page'];
}
Here Home means the ID=1 data in database, which is review page data. And it shows the Review.php

2. I have made Internally rewrite requests for reviews URLs to php scripts
RewriteRule ^review/(.+)/$ /review.php?page=$1 [L]
which is not working at all.

How can I alter my script so that the links produced on the pages look like href="/review/thank-you-for-all-you-have-done-for-us" or href="/review/thank-you-for-making-everything-easier-for-us" etc ?

Thanks!