Drako píše:
to nieje len take jednoduche a nenajdes to hocikde napis mi na icq 396 147 846 a pokecame o tom
ja by som povedal ze je to este jednoduchsie ako sa to zda
ale aby som netocil okolo toho a aj pomohol. prikladam zrojak na jednoduchu registraciu:)
tazke najskor tabulku v mysql:
Kód:
CREATE TABLE users
(
id int auto_increment not null primary key,
nick varchar(100) not null,
password varchar(200) not null,
name varchar(100) not null,
surname varchar(100) not null,
email varchar(100) not null,
ip varchar(100) not null,
reg_date varchar(100) not null
);
a potom
samotny script:
Kód:
<?php
mysql_connect('localhost', 'root', '') or die ('Mysql error');
mysql_select_db('stranka') or die ('Mysql error');
$nick=trim(htmlspecialchars(addslashes($_POST['nick'])));
$password=sha1(addslashes($_POST['password']));
$password_confirm=md5(addslashes($_POST['password_confirm']));
$name=trim(htmlspecialchars(addslashes($_POST['name'])));
$surname=trim(htmlspecialchars(addslashes($_POST['surname'])));
$email=trim(htmlspecialchars(addslashes($_POST['email'])));
$time=date('d.m.Y g:i a');
$ip=$_SERVER['REMOTE_ADDR'];
if (!$ip){
$ip='UNKNOWN';
}
$sql='SELECT * FROM users WHERE nick="'.$nick.'"';
$result=mysql_query($sql);
if (mysql_num_rows($result)!=0){
$error=1;
}
else{
$error=0;
}
if (isset($_POST['sent']))
{
if ($nick=='' || $password=='' || $password_confirm=='' || $name=='' || $surname=='' || $email=='')
{
print 'You must insert all information about you!';
}
else
{
if ($error==0)
{
if ($password == $password_confirm)
{
if (ereg('^.+@.+\\..+$', $email))
{
$sql='INSERT INTO users (`nick`, `password`, `name`, `surname`, `email`, `ip`, `reg_date`) VALUES ("'.$nick.'", "'.$password.'", "'.$name.'", "'.$surname.'", "'.$email.'", "'.$ip.'", "'.$time.'")';
$result=mysql_query($sql);
header('Location: index.php?register=successful');
}
else
{
print 'Email is not valid';
}
}
else {
print 'Passwords are different';
}
}
elseif ($error==1)
{
print 'This nick is already register';
}
}
}
else {
print 'Please insert all informations about you';
}
mysql_close();
?>
<center>
<form method="post">
Nick: <input type="text" name="nick" value="" size="20"><br>
Password: <input type="password" name="password" value="" size="20"><br>
Confirm password: <input type="password" name="password_confirm" value="" size="20"><br>
Name: <input type="text" name="name" value="" size="20"><br>
Surname:<input type="text" name="surname" value="" size="20"><br>
E - mail: <input type="text" name="email" value="" size="20"><br>
<input type="reset" value="Reset">
<input type="submit" name="sent" value="Register">
</form>
nakoniec dodam ze tento script som pisal pekne davno takze nie ze mi budete vycitat ze som lama
i ked ja vlastne som