Jump to content

Code Working But I Want Position Echo Elsewhere


azraelGG

Recommended Posts

hi

 

currently i created login form and its working but i want replace my echo messages be below form not above

how can i replace it (is it possible without repeating code)

 

here is the code

<?php
  //username and password check - start session or display wrong username and password
  if (isset($_REQUEST['login'])){
   $korisnickoIme=$_REQUEST['korisnickoIme'];
   $lozinka=$_REQUEST['lozinka'];
   if ($korisnickoIme=='admin'  && sha1($lozinka)=='7110eda4d09e062aa5e4a390b0a572ac0d2c0220') {
 $_SESSION['logiran']='da';
 $_SESSION['korisnickoIme']=$korisnickoIme;
   }
   else{
 echo "Molimo unesite ispravne podatke.";
   }
  }

  //display login form - if someone clicked logout button or not logged in
  if (
  (isset($_REQUEST['logout']))||(!isset($_SESSION['logiran']))
  ) {
   echo '<!--start of login form sidebar-->
 <form id="login" action="index.php" method="post">
  <label>Korisničko ime:</label>
  <input type="text" name="korisnickoIme" id="korisnickoIme" />
  <label>Korisnička šifra:</label>
  <input type="password" name="lozinka" id="lozinka" />
  <input type="submit" value="Login" name="login" />   
 </form>';
   if(isset($_REQUEST['logout'])){
 session_destroy();
 echo "Uspješno ste se odjavili.";
   }
  }
  //if user is logged in display logut form
  elseif (isset($_SESSION['logiran'])) {
   echo "Logirani ste pod imenom ".$_SESSION['korisnickoIme'];
 echo'<!--start form for logout -->
   <form id="logout" action="index.php" method="post">
    <input type="submit" value="Logout" name="logout" />
   </form>
   ';
  }
  ?>

 

i want that part of code else echo "Molimo unesite ispravne podatke" below form

this other echo shows at bottom because that code is below form. any way to reposition that echo or how do i do it

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.