Dark13 Posted January 11, 2007 Report Share Posted January 11, 2007 Man ir viena problema un del tam problemas rodas viens jautajums 1. Ka var uztaisit registracijas lapu ar visu datubazi? Link to comment Share on other sites More sharing options...
DaretodreaM Posted January 11, 2007 Report Share Posted January 11, 2007 samaksā kādam 20 Ls tev uztaisīs! Link to comment Share on other sites More sharing options...
Dark13 Posted January 12, 2007 Author Report Share Posted January 12, 2007 a nav nekur nekada pamaciba??? vai kads nevar biki apstastit?? Link to comment Share on other sites More sharing options...
DaretodreaM Posted January 12, 2007 Report Share Posted January 12, 2007 nu vareetu php fusion bet neiesaku! Link to comment Share on other sites More sharing options...
Dark13 Posted January 13, 2007 Author Report Share Posted January 13, 2007 man jau ir php-fusion ;P ej pasties Webs es gribu vnk pameginat pats uztaisit Link to comment Share on other sites More sharing options...
DaretodreaM Posted January 13, 2007 Report Share Posted January 13, 2007 Da nosākuma uztaisi tukšu webu Normāla ar kaut kādiem prikoliem piem ka no lasa no DB kaut ko un tt nevis uzreiz sāc ar tik grūtu lietu kā Login panel! Link to comment Share on other sites More sharing options...
Dark13 Posted January 13, 2007 Author Report Share Posted January 13, 2007 Man ir Microsoft Front page tur es panemu un uzreiz ieladeju template ar hyperlinkiem bet tur nav ar DB protais webs Link to comment Share on other sites More sharing options...
vincister Posted January 13, 2007 Report Share Posted January 13, 2007 ai čali - aizmirsti tu neuztaisīsi, tapēc ņem gatavu (visus tos gatavos forumus/web ar login/ etc.) jo uztaisīt to var tikai ilgā laikā un ar labu skilu programmēšanā (PHP / HTML etc.) Link to comment Share on other sites More sharing options...
Grow3r Posted January 13, 2007 Report Share Posted January 13, 2007 Paga vinchister! Vins jau var sakt iet uz datorkursiem! Lasit Skritosanas gramatas! Ja vins loti gribes vins vares visu! Bet tas jau ir vina rokas! Link to comment Share on other sites More sharing options...
darker Posted January 13, 2007 Report Share Posted January 13, 2007 (edited) http://www.techtuts.com/forums/index.php?showtopic=48 hope it helps tas tā sākumpunktam. Papriekšu būtu ieteicams iemācīties php pamatus. protams var jau visu copy 'n' paste L:D editz: nafig grower vajadzeja iepirst velreiz to linku, kuru es jau biju paspejis iebaazt? Edited January 13, 2007 by darker Link to comment Share on other sites More sharing options...
Grow3r Posted January 13, 2007 Report Share Posted January 13, 2007 (edited) Nemts no saita: http://www.techtuts.com/forums/index.php?showtopic=48 Database Setup We will use a database to store all the user information in. Once you have created a database, go to phpmyadmin and run this query: CREATE TABLE `users` ( `id` int(11) NOT NULL auto_increment, `username` varchar(30) NOT NULL default '', `password` varchar(255) NOT NULL default '', `email` varchar(40) NOT NULL default '', `msn` varchar(250) NOT NULL default 'Not Specified', `aim` varchar(250) NOT NULL default 'Not Specified', `location` varchar(36) NOT NULL default 'Not Specified', PRIMARY KEY (`id`) ) TYPE=MyISAM; Connecting to the database Now we need a file to connect to the database with. <? ob_start(); // allows you to use cookies $conn = mysql_connect("localhost","DATABASE USERNAME","DATABASE PASSWORD"); mysql_select_db(DATABASE NAME) or die(mysql_error()); //fill in the above lines where there are capital letters. $logged = MYSQL_QUERY("SELECT * from users WHERE id='$_COOKIE[id]'"); $logged = mysql_fetch_array($logged); //the above lines get the user's information from the database. ?> Save that file as config.php. Setup You will need to add some code to the TOP of every page you want to use the login system on. (not including the pages below). This is the code: <? ob_start(); include("config.php"); ?> We are now ready to start coding the pages. Register.php Register.php will allow users to register. Be sure to read the comments. <?php ob_start(); // allows you to use cookies include("config.php"); //gets the config page if ($_POST[register]) { // the above line checks to see if the html form has been submitted $username = $_POST[username]; $password = $_POST[pass]; $cpassword = $_POST[cpass]; $email = $_POST[emai1]; //the above lines set variables with the user submitted information if($username==NULL|$password==NULL|$cpassword==NULL|$email==NULL) { //checks to make sure no fields were left blank echo "A field was left blank."; }else{ //none were left blank! We continue... if($password != $cpassword) { // the passwords are not the same! echo "Passwords do not match"; }else{ // the passwords are the same! we continue... $password = md5($password); // encrypts the password $checkname = mysql_query("SELECT username FROM users WHERE username='$username'"); $checkname= mysql_num_rows($checkname); $checkemail = mysql_query("SELECT email FROM users WHERE email='$email'"); $checkemail = mysql_num_rows($checkemail); if ($checkemail>0|$checkname>0) { // oops...someone has already registered with that username or email! echo "The username or email is already in use"; }else{ // noone is using that email or username! We continue... $username = htmlspecialchars($username); $password = htmlspecialchars($password); $email = htmlspecialchars($email); // the above lines make it so that there is no html in the user submitted information. //Everything seems good, lets insert. $query = mysql_query("INSERT INTO users (username, password, email) VALUES('$username','$password','$email')"); // inserts the information into the database. echo "You have successfully registered!"; } } } } else { // the form has not been submitted...so now we display it. echo (" <center> <form method=\"POST\"> Username: <input type=\"text\" size=\"15\" maxlength=\"25\" name=\"username\"><br /> Password: <input type=\"password\" size=\"15\" maxlength=\"25\" name=\"pass\"><br /> Confirm Password: <input type=\"password\" size=\"15\" maxlength=\"25\" name=\"cpass\"><br /> Email: <input type=\"text\" size=\"15\" maxlength=\"25\" name=\"emai1\"><br /> <input name=\"register\" type=\"submit\" value=\"Register\"> </form> </center> "); } ?> Login.php Now that people can register, we need to let them login!. You can put this code in a block on your site, or put it in a blank page. <? oB_start(); // allows you to use cookies. include("config.php"); if (!$logged[username]) { if (!$_POST[login]) { echo(" <center><form method=\"POST\"> <table> <tr> <td align=\"right\"> Username: <input type=\"text\" size=\"15\" maxlength=\"25\" name=\"username\"> </td> </tr> <tr> <td align=\"right\"> Password: <input type=\"password\" size=\"15\" maxlength=\"25\" name=\"password\"> </td></tr><tr> <td align=\"center\"> <input type=\"submit\" name=\"login\" value=\"Login\"> </td></tr><tr> <td align=\"center\"> <a href=\"register.php\">Register Here</a> </td></tr></table></form></center>"); } if ($_POST[login]) { // the form has been submitted. We continue... $username=$_POST['username']; $password = md5($_POST[password]); // the above lines set variables with the submitted information. $info = mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error()); $data = mysql_fetch_array($info); if($data[password] != $password) { // the password was not the user's password! echo "Incorrect username or password!"; }else{ // the password was right! $query = mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error()); $user = mysql_fetch_array($query); // gets the user's information setcookie("id", $user[id],time()+(60*60*24*5), "/", ""); setcookie("pass", $user[password],time()+(60*60*24*5), "/", ""); // the above lines set 2 cookies. 1 with the user's id and another with his/her password. echo ("<meta http-equiv=\"Refresh\" content=\"0; URL=http://yoursite.com\"/>Thank You! You will be redirected"); // modify the above line...add in your site url instead of yoursite.com } } } else { // we now display the user controls. echo ("<center>Welcome <b>$logged[username]</b><br /></center> - <a href=\"editprofile.php\">Edit Profile</a><br /> - <a href=\"members.php\">Member List</a><br /> - <a href=\"logout.php\">Logout</a>"); } ?> Edit Profile This page will allow users to update their information. Save it as editprofile.php. <? ob_start(); include("config.php"); if ($logged[username]) { // the user is logged in! We continue... if (!$_POST[update]) { // the form hasn't been submitted. We continue... $profile = mysql_query("SELECT * from users where username = '$logged[username]'"); $profile = mysql_fetch_array($profile); // the above lines get the information so that it can be displayed in the html form. echo(" <center><form method=\"POST\"> <table width=\"100%\"> <tr> <td align=\"right\" width=\"25%\"> Location </td> <td align=\"left\"> <input type=\"text\" size=\"25\" maxlength=\"25\" name=\"locate\" value=\"$profile[location]\"></td> </tr> <tr> <td align=\"right\" width=\"25%\"> MSN Messenger </td> <td align=\"left\"> <input size=\"25\" name=\"msn\" value=\"$profile[msn]\"></td> </tr> <tr> <td align=\"right\" width=\"25%\"> AOL Messenger</td> <td align=\"left\"> <input size=\"25\" name=\"aim\" value=\"$profile[aim]\"></td> </tr> <tr> <td align=\"right\" width=\"25%\"> Email Address</td> <td align=\"left\"> <input size=\"25\" name=\"email\" value=\"$profile[email]\"></td> </tr> <tr> <td align=\"center\"> </td> <td align=\"left\"> <input type=\"submit\" name=\"update\" value=\"Update\"></td> </tr> </table> </form> </center>"); } else { $email = htmlspecialchars($_POST[email]); $aim = htmlspecialchars($_POST[aim]); $msn = htmlspecialchars($_POST[msn]); $locate = htmlspecialchars($_POST[locate]); // the above lines get rid of all html. echo ("Your profile has been updated!"); $update = mysql_query("Update users set email = '$email', msn = '$msn', aim = '$aim', location = '$locate' where username = '$logged[username]'"); // updates the information in the database. } } else { // They aren't logged in! echo ("<a href=\"login.php\">You must login</a>"); } ?> Display Users Information Now we need to have a page where members can view other member's profiles. Use this code, and save this as members.php. <? ob_start(); include("config.php"); if (!$_GET[user]) { $getuser = mysql_query("SELECT * from users order by id asc"); while ($user = mysql_fetch_array($getuser)) { // gets all the users information. echo ("<a href=\"members.php?user=$user[username]\">$user[username]</a><br />\n"); // links to a page to view the user's profile. } } ELSE { $getuser = mysql_query("SELECT * from users where username = '$_GET[user]'"); $usernum = mysql_num_rows($getuser); if ($usernum == 0) { echo ("User Not Found"); } else { $profile = mysql_fetch_array($getuser); echo ("<center><b>$profile[username]'s Profile:</b><br /></center> MSN Messenger: $profile[msn]<br /> AIM Messebger: $profile[aim]<br /> Location: $profile[location]<br /> Email: $profile[email]"); // in the above code, we display the user's information. } } ?> Logout.php This page logs the user out. It just updates the cookie with false information. <? ob_start(); setcookie("id", 2132421,time()+(60*60*24*5), "/", ""); setcookie("pass", loggedout,time()+(60*60*24*5), "/", ""); echo ("You are now logged out!"); ?> That concludes this huge tutorial. If you need any help please leave a comment below. Showing the login box in a content box Add this code where you want the login system: <? include("login.php"); ?> Members Only Pages Use this code for a members only page. <? ob_start(); include("config.php"); if ($logged[username]) { echo("You are logged in"); } else { echo("You are not logged in"); } ?> Domaju ka palidzes! Sita laba pamaciba! Pats kautkad saksu veidot savu WEB nevis php-Fusion un izmantosu kautko no sita! Edited January 13, 2007 by Grow3r Link to comment Share on other sites More sharing options...
DaretodreaM Posted January 13, 2007 Report Share Posted January 13, 2007 kas ir tas query? nesaprotu! Link to comment Share on other sites More sharing options...
Grow3r Posted January 13, 2007 Report Share Posted January 13, 2007 Ko tiesi tu nesaproti??? Link to comment Share on other sites More sharing options...
DaretodreaM Posted January 13, 2007 Report Share Posted January 13, 2007 es piem gribu iekopeet to kodu ieksh users tabuas bet vinjsh saka ka taada tabula jau eksistee!! pasaki luudzu skype niku! Link to comment Share on other sites More sharing options...
JuiCe Posted January 13, 2007 Report Share Posted January 13, 2007 Ja grib kaut ko macities par php jasak, ar html. Labi visi apskaidrots pa html tur ari ir css turiali. Vajag tikai palasit ir ari ka izveidot sadus panelus. Link to comment Share on other sites More sharing options...
Dark13 Posted January 17, 2007 Author Report Share Posted January 17, 2007 (edited) Liels tev paldies Grow3r un velviens jautajumins ka var html lapa ieklaut php kodu?? Edited January 17, 2007 by Dark13 Link to comment Share on other sites More sharing options...
darker Posted January 17, 2007 Report Share Posted January 17, 2007 (edited) Liels tev paldies Grow3r un velviens jautajumins ka var html lapa ieklaut php kodu?? 1kārt pārsauc savu dokumentu uz tavsnosaukums.php, nevis.html un kur tu gribi iebāzt savu php scriptu raksti <?php tavs_kods; ?> protams var jau ari <?php tavs_kods; ?> Edited January 17, 2007 by darker Link to comment Share on other sites More sharing options...
Dark13 Posted January 17, 2007 Author Report Share Posted January 17, 2007 nju labi bet piemeram ir kaut kads tur .php kods ka lai es ielieku tur kaut ko no html koda lai vins stradatu?? tur nbebija gadijuma kautkads echo?? Link to comment Share on other sites More sharing options...
Kavacky Posted January 17, 2007 Report Share Posted January 17, 2007 jo uztaisīt to var tikai ilgā laikā un ar labu skilu programmēšanā (PHP / HTML etc.) Vienkārši logins ar pāris huiņām nav pat pusstundas jautājums. A PHP kodam par HTML nospļauties. Principā jams ļoti labi strādā arī nesaistīti ar HTML vai internetu vispār. Kaut kas jāizvada ( ar to pašu echo ) ir tad, ja tu gribi, lai kaut ko noteiktu parāda pārlūkā. Link to comment Share on other sites More sharing options...
vincister Posted January 18, 2007 Report Share Posted January 18, 2007 Vienkārši logins ar pāris huiņām nav pat pusstundas jautājums. ar uzsvaru uz vienkāršs jā es ar tādu varu ātri uztaisīt, bet tādā līmenī lai no tā būtu kāds labums ir jātaisa visa lapa un diezgan vēl jātestē vai nav caurumi Link to comment Share on other sites More sharing options...
Dr. Pain Posted January 18, 2007 Report Share Posted January 18, 2007 logins-shmogins! vispirms vajag labu ideju lapai, nevis vienkaarshi uzbliezt lapu, kuraa ir pieregojushies tavi 7 klana biedri (ieksaitot to, kursh klanu pameta) un 3 klasesbiedri (kuriem tu paluudzi). ar to arii beidzam! Link to comment Share on other sites More sharing options...
Recommended Posts