Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include('config.php');
- ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <link href="<?php echo $design; ?>/style.css" rel="stylesheet" title="Style" />
- <title>Sign up</title>
- </head>
- <body>
- <div class="header">
- <a href="<?php echo $url_home; ?>"><img src="<?php echo $design; ?>/images/logo.png" alt="Members Area" /></a>
- </div>
- <?php
- //We check if the form has been sent
- if(isset($_POST['username'], $_POST['password'], $_POST['passverif'], $_POST['email'], $_POST['vardas'],$_POST['pavarde'],$_POST['amzius']) and $_POST['username']!='')
- {
- //We remove slashes depending on the configuration
- if(get_magic_quotes_gpc())
- {
- $_POST['username'] = stripslashes($_POST['username']);
- $_POST['password'] = stripslashes($_POST['password']);
- $_POST['passverif'] = stripslashes($_POST['passverif']);
- $_POST['email'] = stripslashes($_POST['email']);
- $_POST['vardas'] = stripslashes($_POST['vardas']);
- $_POST['pavarde'] = stripslashes($_POST['pavarde']);
- $_POST['metai'] = (int)$_POST['metai'];
- $_POST['menuo'] = (int)$_POST['menuo'];
- $_POST['diena'] = (int)$_POST['diena'];
- $birthdate = new DateTime( $_POST['diena']."-".$_POST['menuo']."-".$_POST['diena']);
- $today = new DateTime();
- $interval = $today->diff($birthdate);
- echo $interval->format('%y years');
- $amzius= $interval->format('%y years');
- $cenzas='18' ;
- }
- if($cenzas<18) {
- //We check if the two passwords are identical
- if($_POST['password']==$_POST['passverif'])
- {
- //We check if the password has 6 or more characters
- if(strlen($_POST['password'])>=6)
- {
- //We check if the email form is valid
- if(preg_match('#^(([a-z0-9!\#$%&\\\'*+/=?^_`{|}~-]+\.?)*[a-z0-9!\#$%&\\\'*+/=?^_`{|}~-]+)@(([a-z0-9-_]+\.?)*[a-z0-9-_]+)\.[a-z]{2,}$#i',$_POST['email']))
- {
- //We protect the variables
- $username = mysql_real_escape_string($_POST['username']);
- $password = mysql_real_escape_string($_POST['password']);
- $email = mysql_real_escape_string($_POST['email']);
- $vardas = mysql_real_escape_string($_POST['vardas']);
- $pavarde = mysql_real_escape_string($_POST['pavarde']);
- $amzius = mysql_real_escape_string($_POST['amzius']);
- $_POST['metai'] = (int)$_POST['metai'];
- $_POST['menuo'] = (int)$_POST['menuo'];
- $_POST['diena'] = (int)$_POST['diena'];
- $birthdate = new DateTime( $_POST['diena']."-".$_POST['menuo']."-".$_POST['diena']);
- $today = new DateTime();
- $interval = $today->diff($birthdate);
- echo $interval->format('%y years');
- //We check if there is no other user using the same username
- $dn = mysql_num_rows(mysql_query('select id from users where username="'.$username.'"'));
- if($dn==0)
- {
- //We count the number of users to give an ID to this one
- $dn2 = mysql_num_rows(mysql_query('select id from users'));
- $id = $dn2+1;
- //We save the informations to the databse
- $rank = 0;
- $amzius= $interval->format('%y years');
- if(mysql_query('insert into users(id, username, password, email,name,last_name,age,rank, signup_date) values ('.$id.', "'.$username.'", "'.$password.'", "'.$email.'", "'.$vardas.'", "'.$pavarde.'", "'.$amzius.'","'.$rank.'", "'.time().'")'))
- {
- //We dont display the form
- $form = false;
- ?>
- <div class="message">Jūs sėkmingai užsiregistravote. Darbar galite prisijungti<br />
- <a href="connexion.php">Prisijungti</a></div>
- <?php
- }
- else
- {
- //Otherwise, we say that an error occured
- $form = true;
- $message = 'Registruojantis įvyko klaida.';
- }
- }
- else
- {
- //Otherwise, we say the username is not available
- $form = true;
- $message = 'Slapyvardis kurį įvedėte yra užimtas. Prašome pasirinkti kitą.';
- }
- }
- else
- {
- //Otherwise, we say the email is not valid
- $form = true;
- $message = 'El.paštas įvestas neteisingai.';
- }
- }
- else
- {
- //Otherwise, we say the password is too short
- $form = true;
- $message = 'Slaptažodis turi susidėti iš mažiausiai 6 simbolių.';
- }
- }
- else
- {
- //Otherwise, we say the passwords are not identical
- $form = true;
- $message = 'Slaptažodžiai nesutampa.';
- }
- }
- else
- {
- //Otherwise, we say the passwords are not identical
- $form = true;
- $message = 'Tau nėra 18metų';
- }
- }
- else
- {
- $form = true;
- }
- if($form)
- {
- //We display a message if necessary
- if(isset($message))
- {
- echo '<div class="message">'.$message.'</div>';
- }
- //We display the form
- ?>
- <div class="content1">
- <form action="sign_up.php" method="post">
- Prašome užpildyti apačioje pateikta registracijos formą:<br />
- <div class="center">
- <label for="username">Slapyvardis</label><input type="text" name="username" value="<?php if(isset($_POST['username'])){echo htmlentities($_POST['username'], ENT_QUOTES, 'UTF-8');} ?>" /><br />
- <label for="password">Slaptažodis<span class="small">(6 simboliai min.)</span></label><input type="password" name="password" /><br />
- <label for="passverif">Slaptažodis<span class="small">(pakartotinai)</span></label><input type="password" name="passverif" /><br />
- <label for="email">El.paštas</label><input type="text" name="email" value="<?php if(isset($_POST['email'])){echo htmlentities($_POST['email'], ENT_QUOTES, 'UTF-8');} ?>" /><br />
- <label for="avatar">Vardas<span class="small"></span></label><input type="text" name="vardas" value="<?php if(isset($_POST['vardas'])){echo htmlentities($_POST['vardas'], ENT_QUOTES, 'UTF-8');} ?>" /><br />
- <label for="avatar">Pavardė<span class="small"></span></label><input type="text" name="pavarde" value="<?php if(isset($_POST['pavarde'])){echo htmlentities($_POST['pavarde'], ENT_QUOTES, 'UTF-8');} ?>" /><br />
- <label for="avatar">Amžius<span class="small"></span></label><input type="number" name="amzius" value="<?php if(isset($_POST['amzius'])){echo htmlentities($_POST['amzius'], ENT_QUOTES, 'UTF-8');} ?>" /><br />
- Gimimo data:
- <select name="year" id="year" value="<?php if(isset($_POST['metai'])){echo htmlentities($_POST['metai'], ENT_QUOTES, 'UTF-8');} ?>">
- <option value="na">Metai</option>
- </select>
- <select name="month" onChange="changeDate(this.options[selectedIndex].value);" value="<?php if(isset($_POST['menuo'])){echo htmlentities($_POST['menuo'], ENT_QUOTES, 'UTF-8');} ?>">
- <option value="na">Mėnuo</option>
- <option value="1">Sausis</option>
- <option value="2">Vasaris</option>
- <option value="3">Kovas</option>
- <option value="4">Balandis</option>
- <option value="5">Gegužė</option>
- <option value="6">Birželis</option>
- <option value="7">Liepa</option>
- <option value="8">Rugpjūtis</option>
- <option value="9">Rugsėjis</option>
- <option value="10">Spalis</option>
- <option value="11">Lapkritis</option>
- <option value="12">Gruodis</option>
- </select>
- <select name="day" id="day" value="<?php if(isset($_POST['diena'])){echo htmlentities($_POST['diena'], ENT_QUOTES, 'UTF-8');} ?>">
- <option value="na">Diena</option>
- </select>
- <script language="JavaScript" type="text/javascript">
- function changeDate(i){
- var e = document.getElementById('day');
- while(e.length>0)
- e.remove(e.length-1);
- var j=-1;
- if(i=="na")
- k=0;
- else if(i==2)
- k=28;
- else if(i==4||i==6||i==9||i==11)
- k=30;
- else
- k=31;
- while(j++<k){
- var s=document.createElement('option');
- var e=document.getElementById('day');
- if(j==0){
- s.text="Day";
- s.value="na";
- try{
- e.add(s,null);}
- catch(ex){
- e.add(s);}}
- else{
- s.text=j;
- s.value=j;
- try{
- e.add(s,null);}
- catch(ex){
- e.add(s);}}}}
- y = 1993;
- while (y-->1940){
- var s = document.createElement('option');
- var e = document.getElementById('year');
- s.text=y;
- s.value=y;
- try{
- e.add(s,null);}
- catch(ex){
- e.add(s);}}
- </script>
- <input type="submit" value="Sign up" />
- </div>
- </form>
- </div>
- <?php
- }
- ?>
- <div class="foot"><a href="<?php echo $url_home; ?>">Go Home</a> - <a href="http://www.webestools.com/">Webestools</a></div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement