Jump to content

Scripto Problemos


Drezard

Recommended Posts

Hello, my script should be displaying a form when loaded only prob is it doesnt display anything...

 

<?php

class class_session {

function user_check($username, $password) {

  $query = "SELECT * FROM user_ids WHERE username='$username' AND password='$password'";

  $result = mysql_query($query);

  $count = mysql_num_rows($result);
  
  if ($count == 0) {
  
   $this->validate = FALSE;
  
  }
  
  if ($count == 1) {
  
   $this->validate = TRUE;
  
  }

}

function user_loginform() {
  
  if (!isset($_POST['submit'])) {

   echo "<form action='' method='post'>
         Username: <input name='username' type='text'> <hr>
	 Password: <input name='password' type='password'> <hr>
	 <input type = 'submit' name = 'submit'>
	 </form>";

  }
  
  if (isset($_POST['submit'])) {
  
   if (!isset($_POST['username']) || trim($_POST['username']) == '') {
   		die("Please enter your username");
   }
   
   if (!isset($_POST['password']) || trim($_POST['password']) == '') {
   		die("Please enter your password");
   }
   
   $username = $_POST['username'];
   $password = $_POST['password'];
   
   $this->user_check($username, $password);
   
   if ($this->validate == FALSE) {
   		die("Username or password incorrect");
   }
   
   if ($this->validate == TRUE) {
   
    $timestamp = date('YmdGi');
$ip = $_SERVER['REMOTE_ADDR'];

$query = "UPDATE user_ids SET timestamp='$timestamp', ip='$ip' WHERE username='$username'";

echo "Sucessfully logged in";

   }
  
  }

}

}

?>

 

Its running here... www.wintersword.com/users.php

 

- Cheers, Daniel

Link to comment
Share on other sites

The code you have showed us only defines the class, it doesn't call it anywhere, so thats why it doesn't output anything.

 

you need to do something like:

 


$session = new class_session;

$session->user_loginform();


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.