Jump to content

Password based on pre-defined value


thaidomizil

Recommended Posts

Hi there,

 

i'm trying to find out how i could password protect a page based on a value that has been written into my mysql db before, basically i'm having a booking system, after updating a customers booking he does get a link by e-mail with the page that shows his booking details and his id like customerpage.php?id=1, now if he opens that page, i want to prompt for the value lname1 of row id 1which would be the customers last name, before he can access the page !

 

Thanks

Link to comment
Share on other sites

Ok i just solved it myself ;)..

 

If someone needs something similar, this will do.

 

<?php
$result_id = $_REQUEST['id'];
if($_POST['Check'])
{
$lname1 = $_POST['lname1'];
$result = mysql_query("select * from booking where id='$result_id' and lname1='$lname1'");
$row = mysql_fetch_assoc($result);
if(mysql_num_rows($result)!='0')
{
	header("Location: customerpage.php?id=$result_id");
}
else
{ 
	echo "<script>alert('Invalid Last Name');</script>";
}
}
?>

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.