• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[Tutor test] Tutor Test by Mikuch 0.0.1

Mikuch

/home/mikuch
Joined
Jul 1, 2008
Messages
440
Reaction score
1
Location
Poland/Kielce
First we need to one pool to table account
execute that in phpmyadnmin.
Code:
ALTER TABLE accounts ADD testdate DOUBLE DEFAULT NULL;

Make config file named config.php
PHP:
<?
$host="localhost"; // Hostname.
$db_user=""; // Mysql user name.
$db_password=""; // Mysql user password.
$database=""; // Database name


$localdate = gmDate("Ymd");
$days = 7; // After how many days test can be done again
?>


Main file called index.php
PHP:
<?
	session_start();
	session_destroy();
	$message="You are logged out"; // Message when logged out
   
	// Login section
	$login=$_POST['login'];
	if($login) {
	// When You click button
	$name=$_POST['name'];
	$password=$_POST['password'];
	include('config.php');
        mysql_connect($host,$db_user,$db_password);
        mysql_select_db($database);

        $data = mysql_query("SELECT * FROM accounts WHERE name='$name'") or die('Error');
        $r = mysql_fetch_assoc($data);

        $dateoftest = "".$r['testdate']."";
        $checkingdays = $dateoftest - $localdate; 



// Checking user name and password.
  $rezultat=mysql_query("select * FROM accounts WHERE name='$name' AND password='$password'");
    if(@mysql_num_rows($rezultat)){
if ($checkingdays <= -($days)){
   session_register("name"); // Remember sesion name.
    header("location:main.php"); // Redirect to main.php
  exit;
}else {
echo "You were making test $checkingdays days ago. You have to wait $days days to try again"; // Message if You was making test less days then in written at conmfig.php
}
  }else {
  $message="<br>Wrong password or username"; // Message if password or username is wrong
  }
} // End of authorization checking

?>
<head>
<html>
<title>Mikuch RPG - tutor test</title>
</head>
  <body>
<? echo $message; ?>
<form id="form1" name="form1" method="post" action="<? echo $PHP_SELF; ?>">
  <table>
    <tr>
      <td>Account Name: </td>
      <td><input name="name" type="text" id="name" /></td>
    </tr>
    <tr>
      <td>Password: </td>
      <td><input name="password" type="password" id="password" /></td>
    </tr>
  </table>
<input name="login" type="submit" id="login" value="login" />
</form>
</body>
</html>


and test file called main.php
PHP:
<?
		include('config.php');
		mysql_connect($host,$db_user,$db_password);
		mysql_select_db($database);

	session_start(); // Session declaration
	if(!session_is_registered("name") ){ // Checking session name
	header("location:index.php"); // Redirect to index.php
	}

$name = $_SESSION['name'];
$localdate = gmDate("Ymd");
	echo("Welcome "); echo $_SESSION['name']; echo("! You are logged in");
?>


<html>
<head>
<title>Mikuch RPG - Tutor test</title>
</head>
<body>
<br>Dont use capital letters in the test<br><br>
<form id="form1" name="form1" method="post" action="<? echo $PHP_SELF; ?>">
<table>

<!--First questiion  -->

<tr>
		<td>
		1. first question<br> 
		</td>
	<tr> 
		<td>
		<input name="p1" type="text" id="p1" />
		</td>
	</tr>
</tr>


<!--Second question  -->
<tr>
		<td>
		2. second question <br>
		</td>
	<tr>
		<td>
		<input name="p2" type="text" id="p2" />
		</td>
	</tr>
</tr>



<tr>
		<td>
		3. third question<br> 
		</td>
	<tr>
		<td>
		<input type=radio name="p3" value="tak">Tak<br>
		<input name="p3" type=radio value="nie">Nie<br>
		</td>
	</tr>
</tr>
	


<tr>
		<td>
		4. fourth question <br>
		</td>
	<tr>
		<td>
		<input type=radio name="p4" value="theforgottenserver">theforgottenserver<br>
		<input type=radio name="p4" value="evolution">Evolution<br>
		<input name="p4" type=radio value="inny">Inny<br>
		</td>



