Question:
is it possible to make a log in system using java or does it have to be made with php?
Yutaka
2009-07-27 01:59:19 UTC
i want to make a log in system but i dont know how. im trying to make it on my own but i dont think i can make it using java. does it really have to be php? coz i dont know much about php
Six answers:
?
2009-07-27 02:08:27 UTC
Yes, in java we have Log4j Framework.



Log4j is an open source logging framework under the Apache foundation. With log4j it is possile to enable logging at runtime without modifying application binary. Log statements can remain in shipped code and logging behaviour can be controlled by editing a configuration file without touching the binaries.
?
2009-07-27 09:07:34 UTC
Log in system to what? If it's an online one, you can use both. Php might be slightly easier because you would need apache tomcat or something similar to serve the java pages. It's not as commonly used as php.
John Stalvern
2009-07-27 09:06:40 UTC
It depends on what your webserver supports. If it supports CGI bindings for Java, you can write the login system in Java.



However, finding Java enabled by default on most webservers is rare, so I'd write it in PHP to be safe.
phoenix_chi
2009-07-30 16:00:07 UTC
It is possible. You can use jdbc to connect to a mysql, access, oracle, ms sql server database when login a user
Matthew
2009-07-31 00:26:33 UTC
do it in php
anonymous
2009-07-27 22:50:22 UTC

/***************************

login.class.php

***************************/

class user{

//To track the switch/errors through out

var $login_error;



//constructor

function user($UserInput){

if($_SERVER['REQUEST_METHOD'] == "POST")

{

$this->validate_user($UserInput);

}

else

{

$this->login_form();

}

}//End function





//Just a simple login form

function login_form(){

echo "
User Name:Password:
";



}//End Function



function validate_user($UserInput){



//my chosen user name and password pattern

$this->user_name_pattern = ("^[a-zA-Z0-9]{5,15}$");

$this->password_pattern = ("^[a-zA-Z0-9\!\@\#\$\%\^\&\*\`\~\_]{5,15}$");

//JavaScript History -1

$this->go_back = "(Go Back)";

//Change the redirect location to whare you want to go http://yoursite.com/members/

$this->success_login_redirect = "http://dzsoundnirvana.com/";



switch($UserInput){

case ($UserInput['FLU'] == "" || !ereg($this->user_name_pattern,$UserInput['FLU'])):

$this->login_form();

echo "
Invalid user name. Try again or $this->go_back!
";

$this->login_error == false;

break;



case ($UserInput['FLP'] == "" || !ereg($this->password_pattern,$UserInput['FLP'])):

$this->login_form();

echo "
Invalid password. Try again or $this->go_back!
";

$this->login_error == false;

break;

}

if($this->login_error === false){

//Or you can redirect to a "Forgot password/user name" page or leave it alone. This will kill the script. No output after though!

exit;

}

else{

//Now we go to the Database and validate the user

$this->db();

$this->query_string = "SELECT * FROM users WHERE user_name='$UserInput[FLU]' && password='" . md5($UserInput['password']) . "'";

$this->query = mysql_query($this->query_string);

//Error check the query

if(!$this->query){

echo "System error! Contact the system administrator!
or
$this->go_back";

//use this for debugging (below), Delete the // at the beginning

//echo mysql_error();

}

else{

//Need to check if more than 1 user exists if so....throw HACKING error (not supported here)..another class

$this->num_rows = mysql_num_rows($this->query);

if($this->num_rows > 1){

echo "Hacking warning";

exit;

}

else{

//Get the user information and set into the $_SESSION and then redirect to the directed page

$this->user_information = mysql_fetch_assoc($this->query);

//Put all user data into $_SESSION

foreach($this->user_information as $key => $value){

$_SESSION[$key] = $value;

//Now we redirect to the page specified

echo "";

echo "If you are not redirected success_login_redirect\" target=\"_parent\">Click here to continue";

}

}



}//else



}//if($this->login_error === false)/else{





}//End function



function db(){

//Put your database host, database user name, and database password

$this->db_link = mysql_connect("data_base_host","data_base_user","data_base_password");

//Select the DB

//Put your database name

$this->db_select = mysql_select_db("data_base_name");



}





}//End Class

?>


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...