Jump to content

Make session invisible


fishbaitfood

Recommended Posts

Hi,

 

So, I have two sessions. One's for displaying an array.

 

Is there some kind of function to make a session invisible?

 

Because when I display an error for not filling in, the previous words of the array show up behind the error message.

Like this:

 

$error = 'Please enter a word.'

 

Output: Please enter a word.word word word

 

So is there a way to make my Session Invisible (not removing any words from array)?

 

Link to comment
https://forums.phpfreaks.com/topic/209797-make-session-invisible/
Share on other sites

Because when I display an error for not filling in, the previous words of the array show up behind the error message.

Huh? How is that possible. Could you post the code that outputs the error and a screenshot of your problem. This sounds more like a HTML/CSS issue to me.

Here's the code:

 

<?php
...

$error = 'Please enter a word.';

...
?>

...

<p>
<?php
  if ($error != '') {
   echo $error;
  }

  if (isset($_SESSION['words'])) {
   echo implode(' ',$_SESSION['words']);
  }
?>
</p>

 

 

 

 

[attachment deleted by admin]

Sorry.. Here's the whole bunch of code (see attachment) :D

 

 

So basically, when I submit the empty form (the array form), I get a message saying 'Please enter a word.'. Nothing wrong with that.

 

But when I previously entered some words, they show up behind my error message. So I need to find a way to make my array invisible, when showing the error message.

 

@ AlexWD: lol, yes..  :D So do I need to put the echo command somewhere else?

 

 

[attachment deleted by admin]

So you only want to show the words previously entered if there is no error message? Change your two if's to if/elseif

 

  if ($error != '') {
   echo $error;
  }
  elseif (isset($_SESSION['words'])) {
   echo implode(' ',$_SESSION['words']);
  }

So you only want to show the words previously entered if there is no error message? Change your two if's to if/elseif

 

  if ($error != '') {
   echo $error;
  }
  elseif (isset($_SESSION['words'])) {
   echo implode(' ',$_SESSION['words']);
  }

 

 

haha, that simple...!!  :D  Thanks for the adjustment!

 

~~~~~~~

SOLVED

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.