PHP Installation
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Installation

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old February 22nd, 2004, 06:27 PM
zzz zzz is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: icecream island
Posts: 37 zzz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via ICQ to zzz Send a message via Yahoo to zzz
why cannot redeclare.....?

win98/php4.0.5

i got problems in this code when i run activate.php...the error came out :Fatal error: Cannot redeclare login_form() in c:program filesapache groupapachehtdocsloginfunctions.php on line 2

the functions.php
php Code:
Original - php Code
  1.  
  2. <?
  3. function login_form()
  4. {
  5. <form action='$siteurl/login.php' method='post' name='' id=''>
  6.   <table width='50%' border='0' align='center' cellpadding='4' cellspacing='0'>
  7.     <tr>
  8.       <td width='22%'>Username</td>
  9.       <td width='78%'><input name='username' type='text' id='username'></td>
  10.     </tr>
  11.     <tr>
  12.       <td>Password</td>
  13.       <td><input name='password' type='password' id='password'></td>
  14.     </tr>
  15.     <tr>
  16.       <td>&nbsp;</td>
  17.       <td><input type='submit' name='Submit' value='Login To Azurapets!'></td>
  18.     </tr>
  19.   </table>
  20. </form>
  21. ");
  22. }
  23.  
  24. function lostpass_form()
  25. {
  26. <form name='form1' method='post' action='$siteurl/lostpw.php?action=lostpass'>
  27.   <table width='100%' border='0' cellspacing='0' cellpadding='4' align='center'>
  28.     <tr>
  29.       <td>Email Address</td>
  30.       <td><input name='email_address' type='text' id='email_address'></td>
  31.     </tr>
  32.     <tr>
  33.       <td>&nbsp;</td>
  34.       <td><input name='recover' type='hidden' id='recover' value='recover'>
  35.         <input type='submit' name='Submit' value='Gain The Knowledge Of My Password!'></td>
  36.     </tr>
  37.   </table>
  38. </form>
  39. ");
  40.  
  41. }
  42. ?>


activate.php that i run
php Code:
Original - php Code
  1.  
  2. <?
  3.  
  4. include("config.php");
  5. include("functions.php");
  6. include("user_check.php");
  7.  
  8.  
  9.  
  10. $userid = $_REQUEST['id'];
  11. $code = $_REQUEST['code'];
  12.  
  13. $sql = mysql_query("UPDATE users SET activated='1' WHERE userid='$userid' AND password='$code'");
  14.  
  15. $sql_doublecheck = mysql_query("SELECT * FROM users WHERE userid='$userid' AND password='$code' AND activated='1'");
  16. $doublecheck = mysql_num_rows($sql_doublecheck);
  17.  
  18. if($doublecheck == 0){
  19.     echo "<strong><font color=red>Sorry,<BR>your account could not be activated!</font></strong>";
  20. } elseif ($doublecheck > 0) {
  21.    
  22.     echo "<strong>Your account has been activated!</strong> You may login below!<br />";
  23.     login_form();
  24. }
  25.  
  26. ?>

the include files config.php
php Code:
Original - php Code
  1.  
  2. <?
  3. $dbhost = 'localhost';
  4. $dbusername = 'z'; //username
  5. $dbpasswd = 'z'; //password
  6. $database_name = 'users'; //databse
  7.  
  8. $connection = mysql_pconnect("$dbhost","$dbusername","$dbpasswd") or die ("Couldn't connect to server.");
  9. $db = mysql_select_db("$database_name", $connection) or die("Couldn't select database.");
  10.  
  11. //Global Vars
  12.  
  13. $admin_email = '; //your email
  14. $siteurl = '; //your main site url without backslash
  15. $sitepath = ''; //your site path without backslash
  16.  
  17. ?>
