Cafte, tak svoj e book chrsanim trochu netypicky :)
Zo zadaneho mena vygenerujem md5 hash ktory sa ukaze userovi, po zadani do dalsieho inputu a odoslani by mal dalej pokracovat skript tj odoslat spravu... Zatial to vsak mam iba tak ze by sa malovypisat OK alebo chyba cez if a else, nieco natom vsak nefunguje....
Chybu nepise ziadnu....
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Simple GuestBook</title>
<link href="style.css" rel="stylesheet" type="text/css" media="screen" />
<style type="text/css">
a {text-decoration: none; color: green;}
a:hover {text-decoration: underline; color: silver; position: relative; margin-left: auto; margin-right: auto;}
body{background-color: #020202; color: #f2f2f2;}
</style>
</head>
<body>
<center><a href="#" onClick="document.getElementById('forms').style.display='block'">Pridať príspevok</a>
<div id="forms" style="display: none">
<form method="POST" action="index.php">
Meno: <input type="text" name="autor" />
Správa: <textarea name="text" cols="50" rows="10" /></textarea>
<input type="submit" />
</form>
</div>
</center>
<?php
/*
CREATE TABLE `gb`.`g_book` (
`id` INT NOT NULL AUTO_INCREMENT ,
`autor` TINYTEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL ,
`text` TINYTEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL ,
`ip` TINYTEXT NOT NULL ,
PRIMARY KEY ( `id` )
) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_unicode_ci
*/
$autor = htmlspecialchars($_POST['autor']);
$text = htmlspecialchars($_POST['text']);
$pripoj = mysql_connect("localhost", "root", "0000") or die(mysql_error());
mysql_select_db("gb");
$trimmed =trim($_POST['autor']);
$trimmed1 =trim($_POST['text']);
if(!empty($trimmed) and $trimmed1){
$captcha = $_POST['meno'];
$captcha2 = md5($captcha);
echo $captcha2;
echo "<form method='POST'>
<input type='text' name='a'>
<input type='button'>
</form>";
$porovnaj = $_POST['a'];
if($porovnaj === $captcha2){
echo "ok";}
else{echo "chyba";}
$sql = mysql_query("INSERT INTO g_book(autor, text) VALUES('$autor', '$text')");
if($sql){
echo "<center>Správa odoslaná.</center>";
}
}
else{echo "<center>Nemôžete odoslať prázdnu správu.</center>";}
$sql = mysql_query("SELECT * FROM g_book ORDER BY id DESC");
while($vypis = mysql_fetch_array($sql)){
?>
<?php
include ('wrap.php');
echo "<b>" . $vypis['autor'] . "</b>" . "" . " " . $vypis['text'] . "</div>"; }
?>
</body>
</html>