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
https://forums.phpfreaks.com/topic/239309-password-based-on-pre-defined-value/
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>";
}
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.