Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP] [MySQL] logowanie, tworzenie konta
Forum PHP.pl > Forum > Przedszkole
schumi1341
Mam problem ze skryptem. probuje zalozyc konto to wyskakuje mi

Fatal error: Cannot redeclare validate() (previously declared in C:\AppServ\www\store\config.ini:48) in C:\AppServ\www\store\config.ini on line 79

  1. <?php
  2.  
  3.  
  4. // nazwa organicacji
  5. $title = "SKLEP INTERNETOWY";
  6.  
  7. // what your selling -- appears on the left sidebar on the main page
  8. $selling = "Soki";
  9.  
  10. // kolor tla
  11. $bg = "#FFFFFF";
  12.  
  13. // gorne i boczne ramki
  14. $middle = "#99CCFF";
  15.  
  16. // 
  17. $tophigh = "#6699CC";
  18.  
  19. // kolor tekstu
  20. $textcolor = "#000000";
  21.  
  22. // nazwa hosta
  23. $host = "localhost";
  24.  
  25. // database uzytkownik
  26. $user = "root";
  27.  
  28. // database haslo
  29. $pass = "";
  30.  
  31. // database nazwa
  32. $database = "sklep";
  33.  
  34. // adres www
  35. $website = "www.soki.pl";
  36.  
  37. // folder ze sklepem
  38. $path = "/localhost/store";
  39.  
  40. // folder z obrazkami
  41. $image_dir = "/store/images";
  42.  
  43.  
  44.  
  45. // some function definitions
  46. /* this is the validation function needed by checkout.php3 it validates
  47. that all the variables are filled */
  48. function validate($lname,$fname,$address,$city,$state,$zipcode,$country,$email,$telephone)
  49. {
  50. echo "<font size=+1><ul>";
  51. if(empty($lname)) { 
  52. echo " <li><b>Wprowadz imie</li>."; }
  53. if(empty($fname)) {
  54. echo "<li>Wprowadz nazwisko.</li>";
  55. $status=1;}
  56. if(empty($address)) { 
  57. echo "<li>Wprowadz email.</li>";
  58. $status=1;}
  59. if(empty($city)) { 
  60. echo "<li>Wprowadz miasto.</li>"; 
  61. $status=1;}
  62. if(empty($state)) { 
  63. echo "<li>Wprowadz wojewodztwo.</li>"; 
  64. $status=1;}
  65. if(empty($zipcode)) { 
  66. echo "<li>Wprowadz kod pocztowy</li>.";
  67. $status=1;}
  68. if(empty($country)) { 
  69. echo "<li>Wprowadz kraj</li>";
  70. $status=1;}
  71. if(empty($email)) { 
  72. echo "<li>Wprowadz email.</li>"; 
  73. $status=1;}
  74. if(empty($telephone)) { 
  75. echo "<li>Wprowadz numer telefonu.</li>";
  76. $status=1;}
  77. echo "</ul>";
  78. if($status=="1") {die();}
  79. }
  80.  
  81. /* credit cart validation function
  82. This was originally done by Brett@InterWebDesign.com, I modified the code to fit
     my needs*/
  83. function credit_card($cardnum, $type = 'none'){
  84.  
  85.  $type = strtolower($type);
  86.  $cardnum = ereg_replace( '[-[:space:]]', '',$cardnum);  
  87.  
  88.  
  89.  if ($type == 'none') {
  90.  
  91.  // Do nothing
  92.  
  93.  }
  94.  elseif ($type == 'mastercard'){
  95.  if (strlen($cardnum) != 16 || !ereg( '^5[1-5]', $cardnum)) {
  96.  die("You have entered an invalid Mastercard number. Please re-enter
  97.  your credit card information."); }
  98.  return 0;
  99.  }
  100.  elseif ($type == 'visa'){
  101.  if ((strlen($cardnum) != 13 && strlen($cardnum) != 16) || substr($cardnum, 0, 1) != '4') {
  102.  die("You have entered an invalid Visa number. Please re-enter
  103.  your credit card information."); }
  104.  return 0;
  105.  }
  106.  elseif ($type == 'amex'){
  107.  if (strlen($cardnum) != 15 || !ereg( '^3[47]', $cardnum)) {
  108.  die("You have entered an invalid American Express number. Please re-enter
  109.  your credit card information.");
  110.  return 0; }
  111.  }
  112.  elseif ($type == 'discover'){
  113.  if (strlen($cardnum) != 16 || substr($cardnum, 0, 4) != '6011') {
  114.  die("You have entered an invalid Discover number. Please re-enter
  115.  your credit card information.");
  116.  return 0; }
  117.  }
  118.  else {
  119.  //invalid type entered
  120.  die("Invalid type. Please select a different type.");
  121.  return -1;
  122.  }
  123.  
  124.  // Start MOD 10 checks
  125.  
  126.  $dig = toCharArray($cardnum);
  127.  $numdig = sizeof ($dig);
  128.  $j = 0;
  129.  for ($i=($numdig-2); $i>=0; $i-=2){
  130.  $dbl[$j] = $dig[$i] * 2;
  131.  $j++;
  132.  }  
  133.  $dblsz = sizeof($dbl);
  134.  $validate =0;
  135.  for ($i=0;$i<$dblsz;$i++){
  136.  $add = toCharArray($dbl[$i]);
  137.  for ($j=0;$j<sizeof($add);$j++){
  138.  $validate += $add[$j];
  139.  }
  140.  $add = '';
  141.  }
  142.  for ($i=($numdig-1); $i>=0; $i-=2){
  143.  $validate += $dig[$i];  
  144.  }
  145.  if (substr($validate, -1, 1) == '0') return 1;
  146.  else return 0;
  147. }
  148.  
  149.  
  150. // takes a string and returns an array of characters
  151. function toCharArray($input){
  152.  $len = strlen($input);
  153.  for ($j=0;$j<$len;$j++){
  154.  $char[$j] = substr($input, $j, 1);  
  155.  }
  156.  return ($char);
  157. }
  158.  
  159. ?>




Natomias jak zaloze konto przez Mysql i probuje sie zalogowac to dostaje

Warning: include(conn.inc) [function.include]: failed to open stream: No such file or directory in C:\AppServ\www\store\login.php3 on line 60

Warning: include() [function.include]: Failed opening 'conn.inc' for inclusion (include_path='.;C:\php5\pear') in C:\AppServ\www\store\login.php3 on line 60

Warning: mysql_query() [function.mysql-query]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\AppServ\www\store\login.php3 on line 62

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in C:\AppServ\www\store\login.php3 on line 62

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\store\login.php3 on line 63


  1. <? 
  2. if(!isset($store_user_cookie) && !isset($store_user) || ($store_user_cookie == 'deleted')) {
  3.  ?>
  4. <? require("config.ini"); ?>
  5. <body text="#000000" bgcolor="#FFFFFF">
  6. <center> 
  7. <table border=1 width=500 cellspacing=0 cellpading=8>
  8. <tr>
  9. <td align=center colspan=2>
  10. <font size=5 face="Times">
  11. <i><? echo $title ?> online store</i></font>
  12. </td>
  13. </tr>
  14. <tr>
  15. <td align=center colspan=2>
  16. Musisz sie zalogowac zanim kupisz.
  17. </td>
  18. </tr>
  19. <tr>
  20. <td align=center>
  21. <form method=post action="<? echo $PHP_SELF; ?>">
  22. <table>
  23. <tr>
  24. <td>
  25. <b>Uzytkownik:</b>
  26. </td>
  27. <td>
  28. <input type=text size=20 name="store_user">
  29. </td>
  30. </tr>
  31. <tr>
  32. <td>
  33. <b>Haslo:</b>
  34. </td>
  35. <td>
  36. <input type=password size=20 name="store_user_pw">
  37. </td>
  38. </tr>
  39. <tr>
  40. <td colspan=2>
  41. <input type=submit name="login" value="Login">
  42. </td>
  43. </tr>
  44. <tr>
  45. <td colspan=2>
  46. Utworz nowe konto <a href="license.php3">click here</a>.
  47. </td>
  48. </tr>
  49. </table>
  50. </td>
  51. </tr>
  52. </table>
  53.  
  54.  <? 
  55.  die();
  56.  }
  57.  elseif($login == "Login" && !isset($store_user_cookie)) {
  58. $username=strtolower($store_user); 
  59. $password=$store_user_pw;
  60. include("conn.inc");
  61.  $query = mysql_query("select username,password from users where
  62.  username='$username' and password='$password'");
  63.  if(!mysql_num_rows($query)) { 
  64. ?>
  65. <body>
  66. <center> 
  67. <table border=1 width=500 cellspacing=0 cellpading=8>
  68. <tr>
  69. <td align=center><font size=5 face="Times"> <i><? echo $title; ?> online store
  70. </i></font></td></tr>
  71. <tr>
  72. <td>
  73. <table>
  74. <tr><td>Niewlasciwy uzytkownik albo haslo.<br>
  75. Musisz sie zalogowac zanim kupisz. Utworz konto(it's free)
  76. <a href="license.php3">click here</a>.
  77. </td></tr>
  78.  
  79. </table>
  80.  
  81. </td></tr>
  82.  
  83. </table>
  84. <? 
  85. die();
  86. }
  87. SetCookie("store_user_cookie",$username,time()+3600,"/","$SERVER_NAME");
  88.  
  89.  } 
  90. elseif($action == "logoff") {
  91. SetCookie("store_user_cookie","",time()+3600,"/","$SERVER_NAME");
  92. Header("Location: http://$SERVER_NAME");
  93. }
  94. elseif(isset($store_user_cookie)) {
  95. echo "<i>$store_user_cookie</i> is logged in.
  96. <a href="login.php3?action=logoff">logoff</a>";
  97. }
  98.  ?>


pomocy sad.gif
Darti
Jak dla mnie to masz to "coś" źle zainstalowane, sprawdź czy spełniasz wymogi kompatybilności (minimalne wersje php, mysql) , skonfigurowałeś poprawnie użytkownika, hasło, nazwę bazy danych itp rzeczy. Przeczytaj po prostu instrukcję instalacji i postępuj zgodnie z jej poleceniami.
Black-Berry
Ciężka sprawa. Wygląda na to że jeśli to skopiowałeś to gdzieś czegoś brakło albo było za dużo. 1 błąd znaczy to że masz 2 razy zadeklarowaną funkcję Validate. Próbujesz podpiąć jakiś sklep ? Co to za kod?
schumi1341
muszę stworzyć prosty sklep internetowy. Najprostszy jaki sie da.

moze moj blad wynika ze zlego imprtowania skryptu sql.
w instrukcji jest

Create tables
---> mysql -u USER -p DATABASE < store.sql

ja poprostu importuje sam store.sql
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.