<tr>
		<td>
		5. fifth question 
		</td>
	<tr>
		<td>
		<input name="p5" type="text" id="p5" />
		</td>
	</tr>
</tr>


<!--Nick to become tutor  -->

<tr>
		<td>
		Enter nick of player that will be tutor
		</td>
	<tr>
		<td>
		<input name="nick" type="text" id="nick" />
		</td>	
	</tr>
</tr>
</table>


<?
$nick=$_POST['nick'];
$result = mysql_query("UPDATE players SET group_id='2' WHERE name='$nick'") or die(mysql_error());

?>
	<input name="answer" type="submit" id="answer" value="answer" />
</form>



<?

$odpowiedz=$_POST['odpowiedz'];

	if($answer)
	{
	$p1=$_POST['p1'];
	$p2=$_POST['p2'];
	$p3=$_POST['p3'];
	$p4=$_POST['p4'];
	$p5=$_POST['p5'];

	$localdate = gmDate("Ymd");
	echo('You answers:<br>');
	echo("1. $p1<br>");
	echo("2. $p2<br>");
	echo("3. $p3<br>");
	echo("4. $p4<br>");
	echo("5. $p5<br>");

        $data = mysql_query("SELECT * FROM accounts WHERE name='$name'") or die('Bł±d zapytania');
        $r = mysql_fetch_assoc($data);
        $datatestu = "".$r['testdate']."";
        $sprawdzenie = $datatestu - $localdate;
		if($p1=='first answer' && $p2=='second answer' && $p3=='third answer' && $p4 =='fourth answer' && $p5=='fifth answrr' && $sprawdzenie <= -($days))
		{
		echo('<font size="5">You made it!!! all answers are correct.</font><br>');
		$nick=$_POST['nick'];
		$result = mysql_query("UPDATE players SET group_id='2' WHERE name='$nick'") or die(mysql_error());
		$result3 = mysql_query("UPDATE accounts SET testdate='$localdate' WHERE name='$name'") or die(mysql_error());
		}
			else
			{
			echo('You did not passed exam try again after $days.');
			$result3 = mysql_query("UPDATE accounts SET testdate='$localdate' WHERE name='$name'") or die(mysql_error());
			?>
			<meta http-equiv="Refresh" content="0; URL=index.php"; />
			<?
			}
}
?>

<p><a href="index.php">Log out</a></p>
</body>
</html>



All credits goes to me :)

TODO:
-More user friendly script
-More configurable config.php
-Layoute
 
Last edited by a moderator:
It would be better to make it in english. Now its polish.
I checked the file and it doesn't contain any shells.
 
I have some bug:
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\index.php:45) in C:\xampp\htdocs\index.php on line 67
 
okay thnx but there are two things:

1: i get this error:

Warning: session_register() [function.session-register]: Cannot send session cache limiter - headers already sent (output started at C:\Users\Jaroen\Desktop\Xenion\Xampp\htdocs\Tutortest\config.php:11) in C:\Users\Jaroen\Desktop\Xenion\Xampp\htdocs\Tutortest\index.php on line 28

Warning: Cannot modify header information - headers already sent by (output started at C:\Users\Jaroen\Desktop\Xenion\Xampp\htdocs\Tutortest\config.php:11) in C:\Users\Jaroen\Desktop\Xenion\Xampp\htdocs\Tutortest\index.php on line 29

Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively. in Unknown on line 0

:)S i dont know how to put it in code)

and 2 (this isnt really is on topic i think):

how can i make a button that players can click on and then get redirected to the tutortest page?

plz help me XD

(no edit button)....i know im a noob in php :S i need to learn..
 
Last edited by a moderator:
Warning: session_register() [function.session-register]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\tutor\config.php:1) in C:\xampp\htdocs\tutor\index.php on line 28

Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\tutor\config.php:1) in C:\xampp\htdocs\tutor\index.php on line 29

Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively. in Unknown on line 0
 
Back
Top