Password protected page

5 posts by 2 authors in: Forums > CMS Builder
Last Post: November 1, 2010   (RSS)

Re: [fleff] Password protected page

By Jason - October 29, 2010

Hi Farnham,

I think the problem is in this line here:
<form action="/land_info.php" method="post" name="pwd">

This sends the form to land_info.php but doesn't append anything else to the url string.

So, the question is, how do you know on the page with the form which listing you want to view?

Let me know and I can try to help you out.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Password protected page

By fleff - October 30, 2010

Thanks, Jason. I agree with you that the problem lies with the line you cite. That is the line where I want to add the record number of the listing I am looking at.

On my land_details.php page there is a link to the page land_info.php that is to be password protected . That link, which works if no password requirement, looks like this:

<div align="center">
<?php if($record['field_card']):?>
<a href="land_info.php?<?php echo $record['field_card'] . '-'. $record['num']; ?>" border="0" class="agents_12b">(o)</a><br />
<?php endif ?>
</div>

At the very top of the land_info.php page I add this line of code to require a password before that page opens:

<?php require_once('microProtector.php'); ?>

It calls the Micro Protector script that I show at the top of this forum question that generates the password form that I would like to have take the user to the page land_info.php plus the record number for that listing.

The php code in the Micro Protector:
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="pwd">

only picks up the URL as far as the .php extension and leaves off the record number that I need there for that particular listing. Otherwise it goes to the first record.

I tried adding the record number this way, but it didn't work.
<form action="<?php echo $_SERVER['PHP_SELF'] . '-'. $record['num']; ?>" method="post" name="pwd">

I am new to php and am hoping there is some way to get this to work. Or is there a better way?

Farnham


Re: [fleff] Password protected page

By Jason - November 1, 2010

Hi Farnham,

$_SERVER['PHP_SELF'] will give you the file that you're executing, but it won't append the query string.

Try this line instead:
<form action="<?php echo $_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING']; ?>" method="post" name="pwd">

Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Password protected page

By fleff - November 1, 2010

That did it, Jason! Thanks again for your great support.

Farnham