index.tpl:
<form id="registry" method="post" action="{$smarty.server.php_self}"> <fieldset> <legend>A simple comment form with submit validation and default messages</legend><label for="cname">login</label> *<input id="login" name="login">
<label for="cemail">haslo</label> *<input id="haslo" name="haslo">
<label for="ccomment">email</label> *<textarea id="email" name="email"></textarea>
<input class="submit" value="Submit" type="submit">
</fieldset> </form>index.php:
<?
require('../libs/Smarty.class.php');
require ("./connect_db.php");
$smarty = new Smarty;
//header("Location: index.php");
$login=$_POST['login'];
$haslo=$_POST['haslo'];
$email=$_POST['email'];
if ( !$login || !$haslo || !$email ) {echo 's';}
if (isset($login) && isset($haslo) && isset($email)){
$rejestruj="INSERT INTO `uzytkownicy` (`login`, `haslo`, `email`) VALUES ('$login', '$haslo', '$email')";
$res = mysql_query($rejestruj);
if ($res)
echo ' DANE ZAPISANE POMYSLNIE.</b></font>
';
}
else {
echo 'zle';
//header("location:panel_a.php");
}
mysql_close($polacz);
$smarty->display('registry.tpl');
?>
jak to poprawnie napisać?