Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Problem z sessions
kubatur0
post
Post #1





Grupa: Zarejestrowani
Postów: 36
Pomógł: 0
Dołączył: 9.04.2010

Ostrzeżenie: (0%)
-----


Mam problem. Po kliknieciu przyciusku rejestruj w moim formularzu, bez wypelnienia pol obok powinny pojawic sie bledy ze niewypelnione pola. Formularz jest przesylany do process.php. Zamiast tego pojawia mi sie komunikat: " Fatal error: Cannot redeclare class MySQLDB in C:\xampp\htdocs\Strona\include\database.php on line 14" No ale dobra (w pliku glownym index.php mam include session.php). Z pliku process.php skasowalem tego samego includa bo wlasnie byl zdublowany... ale zamiast tego teraz pojawia sie komunikat: "
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\Strona\index.php:19) in C:\xampp\htdocs\Strona\process.php on line 111". Czy ktos moze mi pomoc z tym problemem?


Plik process.php
  1. <?php
  2.  
  3.  
  4.  
  5. class Process
  6. {
  7. /* Class constructor */
  8. function Process(){
  9. global $session;
  10. /* User submitted login form */
  11. if(isset($_POST['sublogin'])){
  12. $this->procLogin();
  13. }
  14. /* User submitted registration form */
  15. else if(isset($_POST['subjoin'])){
  16. $this->procRegister();
  17. }
  18. /* User submitted forgot password form */
  19. else if(isset($_POST['subforgot'])){
  20. $this->procForgotPass();
  21. }
  22. /* User submitted edit account form */
  23. else if(isset($_POST['subedit'])){
  24. $this->procEditAccount();
  25. }
  26. /**
  27. * The only other reason user should be directed here
  28. * is if he wants to logout, which means user is
  29. * logged in currently.
  30. */
  31. else if($session->logged_in){
  32. $this->procLogout();
  33. }
  34. /**
  35. * Should not get here, which means user is viewing this page
  36. * by mistake and therefore is redirected.
  37. */
  38. else{
  39. header("Location: main.php");
  40. }
  41. }
  42.  
  43. /**
  44. * procLogin - Processes the user submitted login form, if errors
  45. * are found, the user is redirected to correct the information,
  46. * if not, the user is effectively logged in to the system.
  47. */
  48. function procLogin(){
  49. global $session, $form;
  50. /* Login attempt */
  51. $retval = $session->login($_POST['user'], $_POST['pass'], isset($_POST['remember']));
  52.  
  53. /* Login successful */
  54. if($retval){
  55. header("Location: ".$session->referrer);
  56. }
  57. /* Login failed */
  58. else{
  59. $_SESSION['value_array'] = $_POST;
  60. $_SESSION['error_array'] = $form->getErrorArray();
  61. header("Location: ".$session->referrer);
  62. }
  63. }
  64.  
  65. /**
  66. * procLogout - Simply attempts to log the user out of the system
  67. * given that there is no logout form to process.
  68. */
  69. function procLogout(){
  70. global $session;
  71. $retval = $session->logout();
  72. header("Location: main.php");
  73. }
  74.  
  75. /**
  76. * procRegister - Processes the user submitted registration form,
  77. * if errors are found, the user is redirected to correct the
  78. * information, if not, the user is effectively registered with
  79. * the system and an email is (optionally) sent to the newly
  80. * created user.
  81. */
  82. function procRegister(){
  83. global $session, $form;
  84. /* Convert username to all lowercase (by option) */
  85. if(ALL_LOWERCASE){
  86. $_POST['user'] = strtolower($_POST['user']);
  87. }
  88. /* Registration attempt */
  89. $retval = $session->register($_POST['user'], $_POST['pass'], $_POST['email']);
  90.  
  91. /* Registration Successful */
  92. if($retval == 0){
  93. $_SESSION['reguname'] = $_POST['user'];
  94. $_SESSION['regsuccess'] = true;
  95. header("Location: ".$session->referrer);
  96. }
  97. /* Error found with form */
  98. else if($retval == 1){
  99. $_SESSION['value_array'] = $_POST;
  100. $_SESSION['error_array'] = $form->getErrorArray();
  101. header("Location: ".$session->referrer);
  102. }
  103. /* Registration attempt failed */
  104. else if($retval == 2){
  105. $_SESSION['reguname'] = $_POST['user'];
  106. $_SESSION['regsuccess'] = false;
  107. header("Location: ".$session->referrer);
  108. }
  109. }
  110.  
  111. /**
  112. * procForgotPass - Validates the given username then if
  113. * everything is fine, a new password is generated and
  114. * emailed to the address the user gave on sign up.
  115. */
  116. function procForgotPass(){
  117. global $database, $session, $mailer, $form;
  118. /* Username error checking */
  119. $subuser = $_POST['user'];
  120. $field = "user"; //Use field name for username
  121. if(!$subuser || strlen($subuser = trim($subuser)) == 0){
  122. $form->setError($field, "* Username not entered<br>");
  123. }
  124. else{
  125. /* Make sure username is in database */
  126. $subuser = stripslashes($subuser);
  127. if(strlen($subuser) < 5 || strlen($subuser) > 30 ||
  128. !eregi("^([0-9a-z])+$", $subuser) ||
  129. (!$database->usernameTaken($subuser))){
  130. $form->setError($field, "* Username does not exist<br>");
  131. }
  132. }
  133.  
  134. /* Errors exist, have user correct them */
  135. if($form->num_errors > 0){
  136. $_SESSION['value_array'] = $_POST;
  137. $_SESSION['error_array'] = $form->getErrorArray();
  138. }
  139. /* Generate new password and email it to user */
  140. else{
  141. /* Generate new password */
  142. $newpass = $session->generateRandStr(8);
  143.  
  144. /* Get email of user */
  145. $usrinf = $database->getUserInfo($subuser);
  146. $email = $usrinf['email'];
  147.  
  148. /* Attempt to send the email with new password */
  149. if($mailer->sendNewPass($subuser,$email,$newpass)){
  150. /* Email sent, update database */
  151. $database->updateUserField($subuser, "password", md5($newpass));
  152. $_SESSION['forgotpass'] = true;
  153. }
  154. /* Email failure, do not change password */
  155. else{
  156. $_SESSION['forgotpass'] = false;
  157. }
  158. }
  159.  
  160. header("Location: ".$session->referrer);
  161. }
  162.  
  163. /**
  164. * procEditAccount - Attempts to edit the user's account
  165. * information, including the password, which must be verified
  166. * before a change is made.
  167. */
  168. function procEditAccount(){
  169. global $session, $form;
  170. /* Account edit attempt */
  171. $retval = $session->editAccount($_POST['curpass'], $_POST['newpass'], $_POST['email']);
  172.  
  173. /* Account edit successful */
  174. if($retval){
  175. $_SESSION['useredit'] = true;
  176. header("Location: ".$session->referrer);
  177. }
  178. /* Error found with form */
  179. else{
  180. $_SESSION['value_array'] = $_POST;
  181. $_SESSION['error_array'] = $form->getErrorArray();
  182. header("Location: ".$session->referrer);
  183. }
  184. }
  185. };
  186.  
  187. /* Initialize process */
  188. $process = new Process;
  189.  
  190. ?>


czesc pliku index.php

  1. <?php
  2. include("/include/session.php");
  3. ?>
  4. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  5. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl" lang="pl">
  6. <html>
  7. <head>
  8.  
  9. <link rel="stylesheet" type="text/css" href="css/style.css" />
  10. </head>
  11. <body>
  12. <div id="top">
  13. <div id="NAGLOWEK"></div>
  14. <div id="MENUGORNE">
  15. <?php
  16. include("/components/menugorne.html");
  17. ?>
  18. </div>
  19. <div id="NAW1"></div>
  20. <div id="MENU">
  21. <?php
  22.  
  23. .
  24. .
  25. .


Z gory dzieki za pomoc

Ten post edytował kubatur0 11.04.2010, 16:41:39
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 22.08.2025 - 11:38