usercheck.php
php Code:
Original - php Code
  1.  
  2. <?
  3. include("functions.php");
  4. $sql = mysql_query("SELECT * FROM users WHERE username = '$HTTP_COOKIE_VARS[username]'") OR DIE("Sorry Theres a mysql error.");
  5. $row = mysql_fetch_array($sql);
  6. $num = mysql_num_rows($sql);
  7. //check if username exsists
  8. if($num == 0)
  9. {
  10. print("You must be loggedin to veiw this page!<BR>");
  11. login_form();
  12. print("<BR>Lost password?");
  13. lostpass_form();
  14.  
  15. }
  16.  
  17. //see if user is activated
  18. elseif($row[activated]!=1)
  19. {
  20. print("Sorry your account is not activated.<BR>
  21. If you have not recived your activation link in 48 hours (2 days) please email the site admin.<BR>
  22. <BR>
  23. Be sure to give your accounts username and a breif message on how long you have waited date and time in the email.<BR>
  24. <a href=mailto:$admin_email>Email Site Admin</a>
  25. ");
  26.  
  27. }
  28.  
  29. //check cookies exsist
  30. elseif($HTTP_COOKIE_VARS[username]=="" OR $HTTP_COOKIE_VARS[password]=="")
  31. {
  32. print("You must be loggedin to veiw this page!<BR>");
  33. login_form();
  34. print("<BR>Lost password?");
  35. lostpass_form();
  36.  
  37. }
  38.  
  39. //check if password is correct
  40.  
  41. elseif($HTTP_COOKIE_VARS[password] != $row[password])
  42. {
  43. print("You must be loggedin to veiw this page!<BR>");
  44. login_form();
  45. print("<BR>Lost password?");
  46. lostpass_form();
  47.  
  48. }
  49. ?>

login.php
php Code:
Original - php Code
  1.  
  2. <?
  3. include("config.php");
  4. include("functions.php");
  5. if($action==login)
  6. {
  7. if($HTTP_COOKIE_VARS[username]=="" AND $HTTP_COOKIE_VARS[password]=="")
  8. {
  9. $md5_password = md5($HTTP_POST_VARS[password]);
  10. $sql = mysql_query("SELECT * FROM users WHERE username = '$HTTP_POST_VARS[username]' AND password = '$md5_password'") OR DIE("Sorry there is a mysql error.");
  11. $numrows = mysql_num_rows($sql);
  12. if($HTTP_POST_VARS[password]=="")
  13. {
  14.  
  15. print("No password Entered.");
  16. login_form();
  17. print("<BR><BR> Lost Password?");
  18. lostpass_form();
  19.  
  20. }
  21. elseif($HTTP_POST_VARS[username]=="")
  22. {
  23.  
  24. print("No username Entered.");
  25. login_form();
  26. print("<BR><BR> Lost Password?");
  27. lostpass_form();
  28.  
  29. }
  30. elseif($numrows == "0")
  31. {
  32.  
  33. print("Username and Password doesnt match!");
  34. login_form();
  35. print("<BR><BR> Lost Password?");
  36. lostpass_form();
  37.  
  38. }
  39. else
  40. {
  41. setcookie("username","$HTTP_POST_VARS[username]",time()+3000);
  42. setcookie("password","$md5_password",time()+3000);
  43.  
  44. print("your now logged in!");
  45.  
  46.  
  47. }
  48. }
  49. else
  50. {
  51.  
  52. print("Your are already loggedin!");
  53.  
  54.  
  55. }
  56. }
  57. if($action=="")
  58. {
  59.  
  60. login_form();
  61. print("<BR><BR> Lost Password?");
  62. lostpass_form();
  63.  
  64. }
  65. ?>


i tried to fix it but it took me half day to figure where the problem, still i can't find it.ANYONE SEE THE MISTAKE I MAKE HERE? help! :
i'm quite poor in this coding so please forgive and help...

Reply With Quote
  #2  
Old February 22nd, 2004, 07:32 PM
bluephoenix's Avatar
bluephoenix bluephoenix is offline
Levelheaded Curmudgeon
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Location: Syracuse, NY
Posts: 507 bluephoenix User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 13 m 2 sec
Reputation Power: 2
Send a message via AIM to bluephoenix
RE: why cannot redeclare.....?

do either config.php functions.php or user_checks.php include files? Try using require_once() instead to see if that solves your problem.

-Tim

Reply With Quote
  #3  
Old February 22nd, 2004, 09:14 PM
zzz zzz is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: icecream island
Posts: 37 zzz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via ICQ to zzz Send a message via Yahoo to zzz
RE: RE: why cannot redeclare.....?

yeah all are include files, i edit the first message so u can see thier codes..
i changed the [code]
include("config.php");
include("functions.php");
include("user_check.php");
to
require_once("config.php");
require_once("functions.php");
require_once("user_check.php");
but still error:Fatal error: Cannot redeclare login_form() in c:program filesapache groupapachehtdocsloginfunctions.php on line 2...

Reply With Quote