Buy Now
Sign in

Password Protect a Page?

ozneil , November 03 2008, 04:02
ozneil 18
November 03 2008, 04:02 #16447
I have installed ChronoConnectivity and it is displaying event registration information collected by ChronoForms very nicely. Thank-you!

As the event registration page includes personal information such as emails and phone contacts, we would like to password protect the page so it is not on public view.

I have tried using some PHP code for password protection (see below) but can't get this to work because the code needs to be split over the header and footer to conditionally display the table information from the database.


<?php
// Define your username and password
$username = "yourusername";
$password = "yourpassword";
if ($_POST['txtUsername'] != $username || $_POST['txtPassword'] != $password) {
?>

<h1>Login</h1>
<form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<p><label for="txtUsername">Username:</label>
<br /><input type="text" title="Enter your Username" name="txtUsername" /></p>
<p><label for="txtpassword">Password:</label>
<br /><input type="password" title="Enter your password" name="txtPassword" /></p>
<p><input type="submit" name="Submit" value="Login" /></p>
</form>

<?php
}
else {
?>
<p>This is the protected page. Your private content goes here.</p>
<?php
}
?>

Is there an easy way around this or some other way to password protect a page?

Neil
Chidlow, WA Australia
Webilicious Web Design and Development
https://webilicious.com.au
https://iconifier.net
https://webhostingdownunder.com.au
GreyHead 64
November 03 2008, 06:58 #16450
Hi ozneil,

Who do you want to see the page? Just the owner? or all registered users?

You could simply try putting a redirect in the header. For example
<?php
global $mainframe;
$my = JFactory::getuser();
if ( $my->id == 0) {
$mainframe->redirect('index.php');
}
?>
will redirect guests to the home page.

Bob
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
ozneil 18
November 12 2008, 03:06 #16936
Rather than a registered user I would like to be able to just hand out a password to those authorised to see the page. Is that possible?
Webilicious Web Design and Development
https://webilicious.com.au
https://iconifier.net
https://webhostingdownunder.com.au
admin 28
November 12 2008, 11:27 #16945
hand out a password = ???

Max
Max
If your main question got answered then please mark the answer using the button!
Did you try the new ChronoForms7 ? if yes then please send us your comments!!