/    Sign up×
Community /Pin to ProfileBookmark

Delete the login form?

Well, i’m trying to make a very simple login form, and have got this far;

[code=php]<?php
$loginform = ‘<form action=”login.php” method=”get”>Username:<input name=”user” type=”text” id=”user”><br /><br />Password:<input name=”pass” type=”text” id=”pass”><br /><br /><input type=”submit” name=”Submit” value=”Submit”></form>’;

echo $loginform;

if ($_GET[‘user’] == ‘Johnno’)
{
if ($_GET[‘pass’] == ‘pass’)
{
echo ‘Hello’;
}
}
?>[/code]

Thats all fine and dandy, but is there a way to delete the login form after it is filled out, without transfering to a new page, because I want this all in one file.

I’ve tried delete() and unset(), and cant think of anything else.

Thanks.

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@MstrBobAug 15.2004 — Something like:


[code=php]
<?PHP
if(isset($_POST['user']) && isset($_POST['pass']))
{
if($_POST['user']=='Johnno' && $_POST['pass'] == 'pass')
{
echo("Hello, ".$_POST['user']."!");
} else {
$loginform = '<form action="'.$_SERVER['PHP_SELF'].'" method="post">Username:<input name="user" type="text" id="user"><br /><br />Password:<input name="pass" type="password" id="pass"><br /><br /><input type="submit" name="Submit" value="Submit"></form>';
echo($loginform);
}
?>
[/code]


Sends the page the form to the same PHP page, and if the form fields are filled out, it processes them and no form is displayed. For logins, don't use GET, because info is displayed in the URL.
Copy linkTweet thisAlerts:
@JohnnoauthorAug 15.2004 — Parse error: parse error, unexpected $ in /home/autogame/public_html/johnno/login.php on line 11[/QUOTE]
Line 11: [code=php]?>[/code]

?

I've played around with it for a while, but couldn't find anything wrong.

(That error is what appears from that exact code)
Copy linkTweet thisAlerts:
@MstrBobAug 15.2004 — Eek, you copied it as is? I really need to start proofreading my posts... Anywho, I forgot a bracker }

[code=php]
<?PHP
if(isset($_POST['user']) && isset($_POST['pass']))
{
if($_POST['user']=='Johnno' && $_POST['pass'] == 'pass')
{
echo("Hello, ".$_POST['user']."!");
}
} else {
$loginform = '<form action="'.$_SERVER['PHP_SELF'].'" method="post">Username:<input name="user" type="text" id="user"><br /><br />Password:<input name="pass" type="password" id="pass"><br /><br /><input type="submit" name="Submit" value="Submit"></form>';
echo($loginform);
}

?>
[/code]
×

Success!

Help @Johnno spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...