Jump to content
php.lv forumi

daGrevis

Reģistrētie lietotāji
  • Posts

    4824
  • Joined

  • Last visited

Everything posted by daGrevis

  1. Diemžēl lapas izskats neviešs uzticību par hostingu... Par dizainu vajadzētu padomāt... :)
  2. Izdomāju ka vajag izveidot tā, ka atverot lapu ar datoru ir HTML layouts, bet verot vaļā ar mobīlā WAP'u ir WML... Viss takā jau jauki, bet kā lai izveido, ka veidojot lapu, kurā ir teikumi kas ir ielikti HTML "<p>" tagā normāli attēlojas uz WML? Dublēt info un katru likt savā layouts mapē nebūtu gudri, ne?
  3. Centīšos, tikai gribēju pateikt ka šitas sviests ir manis veidots. :D
  4. Paskaties core.php ko dara funkcija redirectTo! :) Problēma tāda, ka ir header already send errors, bet nezinu kā sataisīt lai tas errors tur nebūtu... :(
  5. Nu pagaidām viedoju tikai lai pamācītos PHP praksē, bet saksaros ar problēmu, ka nevaru sakarīgi lietotāju pēc reģistrācijas (signup.php) pārmest uz index.php. P.S. Zinu ka līkaku sourci par šito nevar atrast, bet tikai mācos. http://yy.lv/download.php?f=38179
  6. Problēma ir pavisam vienkārša. Ir galvenais fails (core.php), kurā ir norādīts "$rootPath" un "$stylePath". $rootPath = $serverProtocol . "://" . $serverDirectory . "/" . $serverSubDirectory . "/"; $stylePath = $rootPath . "styles/" . $defaultStyle . "/"; Tad core.php ir iekļauts konfigurācijas fails. $serverProtocol = 'http'; $serverDirectory = '127.0.0.1'; $serverSubDirectory = 'prototype'; $defaultStyle = "proLite"; Veidojot funkciju core.php failā - "overallHeader", dabūju šādu ķļudu. Warning: require() [function.require]: URL file-access is disabled in the server configuration in D:\xampp\htdocs\prototype\includes\core.php on line 39 Warning: require(http://127.0.0.1/prototype/styles/proLite/overallHeader.php) [function.require]: failed to open stream: no suitable wrapper could be found in D:\xampp\htdocs\prototype\includes\core.php on line 39 Fatal error: require() [function.require]: Failed opening required 'http://127.0.0.1/prototype/styles/proLite/overallHeader.php' (include_path='.;D:\xampp\php\pear\') in D:\xampp\htdocs\prototype\includes\core.php on line 39 Funkcija izskatāš šāda. function overallHeader($pageTitle = "") { global $alive, $siteTitle, $stylePath; if(!$alive) { echo "Site is down for maintenance, please check back again later..."; die; } if($pageTitle == "") { $pageTitle = $siteTitle; } header("Content-Type: text/html; charset=utf-8"); require $stylePath . "overallHeader.php"; } Idejas? Vai norādīt "root" mainīgos savādāk, vai ieslēgt serveī tādu iespēju? ;?
  7. Atvainojos ka nemeklēju... Paldies par risinājumu! :)
  8. Problēma jau itkā nav problēma... :D function redirectToIndex() { header('Location: index.php'); } ...un tur, kur vajag, lai lapa pārdirektējās, likt, lai izpildās šī funkcija... Problēma! Ko darīt, ja izmetas šāds "error's"? Warning: Cannot modify header information - headers already sent by (output started at D:\xampp\htdocs\ProToType\styles\peace\overallHeader.php:4) in D:\xampp\htdocs\ProToType\includes\core.php on line 10
  9. Nesaprotu kādēļ visu tā sarežģīt... Sākumā pastāsti, kam kods būs domāts?
  10. Skaidrs, jau domāju, ka tieši tāda būs atbilde + paldies par iepriekšējo atbildi... ;)
  11. Te nu es tev nepiekrītu... Ja iekļauj jebko ar "include", tad ja kaut kas neeksistē, tad nekas neparādās - nereaģē, ber ar "require" izmet kļūdu... Vai varbūt Es vienkārši nezinu kas ir "warning's" un kur to var redzēt? Ja nezinu, tad apgaismojiet mani... :D
  12. Iedod kodu, lai palīdzētu izlabot... ;)
  13. Tu jau bezproblēmām atrast "guglē" pamācību, kā pat nezinot PHP un MySQL pamatus izveidot tādu iespēju lapai, ka vari caur KP pievienot/rediģēt rakstus... ;)
  14. Vai tad, loģiski nav tas, ka uzrakstot... <?php include 'example.txt'; ?> ...man iekļauj vienu reizi failu "example.txt"... Tad kāpēc ir "include_once", kura dara to pašu?! ;?
  15. Nekas tā tev nesanāks... :( Tur vajag mainīt sesijas, apvienot datubāzes... :( Nav vienkāršāk parasto "phpBB" pārmodificēt ar dažām modifikācijām par tādu, kam ir "wordpress" iespējas? Noderīgi resursi varētu būt - http://phpbb.com/ un http://phpbbgods.org/ ... ;)
  16. Cik es sapratu, kad man skaidroja šīs lietas viens čalīts, tas sesijas id ("sid") normālās lapās aiz lapas linka vajadzētu padoties tikai tad, ja lietotājam ir izslēgti "cookies"... Un droši zinu, ka "cookies" nav tik droši kā sesijas, jo tos, pa visam vienkārši, var nozagt... :)
  17. Šeit ir reģistrēšanās un ielogošanās sistēma, kurā ir daži "bugiņi", kā piemēram, ka nevar ielogoties [ :D ], un prasu jums, kā to varētu izlabot... Ceru, ka palīdzēsiet, jo viens pats to nevaru, jo ar PHP neesmu tik lielos draugos [ pagaidām ], tap\ec prasu jums... :) Kļūda ir tāda, ka ieejot /login.php, un savadot savus datus, izmet šādu kļūdu - There was an error: , please try again. ! MySQL ieraksts CREATE TABLE `users` ( `id` INT( 5 ) NOT NULL AUTO_INCREMENT, `username` VARCHAR( 20 ) NOT NULL, `password` VARCHAR( 32 ) NOT NULL, PRIMARY KEY ( `id` ) ) TYPE=MyISAM; /functions.php <?php function user_register($username, $password) { // Now encrypt the password, using md5; $encrypted = md5($password); // Store the information in the database; $query = "INSERT INTO users (username, password) VALUES ('$username', '$encrypted')"; mysql_query ($query) or die ('Could not create user!'); } function user_login($username, $password) { // Try and get the user using the username & encrypted pass $query = "SELECT id, username FROM users WHERE username='$username' and password='$password'"; $result = mysql_query($query); $user = mysql_fetch_array($result); $numrows = mysql_num_rows($result); // Now encrypt the data to be stored in the session $encrypted_id = md5($user['id']); $encrypted_name = md5($user['username']); // Store the data in the session $_SESSION['id'] = $id; $_SESSION['username'] = $username; $_SESSION['encrypted_id'] = $encrypted_id; $_SESSION['encrypted_name'] = $encrypted_name; if ($numrows == 1) { return 'Correct'; } else { return false; } } function user_logout() { // End the session and unset all vars session_unset (); session_destroy (); } function is_authed() { // Check if the encrypted username is the same // as the unencrypted one, if it is, it hasn't been changed if (isset($_SESSION['username']) && (md5($_SESSION['username']) == $_SESSION['encrypted_name'])) { return true; } else { return false; } } ?> /init.php <?php // Start the session session_start(); // MySQL Settings $db_host = 'localhost'; $db_user = 'root'; $db_pass = ''; $db_database = 'db'; // Connect to the database mysql_connect ($db_host, $db_user, $db_pass) or die ('Could not connect to the database.'); mysql_selectdb ($db_database) or die ('Could not select database.'); // Seed the random number generator srand(); // Include functions include 'functions.php'; ?> /register.php <?php // Include init file include 'init.php'; if (!isset($_POST['submit'])) { // Show the form include 'register_form.inc.php'; exit; } else { // Check if any of the fields are missing if (empty($_POST['username']) || empty($_POST['password']) || empty($_POST['confirmpass'])) { // Reshow the form with an error $reg_error = 'One or more fields missing'; include 'register_form.inc.php'; exit; } // Check if the passwords match if ($_POST['password'] != $_POST['confirmpass']) { // Reshow the form with an error $reg_error = 'Your passwords do not match'; include 'register_form.inc.php'; exit; } // Everything is ok, register user_register ($_POST['username'], md5($_POST['password'])); echo 'Thank you for registering on our site, <a href="index.php">click here</a> to go back.'; } ?> /register_form.inc.php <?php if (isset($reg_error)) { ?> There was an error: <?php echo $reg_error; ?>, please try again. <?php } ?> <form action="register.php" method="post"> <b>Username:</b> <input type="text" size="20" maxlength="20" name="username" <?php if (isset($_POST['username'])) { ?> value="<?php echo $_POST['username']; ?>" <?php } ?>/><br /> <b>Password:</b> <input type="password" size="20" maxlength="10" name="password" /><br /> <b>Confirm Password:</b> <input type="password" size="20" maxlength="10" name="confirmpass" /><br /> <input type="submit" name="submit" value="Register!" /> </form> /login.php <?php // Include init file include 'init.php'; if (!isset($_POST['submit'])) { // Show the form include 'login_form.inc.php'; exit; } else { // Try and login with the given username & pass $result = user_login($_POST['username'], $_POST['password']); if ($result != 'Correct') { // Reshow the form with the error $login_error = $result; include 'login_form.inc.php'; } else { echo 'Thank you for logging in, <a href="index.php">click here</a> to go back.'; } } ?> /login_form.inc.php <?php if (isset($reg_error)) { ?> There was an error: <?php echo $reg_error; ?>, please try again. <?php } ?> <form action="register.php" method="post"> <b>Username:</b> <input type="text" size="20" maxlength="20" name="username" <?php if (isset($_POST['username'])) { ?> value="<?php echo $_POST['username']; ?>" <?php } ?>/><br /> <b>Password:</b> <input type="password" size="20" maxlength="10" name="password" /><br /> <b>Confirm Password:</b> <input type="password" size="20" maxlength="10" name="confirmpass" /><br /> <input type="submit" name="submit" value="Register!" /> </form> /index.php <?php include 'init.php'; if (!is_authed()) { die ('You are not permitted to view this page!'); } ?> All works! Ceru, ka palīdzēsiet... ;)
  18. Divi jautājumiņi... P.S. zekils, tavs kods strādāja - paldies... :) 1) Ko es failā login.php uzrakstīju nepareizi, ka man met arā "erroru", lai gan viss pārējais strādā... ;) login.php <?php require "includes/core.php"; stdhead("Ielogošanās"); if (isset($_GET['d']) and $_GET['d'] == "ok") { $dbhost = "localhost"; $dbname = "mysource"; $dbuser = "root"; $dbpass = ""; mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Nevarēja piekonektēties: ".mysql_error()); mysql_select_db($dbname) or die(mysql_error()); session_start(); $nick = $_POST['nick']; $pass = md5($_POST['pass']); $query = "select * from users where nick='$nick' and pass='$pass'"; $result = mysql_query($query); if (mysql_num_rows($result) != 1) { echo "Nepareiza info!"; } else { $_SESSION['nick'] = "$nick"; echo "Veiksmīgi!"; } } ?> <form name="login" method="post" action="login.php?d=ok"> <table border="0" width="225" align="center"> <tr> <td width="219" bgcolor="#999999"> <p align="center"><font color="white"><span style="font-size:12pt;"><b>Login</b></span></font></p> </td> </tr> <tr> <td width="219"> <table border="0" width="220" align="center"> <tr> <td width="71"><span style="font-size:10pt;">Nick:</span></td> <td width="139"><input type="text" name="nick"></td> </tr> <tr> <td width="71"><span style="font-size:10pt;">Pass:</span></td> <td width="139"><input type="password" name="pass"></td> </tr> <tr> <td width="71"> </td> <td width="139"><p align="right"><input type="submit" name="submit" value="Submit"></p></td> </tr> </table> </td> </tr> <tr> <td width="219" bgcolor="#999999"><font color="white">Not Registered? </font><a href="signup.php" target="_self"><font color="white">Register</font></a><font color="white"> </font><b><i><font color="white">Now!</font></i></b></td> </tr> </table> </form> <?php stdfoot(); ?> Met ārā šo... Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at D:\xampp\htdocs\includes\core.php:59) in D:\xampp\htdocs\login.php on line 18 core.php - 59 line... <title><?php echo $title; ?></title> 2) Vai varu darīt šādi, un vai tas nekaitēs drošībai? Tajās vietās kur ir dati par savienošanos ar db, izdarīt šādi... require "includes/secrets.php" P.S. Man inludes mapei ir htaccess, ka nevar tā pat piekļūt... ;)
  19. Sapratu - izlaboju! :) Paldies... Vai ir iespējams to take_x.php savienot ar x.php vienā failā?
  20. Jā, kad piereģistrējos, tad DB parādās jauns ieraksts, bet kad mēģinu ielogoties, izlec - "Nepareiza info!"... ..., lai gan tā nav... :(
  21. Labdien! PHP un MySQL tikai mācos, tapēc noteikti tur ir pilns ar kļūdām un citām sliktām lietām, bet vēlējos tomēr novērst šo ķibeli... :) Viss ar piereģistrēšanos strādā, bet ielogošanās gan nē... Par to atbild fails "take_login.php"... Kas tur par vainu? P.S. Tas nav mans kods, atradu kautkur netā, un centos pielabot... SQL CREATE TABLE `users` ( `id` int(25) NOT NULL auto_increment, `nick` varchar(25) NOT NULL default '', `pass` varchar(255) NOT NULL default '', `email` varchar(255) NOT NULL default '', PRIMARY KEY (id), UNIQUE KEY nick (nick) ) TYPE=MyISAM; signup.php <?php require "includes/core.php"; stdhead("Reģistrācija"); ?> <form name="login" method="post" action="take_signup.php"> <table border="0" width="225" align="center"> <tr> <td width="219" bgcolor="#999999"> <p align="center"><font color="white"><span style="font-size:12pt;"><b>Registration</b></span></font></p> </td> </tr> <tr> <td width="219"> <table border="0" width="282" align="center"> <tr> <td width="116"><span style="font-size:10pt;">Email:</span></td> <td width="156"><input type="text" name="email" maxlength="100"></td> </tr> <tr> <td width="116"><span style="font-size:10pt;">Username:</span></td> <td width="156"><input type="text" name="nick"></td> </tr> <tr> <td width="116"><span style="font-size:10pt;">Password:</span></td> <td width="156"><input type="password" name="pass"></td> </tr> <tr> <td width="116"> </td> <td width="156"> <p align="right"><input type="submit" name="submit" value="Submit"></p> </td> </tr> </table> </td> </tr> <tr> <td width="219" bgcolor="#999999"> </td> </tr> </table> </form> <?php stdfoot(); ?> take_signup.php <?php $dbhost = "localhost"; $dbname = "mysource"; $dbuser = "root"; $dbpass = ""; mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Nevarēja piekonektēties: ".mysql_error()); mysql_select_db($dbname) or die(mysql_error()); $email = $_POST['email']; $nick = $_POST['nick']; $pass = $_POST['pass']; $checkuser = mysql_query("SELECT nick FROM users WHERE nick='$nick'"); $nick_exist = mysql_num_rows($checkuser); if($nick_exist > 0){ echo "Piedod, bet lietotājvārds, kuru tu izvēlējies jau ir lietošanā. Izvēlies citu!"; unset($nick); include 'register.html'; exit(); } $query = "INSERT INTO users (email, nick, pass) VALUES('$email', '$nick', '$pass')"; mysql_query($query) or die(mysql_error()); mysql_close(); echo "Tu esi veiksmīgi reģistrējies!"; ?> login.php <?php require "includes/core.php"; stdhead("Ielogošanās"); ?> <form name="login" method="post" action="take_login.php"> <table border="0" width="225" align="center"> <tr> <td width="219" bgcolor="#999999"> <p align="center"><font color="white"><span style="font-size:12pt;"><b>Login</b></span></font></p> </td> </tr> <tr> <td width="219"> <table border="0" width="220" align="center"> <tr> <td width="71"><span style="font-size:10pt;">Nick:</span></td> <td width="139"><input type="text" name="nick"></td> </tr> <tr> <td width="71"><span style="font-size:10pt;">Pass:</span></td> <td width="139"><input type="password" name="pass"></td> </tr> <tr> <td width="71"> </td> <td width="139"><p align="right"><input type="submit" name="submit" value="Submit"></p></td> </tr> </table> </td> </tr> <tr> <td width="219" bgcolor="#999999"><font color="white">Not Registered? </font><a href="signup.php" target="_self"><font color="white">Register</font></a><font color="white"> </font><b><i><font color="white">Now!</font></i></b></td> </tr> </table> </form> <?php stdfoot(); ?> take_login.php <?php $dbhost = "localhost"; $dbname = "mysource"; $dbuser = "root"; $dbpass = ""; mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Nevarēja piekonektēties: ".mysql_error()); mysql_select_db($dbname) or die(mysql_error()); session_start(); $nick = $_POST['nick']; $pass = md5($_POST['pass']); $query = "select * from users where nick='$nick' and pass='$pass'"; $result = mysql_query($query); if (mysql_num_rows($result) != 1) { echo "Nepareiza info!"; } else { $_SESSION['nick'] = "$nick"; include "index.php"; } ?> Lūdzu izskaidrojiet man... :)
×
×
  • Create New...