Nero Posted March 4, 2010 Report Share Posted March 4, 2010 Man vajag ielikt webaa php registreties un loginu,apnikas jau caur ipb....kads var pateikt kodus un ka kas pareizi jaieliek? Quote Link to comment Share on other sites More sharing options...
briedis Posted March 4, 2010 Report Share Posted March 4, 2010 Man vajag ielikt webaa php registreties un loginu,apnikas jau caur ipb....kads var pateikt kodus un ka kas pareizi jaieliek? Pameklē gūglē "php login script" vai tepat forumā... Quote Link to comment Share on other sites More sharing options...
Martiny Posted March 4, 2010 Report Share Posted March 4, 2010 (edited) Forumā bija kaut kas tāds -> login-form.php <html> <head> <title>Login page</title> <?php session_start(); $_SESSION['rand']=mt_rand(1, 10000); ?> </head> <body> <form action="secure-page.php" method="post"> user:<input name="usr" type="text" /><br /> password:<input name="pwd" type="password" /><br /> <input name="verify" type="hidden" value="<?php echo $_SESSION['rand']; ?>" /> <input name="ok" type="submit" /> </form> </body> </html> secure-page.php <?php ob_start(); session_start(); if ($_COOKIE['auth']=='logged_in' ) { echo 'protected page'; } elseif ($_POST['verify']==$_SESSION['rand']) { $connect = mysql_connect("localhost", "root", "") or die("bad connection"); mysql_select_db("some_database"); $usr=mysql_real_escape_string($_POST['usr']); $pwd=mysql_real_escape_string($_POST['pwd']); if ( $usr=='mike' && $pwd=='secret' ) { setcookie('auth','logged_in'); echo 'protected page'; } else { echo 'incorrect credentials '; } } else { echo 'you are not authorized to view this page!'; } ob_end_flush(); ?> Edited March 4, 2010 by Martiny Quote Link to comment Share on other sites More sharing options...
Martiny Posted March 4, 2010 Report Share Posted March 4, 2010 Piedod Nero, tas tāds s.....s piemērs. Te būs vēl. <?php //include("../config.php"); if(isset($_POST['nick'])) { $kludas =array(); if($_POST['parole1'] != $_POST['parole2']) $kludas[] = 'Paroles nesakrit'; if(strlen($_POST['nick']) <=3 ) $kludas[] = 'Ievaditais Lietotaj vards ir parak iss Minimalas prasibas ir 4 simboli!'; if(strlen($_POST['parole1']) <=6 ) $kludas[] = 'Ievaditais Parole ir parak iss Minimalas prasibas ir 6 simboli!'; #ja nau kludu if(count($kludas) == 0) { $niks = quote_smart($_POST['nick']); $parole = quote_smart(md5($_POST['parole1'])); $result = mysql_query("SELECT COUNT(*) FROM lietotaji WHERE nick = $niks"); $rezultats_kopa = mysql_result($result,0,'COUNT(*)'); if($rezultats_kopa > 0) { $kludas[] = 'Sads lietotajs jau eksiste'; } else { mysql_query("INSERT INTO lietotaji (nick,parole,tips) VALUES ($niks,$parole,1)"); $kludas[] = 'veiksmigi izveidots lietotajs'; } } foreach($kludas as $kluda) { echo '<p>'. $kluda .'</p>'; //echo "$kluda"; } } ?> <form method="post"> <table border="1"> <tr><td>Lietotajvards:</td><td> <input type="text" name="nick" /></td></tr> <tr><td>parole:</td><td> <input type="password" name="parole1" /></td></tr> <tr><td>Parole atkartot :</td><td> <input type="password" name="parole2" /></td></tr> <td><input type="submit" value="submit" /></td> </table> </form> Uz doto brīdi arī es strādāju pie lietotāju reģistrācijas formas un te iepostoju jautājumu par formā ievadīto datu pārbaudi. Lai veicas! Quote Link to comment Share on other sites More sharing options...
Kemito Posted March 4, 2010 Report Share Posted March 4, 2010 OMG lasīt protat, ka garos kodus jāliek ir - paste.php.lv ? Quote Link to comment Share on other sites More sharing options...
Martiny Posted March 4, 2010 Report Share Posted March 4, 2010 Kemito, kurš no tiem tev bij garš kods? Es labāk izvēlos 1000 rindiņu vienā failā nevis 1000 failus, kur katrā pa vienai rindiņai. Quote Link to comment Share on other sites More sharing options...
2easy Posted March 4, 2010 Report Share Posted March 4, 2010 šis nu toč nebija garš kods! imho, ~50 rindiņas var droši te postot. ja tuvojas simtam, tad jau gan paliek tā padaudz priekš posta Quote Link to comment Share on other sites More sharing options...
Nero Posted March 4, 2010 Author Report Share Posted March 4, 2010 paldies martiny :) Quote Link to comment Share on other sites More sharing options...
Martiny Posted March 5, 2010 Report Share Posted March 5, 2010 Ja jāpārbauda e-pasta adrese // Pārbaudu vai e-pasta adrese atbilst nosacījumiem if (!preg_match('/^(\w+\.)*(\w+)@(\w+\.)+(\w+)$/', $user_email)) { echo '<p class="zinojums"><b>Nekorekta e-pasta adrese.</b></p>'; } Quote Link to comment Share on other sites More sharing options...
2easy Posted March 5, 2010 Report Share Posted March 5, 2010 pusi no tām iekavām var nelietot, bet ir ok ;) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.