Jump to content

My form not working ... again


seksislav

Recommended Posts

Hello everybody,

 

I feel a bit embarrassed now for asking the most retarded questions ever. So my problem is when I check if the user is logged it i echo a welcome message to the user. If not then i'll proc a login form. Till there everything is OK but when i press the "LOGIN" button it dose not process the form.

<? if(!$session->logged_in){
  	
  echo '
  <tr class="user_menu">
    <td height="26" ><div align="left">
    <form action="process.php" method="post">  
    <input type="text" class="login" name="user" maxlength="30" value="Username">  
    <input type="password" class="login" name="pass" maxlength="30" value="Password">
    <input type="hidden" name="sublogin" value="1">
    <input type="button" class="login_button" value="Login" >
    </form></div></td>
    <td height="26" colspan="2" class="messages">Forgot password? Register<div align="right"></div></td>
  </tr>';} 
  else {
  
  echo '<tr class="user_menu">
    <td height="26" ><div align="left"> Welcome '.$session->username.' </div></td>
    <td> <a href="process.php">Logout</a> </td>
    <td height="26" colspan="2" class="messages"><div align="right">You have (0) new messages. </div></td>
  </tr>'; } ?>

.. -.- please do help me

Link to comment
https://forums.phpfreaks.com/topic/91669-my-form-not-working-again/
Share on other sites

how are you processing the form?

 

if its all in one file you could try this:

 

<?php

// Process Login if a form is submitted
if($_POST['sublogin']){
  
  // ive oput user/passes in the file to make my reply simple, not sure if your using a mysql db to store usernames or not.
  $users = array(
    "Username" => "Password",
    "Username2" => "Password2",
    "Username3" => "Password3"
  );
  
  if(@$users[$_POST['username']] == $_POST['password']){ // the @ symbol supresses a T_NOTICE being displayed if a username is not found.
    $session->logged_in = true;
    $session->username = $_POST['username'];
  }else{
    exit("Details do not match");
  }
}

if(!$session->logged_in){
  	
  echo '
  <tr class="user_menu">
    <td height="26" ><div align="left">
    <form action="process.php" method="post">  
    <input type="text" class="login" name="user" maxlength="30" value="Username">  
    <input type="password" class="login" name="pass" maxlength="30" value="Password">
    <input type="hidden" name="sublogin" value="1">
    <input type="button" class="login_button" value="Login" >
    </form></div></td>
    <td height="26" colspan="2" class="messages">Forgot password? Register<div align="right"></div></td>
  </tr>';

  
}else{
  
  echo '<tr class="user_menu">
    <td height="26" ><div align="left"> Welcome '.$session->username.' </div></td>
    <td> <a href="process.php">Logout</a> </td>
    <td height="26" colspan="2" class="messages"><div align="right">You have (0) new messages. </div></td>
  </tr>';
}
?>

 

 

this is a very simple solution to a login, i see your using a class stored in $session.

do you get a completely blank page when you click login?

 

if so check your php.ini (or use ini_get() ) and see if "display_errors" is on or off.

----------------

 

also, i tyhink we need more information like the classes your using? the session class and any class that session class uses would be quite helpful in diagnosing the problem...

do you get a completely blank page when you click login?

 

if so check your php.ini (or use ini_get() ) and see if "display_errors" is on or off.

----------------

 

also, i tyhink we need more information like the classes your using? the session class and any class that session class uses would be quite helpful in diagnosing the problem...

 

nope. The login is working on another page but not on this one. I started by doing the mysql tables , then the code and finaly the design. I'm at the design stage. If i use the old shit without any tables, images or whatever its working :/ if u put tables and other stuff it dosnt.

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.