Simple PHP Question
- Started
- Last post
- 31 Responses
- epikore
I'm trying to make a html page that's password protected. The trick is if the user types in the correct password, it automatically goes to another page.
- epikore0
Another question, what's the simplest script where there's a text box, button that posts comments onto a html page?
- look at the free Vanilla forum maybe. www.getvanilla.comairey
- janne760
setting up secret societies, eh?
- epikore0
classified
- airey0
i realise it's going to come across smart-arse but have you even looked at google? that link above was 1 of 6 billion that appeared when i looked up "password login html". there are billions of solutions.
- pylon0
So epikore what you're asking is two things, right?
Password protection / validation.
Page redirection.
Password protection is most effective with .htaccess.
Are you trying to build a text-box for a comments area like in a blog or a product review?
- epikore0
The first one is a password protection page. If the password is correct, it automatically directs to the "secret society page"
The second one is a page where a viewer can post a comment. Just a text area box and a submit button. Kind of like here.
- neferiu0
<?php
//password
$pw = 'sekritz';if ($_POST['submit'] == 'Login')
{
//Check Password
if ($_POST['password'] == $pw)
//Send to Sekritz
header('Location: sekritz.php');
else
//load error note and proceed with the rest of the shit.
$error = 'Password Incorrect<p>';
}
?><form method="post" action="<?=$PHP_SELF;?>" name="sekrit">
<?=$error;?>
Please enter the password.
<p><input type="text" name="password">
<input type="submit" name="submit" value="Login">
</form>- how would I modify the header(Location with a direct link rather than a local link?epikore
- neferiu0
as simple as it gets...
- epikore0
I been messing with the header('Location: redirect thing and I get this message:
Warning: Cannot modify header information - headers already sent by (output started at /nfs/cust/5/91/08/480195/web/tes... in /nfs/cust/5/91/08/480195/web/tes... on line 18
- neferiu0
it means you got something hitting the HTML page before that header does. You have to make sure the header redirect is the first thing to hit the page.
- epikore0
This the entire code, I don't think I have anything before it:
<html>
<head>
<title></title></head>
<body>
<?php
//password
$pw = 'yahoo';if ($_POST['submit'] == 'Login')
{
//Check Password
if ($_POST['password'] == $pw)
//Send to Sekritz
header('Location: http://www.yahoo.com');
else
//load error note and proceed with the rest of the shit.
$error = 'Password Incorrect<p>';
}
?><form method="post" action="<?=$PHP_SELF;?>" name="sekrit">
<?=$error;?>
Please enter the password.
<p><input type="text" name="password">
<input type="submit" name="submit" value="Login">
</form></body>
</html>
- neferiu0
put the PHP shit above the HTML setup... the PHP shit is basically meant to just proces the form, so it doesnt need any of the Html tags, and the html tags are what's fucking up the header redirect.
This should work:
----------------
<?php
//password
$pw = 'yahoo';if ($_POST['submit'] == 'Login')
{
//Check Password
if ($_POST['password'] == $pw)
//Send to Sekritz
header('Location: http://www.yahoo.com');
else
//load error note and proceed with the rest of the shit.
$error = 'Password Incorrect<p>';
}
?><html>
<head>
<title></title></head>
<body>
<form method="post" action="<?=$PHP_SELF;?>" name="sekrit">
<?=$error;?>
Please enter the password.
<p><input type="text" name="password">
<input type="submit" name="submit" value="Login">
</form></body>
</html>
- epikore0
fuck yeah, that works, thanks
- neferiu0
no prob. now go make that fucker as pretty as can be. :)
- epikore0
hey, if you got time, what about a text box and a submit button that posts on a page? =P
- neferiu0
Haha - i have a job too you know. ;) Explain in better detail what you need.
- epikore0
I want a page where viewers can post comments. Just a plain text box and a submit button kind of like here.