PHP: Making my code simpler/shorter welcome message
Posted
by
Karem
on Stack Overflow
See other posts from Stack Overflow
or by Karem
Published on 2011-01-05T20:52:01Z
Indexed on
2011/01/05
21:54 UTC
Read the original article
Hit count: 257
Any suggestion to make this welcome message shorter:
<?php
if(isset($_SESSION['user_id'])) {
if(isSet($_SESSION['1stTime'])){
?>
<strong id="welcome" style="font-size: 10px;">
<a href="logout.php">
Logga ut
</a>
</strong>
<?php
}else{
$_SESSION['1stTime'] = time();
?>
<script>
$(document).ready(function() {
$("#welcome").fadeIn("slow");
setTimeout(function(){
$("#welcome").fadeOut("slow");
setTimeout(function(){
$("#welcome").html("<a href='logout.php'>Logga ut</a>");
$("#welcome").fadeIn();
}, 800);
}, 5000);
});
</script>
<strong id="welcome" style="display: none; color: #FFF; font-size: 10px;">Hej, <?php echo $FULL; ?>!</strong>
<?php
}
}
?>
First it checks if you are signed in. Next if 1stTime is set, if it is then show "Log out" in swedish, if it isnt, then introduce with "Hi, NAME", and then change to "Log out" after 5 seconds(jquery) + set the session
How can i make this simpler?
© Stack Overflow or respective owner