/    Sign up×
Community /Pin to ProfileBookmark

Very easy question… Sorry

Don’t laugh… but… I have sign in form on my page, but i want it gone when a user is signed in and a session is created. I have this working perfect but i have just one small question. In the code below, if a session has not started the sign in form is available, else

[code=php]echo hey echo hey . $_SESSION[‘loggedIn_s’];[/code]

Now, i want this part after the else gone (wher e it says hey to the user logged in. Can i simply just remove the else statment (and what follows it) or is this bad coding practices… If so what should i put instead of the else (is there something that i should be putting there to make the code more correct or stronger instead of just leaving it blank

[code=php]<?php

if (!isset($_SESSION[‘loggedIn_s’]))
echo ‘<form name=”SignIn” method=”post” action=”login.processor.php”>
<table width=”75%” border=”0″ cellspacing=”0″ cellpadding=”0″>
<tr>
<td height=”38″ class=”sign_header”>Sign In To View Your Score</td>
</tr>
<tr>
<td class=”sign_text”>Username:</td>
</tr>
<tr>
<td height=”29″><input type=”text” name=”username” TABINDEX=1 maxlength=”20″><span class=”lost”> or<a href=”join.form.php” class=”linksFooter”> Join Here</a></span></td>
</tr>
<tr>
<td class=”sign_text”>Password:</td>
</tr>
<tr>
<td height=”29″><input type=”password” name=”password” TABINDEX=2 maxlength=”20″></td>
</tr>
<tr>
<td height=”36″><input type=”submit” name=”Submit” value=”Sign In”></td>
</tr>
<tr>
<td height=”36″ class=”lost”>Lost Your <a href=”lost.password.php” class=”linksFooter”>Password</a> ?</td>
</tr>
</table>
</form>’;

else
echo hey . $_SESSION[‘loggedIn_s’];
?>[/code]

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@MrCoderMay 02.2007 — [code=php]
<?php
if (!isset($_SESSION['loggedIn_s']))
{
?>
<form name="SignIn" method="post" action="login.processor.php">
<table width="75%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="38" class="sign_header">Sign In To View Your Score</td>
</tr>
<tr>
<td class="sign_text">Username:</td>
</tr>
<tr>
<td height="29"><input type="text" name="username" TABINDEX=1 maxlength="20"><span class="lost"> or<a href="join.form.php" class="linksFooter"> Join Here</a></span></td>
</tr>
<tr>
<td class="sign_text">Password:</td>
</tr>
<tr>
<td height="29"><input type="password" name="password" TABINDEX=2 maxlength="20"></td>
</tr>
<tr>
<td height="36"><input type="submit" name="Submit" value="Sign In"></td>
</tr>
<tr>
<td height="36" class="lost">Lost Your <a href="lost.password.php" class="linksFooter">Password</a> ?</td>
</tr>
</table>
</form>
<?php
// Since the user is not logged in I guess you dont want the following displayed, so lets stop PHP by using die()

die();
}

// This line would never get executed unless the user was logged in
?>

<h2>You are now logged in.</h2>
[/code]
×

Success!

Help @oo7ml 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 5.28,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...