Pcfr43k
01-27-2010, 12:01 PM
Hello,
I try to write a login script that can be part of the file.
Like this:
{index.php
{index page}
{login}
{restricted page}
}
So I wrote a script but used the GOTO command.
<?
$user = 'admin';
$pass = 'pass';
$userinput = $_POST['userinput'];
$passinput = $_POST['passinput'];
$error = 'Wrong login, try again.';
echo "<html><head><title>Login script</title></head><body>
<form action='<?php echo $_SERVER['PHP_SELF']; ?>' method='post'>
Username:<br/>
<input type='text' name='userinput'/><br/>
Password:<br/>
<input type='password' name='passinput'/><br/>
<input type='submit' value='Login' />
</form></body></html>";
if($user==$userinput)
{
if($pass==$passinput)
{goto page;}
else {echo $error;}
}
else {echo $error;}
page:
echo "<p>This content is visable after logging in</p>";
?>
I don't know if this works, but I want this to work on lower version PHP servers.
So I adjusted the script:
<?
$user = 'admin';
$pass = 'pass';
$userinput = $_POST['userinput'];
$passinput = $_POST['passinput'];
$error = 'Wrong login, try again.';
echo "<html><head><title>Login script</title></head><body>
<form action='<?php echo $_SERVER['PHP_SELF']; ?>' method='post'>
Username:<br/>
<input type='text' name='userinput'/><br/>
Password:<br/>
<input type='password' name='passinput'/><br/>
<input type='submit' value='Login' />
</form></body></html>";
if($user==$userinput)
{
if($pass==$passinput)
{echo "<p>This content is visable after logging in</p>";}
else {echo $error;}
}
else {echo $error;}
?>
But this is resulting in a white page.
What am I doing wrong?
The scripts I write are as small and simple as is possible by me.
I try to write a login script that can be part of the file.
Like this:
{index.php
{index page}
{login}
{restricted page}
}
So I wrote a script but used the GOTO command.
<?
$user = 'admin';
$pass = 'pass';
$userinput = $_POST['userinput'];
$passinput = $_POST['passinput'];
$error = 'Wrong login, try again.';
echo "<html><head><title>Login script</title></head><body>
<form action='<?php echo $_SERVER['PHP_SELF']; ?>' method='post'>
Username:<br/>
<input type='text' name='userinput'/><br/>
Password:<br/>
<input type='password' name='passinput'/><br/>
<input type='submit' value='Login' />
</form></body></html>";
if($user==$userinput)
{
if($pass==$passinput)
{goto page;}
else {echo $error;}
}
else {echo $error;}
page:
echo "<p>This content is visable after logging in</p>";
?>
I don't know if this works, but I want this to work on lower version PHP servers.
So I adjusted the script:
<?
$user = 'admin';
$pass = 'pass';
$userinput = $_POST['userinput'];
$passinput = $_POST['passinput'];
$error = 'Wrong login, try again.';
echo "<html><head><title>Login script</title></head><body>
<form action='<?php echo $_SERVER['PHP_SELF']; ?>' method='post'>
Username:<br/>
<input type='text' name='userinput'/><br/>
Password:<br/>
<input type='password' name='passinput'/><br/>
<input type='submit' value='Login' />
</form></body></html>";
if($user==$userinput)
{
if($pass==$passinput)
{echo "<p>This content is visable after logging in</p>";}
else {echo $error;}
}
else {echo $error;}
?>
But this is resulting in a white page.
What am I doing wrong?
The scripts I write are as small and simple as is possible by me.