Jump to content

PHP/MYSQL ID REDIRECT


w00kie

Recommended Posts

Hi, I have MYSQL Rows in a table for instance :-

[a href=\"http://localhost/description?id=1\" target=\"_blank\"]http://localhost/description?id=1[/a]

now, this is fine. But what i want to do is, when a user enters an INVALID ID, which isn't a row in the MYSQL table to redirect to a different page. Or give an echo saying, this is ID is invalid.

so if someone enters [a href=\"http://localhost/description?id=09340350305035\" target=\"_blank\"]http://localhost/description?id=09340350305035[/a]

and that ID doesn't exist, it redirects

thanks in advance



Link to comment
Share on other sites

[!--quoteo(post=365978:date=Apr 18 2006, 08:04 AM:name=GingerRobot)--][div class=\'quotetop\']QUOTE(GingerRobot @ Apr 18 2006, 08:04 AM) [snapback]365978[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Use mysql_num_rows();

[code]
$sql = "SELECT * FROM `fieldname` WHERE `id`='$id'";
$result = mysql_query($sql);
$num = mysql_num_rows($result)
if($num < 1){
header("location:errorpage.php");
exit;
}
[/code]
[/quote]

thank you ever so much :)
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.