[php:1:e0b2753167]<?php
require_once "Smarty.class.php";
$smarty = new Smarty();
$smarty->template_dir = '/usr/local/apache/htdocs/templates';
$smarty->compile_dir = '/usr/local/apache/htdocs/templates_c';
$smarty->config_dir = '/usr/local/apache/htdocs/configs';
$smarty->cache_dir = '/usr/local/apache/htdocs/cache';
$smarty->assign('site_name' , 'United Gaming');
mysql_connect('localhost' , 'root' , '123qwe');
mysql_select_db("test");
$id=$_GET['id'];
if (!$id) {
echo "Podaj paramentr";
}
else
{
$sql = "SELECT * FROM ug_users WHERE ug_id=$id";
$result=mysql_query($sql);
$row = mysql_fetch_array($result);
}
$smarty->assign('Profile' ,
array('id' => $row["ug_id"],
'nick' => $row["ug_nick"],
'irc' => $row["ug_irc"],
'gg' => $row["ug_gg"],
'www' => $row["ug_www"],
'lastlogin' => $row["ug_lastlogin"],
'status' => $row["ug_status"],
'comm_n' => $row["ug_comm_n"],
'news_n' => $row["ug_news_n"],
'regdate' => $row["ug_regdate"],
'logins_n' => $row["ug_logins_n"],
'opis' => $row["ug_opis"],
'lastlogin' => $row["ug_lastlogin"],
'email' => $row["ug_email"]));
function edit_user()
{
$sql = "UPDATE ug_users SET ug_nick=$ug_nick WHERE ug_id=$id";
$result=mysql_query($sql);
}
$smarty->register_function("edit_us" , "edit_user");
$smarty->display('edit.tpl');
?>[/php:1:e0b2753167]
i kod pliku edit.tpl
[xml:1:e0b2753167]<html xmlns=http://www.w3.org/1999/xhtml" xml; lang="en" lan="en">
<head>
<title>{$site_name} - Profil uzytkownika {$Profile.nick} [{$Profile.id}]</title>
</head><hr>
<body><h2>Edytowanie uzytkownika {$Profile.nick}</h2><hr><BR>
<form method="POST" action="{edit_us}">
Nick: <input type=text name"nick" value="{$Profile.nick}">
<BR>
E-mail: <input type=text name"nick" value="{$Profile.email}">
<BR>
Gadu-Gadu: <input type=text name"nick" value="{$Profile.gg}">
<BR>
IRC: <input type=text name"nick" value="{$Profile.irc}">
<BR>
Strona WWW: <input type=text name"nick" value="{$Profile.www}">
<BR><BR>
Status: {$Profile.status}<BR><BR>
Data rejestracji: {$Profile.regdate}
<BR>
Ilosc logowan: {$Profile.logins_n}
<BR>
Ostatnie Logowanie: {$Profile.lastlogin}<BR>
<BR>Newsy: {$Profile.news_n}
<BR>
Komentarze: {$Profile.comm_n}
<BR><BR>Opis:<BR> <textarea name"opis" cols=60 rows=10>{$Profile.opis}</textarea><BR><BR>
<input type="submit" name=wyslij "value="Zapisz">
<input type="reset" name=wyslij "value="Resetuj">
</form>
</body>
</html>
[/xml:1:e0b2753167]
Teraz mam 2 pytania. Jak wywolac z pliku edit.tpl funkcje {edit_us} z parametrem id ktory mam albo w linku albo w sesji oraz jak wszystkie pola dodac do bazy.
W smartach jestem zielony wiec prosze lopatologicznie.