KOD PHP (tak jak napisalem wyzeh - rekord zostaje dodany)
<?php $user_name = "xxx"; $password = "xxx"; $database = "xxx"; $server = "localhost"; if ($db_found) { $nick_new = $_POST['data']; if($num_rows == 0) { $_SESSION['nick'] = $nick_new; } else } } ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script language="javascript">
$(document).ready(function() {
$("#form").submit(function() {
var input = $("#input");
var text = input.val();
if((text.length > 0) && (text.length < 40)) {
$.post('logging.php', { data: text }, function(data) {
if(data.status == 'success') {
$("#main_log").toggle(); //probowalem $("#main_log").css("display", "none"); no ale nie dziala
$("#main_chat").toggle(); //probowalem $("#main_chat").css("display", ""); no ale nie dziala
}
}, 'json');
}
return false;
});
});
</script>
<title>Untitled Document</title>
<style type="text/css">
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 100px;
}
#main_log {
width:350px;
height:auto;
margin:0px auto;
margin-top:100px;
border:1px solid black;
background-color:#09C;
}
#main_chat {
width:500px;
height:auto;
margin:0px auto;
margin-top:100px;
border:1px solid black;
background-color:#09C;
padding-top:5px;
padding-bottom:5px;
padding-left:5px;
padding-right:5px;
display:none;
}
#chat_up {
width:496px;
height:700px;
margin:0px auto;
border:1px solid black;
background-color:#FFF;
}
#chat_down {
width:496px;
height:auto;
overflow:auto;
margin:0px auto;
margin-top:5px;
}
#form {
height:auto;
overflow:auto;
font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;
font-size:16px;
margin:0px auto;
width:320px;
margin-top:5px;
line-height:30px;
}
.input {
height:auto;
overflow:auto;
padding-top:5px;
padding-bottom:5px;
padding-left:5px;
padding-right:5px;
width:300px;
}
#button {
width:300px;
padding-top:5px;
padding-bottom:5px;
}
#message {
height:auto;
padding-top:5px;
padding-bottom:5px;
padding-left:5px;
padding-right:5px;
width:484px;
border:1px solid black;
}
#send {
margin-top:5px;
width:484px;
}
</style>
</head>
<body>
<div id="main_log">
<form id="form" method="post" action="logging.php">
Choose temporary nick:<br />
<input type="text" name="input" id="input" maxlength="40"><br /><br />
<center><input type="submit" name="Submit" id="submit" value="ENTER" /></center><br />
</form>
<div id="takennick" style="padding:10px 10px 10px 10px; height:20px; display:none">This nick is taken</div>
</div>
<div id="main_chat">
<div id="chat_up"></div>
<div id="chat_down"><center><input type="text" id="message" name="message" maxlength="400" /><input type="button" value="SEND" name="send" id="send" /></center></div></div>
</body>
</html>