
February 22nd, 2004, 06:27 PM
|
|
|
|
Join Date: Apr 2007
Location: icecream island
Posts: 37
Time spent in forums: < 1 sec
Reputation Power: 2
|
|
|
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 |
|
|
|
<? function login_form() { <form action='$siteurl/login.php' method='post' name='' id=''> <table width='50%' border='0' align='center' cellpadding='4' cellspacing='0'> <tr> <td width='22%'>Username</td> <td width='78%'><input name='username' type='text' id='username'></td> </tr> <tr> <td>Password</td> <td><input name='password' type='password' id='password'></td> </tr> <tr> <td> </td> <td><input type='submit' name='Submit' value='Login To Azurapets!'></td> </tr> </table> </form> "); } function lostpass_form() { <form name='form1' method='post' action='$siteurl/lostpw.php?action=lostpass'> <table width='100%' border='0' cellspacing='0' cellpadding='4' align='center'> <tr> <td>Email Address</td> <td><input name='email_address' type='text' id='email_address'></td> </tr> <tr> <td> </td> <td><input name='recover' type='hidden' id='recover' value='recover'> <input type='submit' name='Submit' value='Gain The Knowledge Of My Password!'></td> </tr> </table> </form> "); } ?>
activate.php that i run
php Code:
Original
- php Code |
|
|
|
<? include("config.php"); include("functions.php"); include("user_check.php"); $userid = $_REQUEST['id']; $code = $_REQUEST['code']; $sql = mysql_query("UPDATE users SET activated='1' WHERE userid='$userid' AND password='$code'"); $sql_doublecheck = mysql_query("SELECT * FROM users WHERE userid='$userid' AND password='$code' AND activated='1'"); if($doublecheck == 0){ echo "<strong><font color=red>Sorry,<BR>your account could not be activated!</font></strong>"; } elseif ($doublecheck > 0) { echo "<strong>Your account has been activated!</strong> You may login below!<br />"; login_form(); } ?>
the include files config.php
php Code:
Original
- php Code |
|
|
|
<? $dbhost = 'localhost'; $dbusername = 'z'; //username $dbpasswd = 'z'; //password $database_name = 'users'; //databse $connection = mysql_pconnect("$dbhost", "$dbusername", "$dbpasswd") or die ("Couldn't connect to server."); //Global Vars $admin_email = '; //your email $siteurl = '; //your main site url without backslash $sitepath = ''; //your site path without backslash ?>
usercheck.php
php Code:
Original
- php Code |
|
|
|
<? include("functions.php"); $sql = mysql_query("SELECT * FROM users WHERE username = '$HTTP_COOKIE_VARS[username]'") OR DIE("Sorry Theres a mysql error."); //check if username exsists if($num == 0) { print("You must be loggedin to veiw this page!<BR>"); login_form(); print("<BR>Lost password?"); lostpass_form(); } //see if user is activated elseif($row[activated]!=1) { print("Sorry your account is not activated.<BR> If you have not recived your activation link in 48 hours (2 days) please email the site admin.<BR> <BR> Be sure to give your accounts username and a breif message on how long you have waited date and time in the email.<BR> <a href=mailto:$admin_email>Email Site Admin</a> "); } //check cookies exsist elseif($HTTP_COOKIE_VARS[username]=="" OR $HTTP_COOKIE_VARS[password]=="") { print("You must be loggedin to veiw this page!<BR>"); login_form(); print("<BR>Lost password?"); lostpass_form(); } //check if password is correct elseif($HTTP_COOKIE_VARS[password] != $row[password]) { print("You must be loggedin to veiw this page!<BR>"); login_form(); print("<BR>Lost password?"); lostpass_form(); } ?>
login.php
php Code:
Original
- php Code |
|
|
|
<? include("config.php"); include("functions.php"); if($action==login) { if($HTTP_COOKIE_VARS[username]=="" AND $HTTP_COOKIE_VARS[password]=="") { $md5_password = md5($HTTP_POST_VARS[password ]); $sql = mysql_query("SELECT * FROM users WHERE username = '$HTTP_POST_VARS[username]' AND password = '$md5_password'") OR DIE("Sorry there is a mysql error."); if($HTTP_POST_VARS[password]=="") { print("No password Entered."); login_form(); print("<BR><BR> Lost Password?"); lostpass_form(); } elseif($HTTP_POST_VARS[username]=="") { print("No username Entered."); login_form(); print("<BR><BR> Lost Password?"); lostpass_form(); } elseif($numrows == "0") { print("Username and Password doesnt match!"); login_form(); print("<BR><BR> Lost Password?"); lostpass_form(); } else { print("your now logged in!"); } } else { print("Your are already loggedin!"); } } if($action=="") { login_form(); print("<BR><BR> Lost Password?"); lostpass_form(); } ?>
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... 
|