Jump to content

JeanieTallis

Members
  • Posts

    123
  • Joined

  • Last visited

    Never

Everything posted by JeanieTallis

  1. else{ if($database->addNewUser($subuser, md5($subpass), $subemail), $sublocation){ if(EMAIL_WELCOME){ $mailer->sendWelcome($subuser,$subemail,$subpass); } Do i replace that, with teh code you gave? EDIT: Nevermind, i seen what you meant
  2. Oh, you mean session.php <?php function register($subuser, $subpass, $subemail, $sublocation){ global $database, $form, $mailer; //The database, form and mailer object /* Location error checking */ $field = "location"; //Use field name for location if(!$sublocation || strlen($sublocation = trim($sublocation)) = default){ $form->setError($field, "* location not selected") /* Username error checking */ $field = "user"; //Use field name for username if(!$subuser || strlen($subuser = trim($subuser)) == 0){ $form->setError($field, "* Username not entered"); } else{ /* Spruce up username, check length */ $subuser = stripslashes($subuser); if(strlen($subuser) < 5){ $form->setError($field, "* Username below 5 characters"); } else if(strlen($subuser) > 30){ $form->setError($field, "* Username above 30 characters"); } /* Check if username is not alphanumeric */ else if(!eregi("^([0-9a-z])+$", $subuser)){ $form->setError($field, "* Username not alphanumeric"); } /* Check if username is reserved */ else if(strcasecmp($subuser, GUEST_NAME) == 0){ $form->setError($field, "* Username reserved word"); } /* Check if username is already in use */ else if($database->usernameTaken($subuser)){ $form->setError($field, "* Username already in use"); } /* Check if username is banned */ else if($database->usernameBanned($subuser)){ $form->setError($field, "* Username banned"); } } /* Password error checking */ $field = "pass"; //Use field name for password if(!$subpass){ $form->setError($field, "* Password not entered"); } else{ /* Spruce up password and check length*/ $subpass = stripslashes($subpass); if(strlen($subpass) < 4){ $form->setError($field, "* Password too short"); } /* Check if password is not alphanumeric */ else if(!eregi("^([0-9a-z])+$", ($subpass = trim($subpass)))){ $form->setError($field, "* Password not alphanumeric"); } /** * Note: I trimmed the password only after I checked the length * because if you fill the password field up with spaces * it looks like a lot more characters than 4, so it looks * kind of stupid to report "password too short". */ } /* Email error checking */ $field = "email"; //Use field name for email if(!$subemail || strlen($subemail = trim($subemail)) == 0){ $form->setError($field, "* Email not entered"); } $regex = "^[_+a-z0-9-]+(\.[_+a-z0-9-]+)*" ."@[a-z0-9-]+(\.[a-z0-9-]{1,})*" ."\.([a-z]{2,}){1}$"; if(!eregi($regex,$subemail)){ $form->setError($field, "* Email invalid"); } $subemail = stripslashes($subemail); if($database->emailTaken($subemail)){ $form->setError($field, "* Email already in use"); } /* Errors exist, have user correct them */ if($form->num_errors > 0){ return 1; //Errors with form } /* No errors, add the new account to the */ else{ if($database->addNewUser($subuser, md5($subpass), $subemail), $sublocation){ if(EMAIL_WELCOME){ $mailer->sendWelcome($subuser,$subemail,$subpass); } return 0; //New user added succesfully }else{ return 2; //Registration attempt failed } } } ?> if($database->addNewUser that bit what your after? its near the bottom of the code above.
  3. I cant find addNewUser in the file but this is all the registration form. I'm guessing it'd be what your after. I cant find an echo nope, where should the echo come up if one was to be displayed? <?php function procRegister(){ global $session, $form; /* Convert username to all lowercase (by option) */ if(ALL_LOWERCASE){ $_POST['user'] = strtolower($_POST['user']); } /* Registration attempt */ $retval = $session->register($_POST['user'], $_POST['pass'], $_POST['email'], $_POST['location']); /* Registration Successful */ if($retval == 0){ $_SESSION['reguname'] = $_POST['user']; $_SESSION['regsuccess'] = true; header("Location: ".$session->referrer); } /* Error found with form */ else if($retval == 1){ $_SESSION['value_array'] = $_POST; $_SESSION['error_array'] = $form->getErrorArray(); header("Location: ".$session->referrer); } /* Registration attempt failed */ else if($retval == 2){ $_SESSION['reguname'] = $_POST['user']; $_SESSION['regsuccess'] = false; header("Location: ".$session->referrer); } } ?>
  4. No errors, also no echo either, and yes, test register, i've been doing test registers every modification of the codes. Just shown location as a timestamp in the database still. I did have them values, I don't know what happened, must of been when I tried to modify the database file, with function emailTaken and with the location part, I've not touched anything else. Sorry if I'm getting you wound up
  5. No success, shall I PM you with register.php, session.php and database.php ? there all needed, I cant set the email so it displays an error when its being used. Also, somehow, userID is set for 0, and timestamp is 0, and location is still being set as a timestamp.
  6. Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/myveeco/public_html/include/database.php on line 243 (243 = return mysql_query($q, $this->connection); )
  7. What lines would I echo out? Copy n paste the lines, thank you. This is the register form. <?php include("include/session.php"); ?> <title>MyVee! Register</title> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <link href="Style3.css" rel="stylesheet" type="text/css"> <style type="text/css"> <!-- .style4 {font-size: 14px} --> </style> <div id="wrapper"> <div id="Layer4"> <div style="color:WHITE;"> <script type="text/javascript"> var d=new Date() var weekday=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday") var monthname=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec") document.write(weekday[d.getDay()] + " ") document.write(d.getDate() + ". ") document.write(monthname[d.getMonth()] + " ") document.write(d.getFullYear()) </script> </div></div> <div id="Layer2"> <div id="Layer9">There are some outgoing errors with this form which will be fixed in time. It works though, you can register no problem. Sorry for any inconvenience.</div> <div id="Layer10"> <p>Already got a login? go back to the <a href="index.php">homepage</a> and login! </p> </div> </div> <div id="Layer1"></div> <div id="Layer3"> <?php /** * The user is already logged in, not allowed to register. */ if($session->logged_in){ header("location: index.php"); } /** * The user has submitted the registration form and the * results have been processed. */ else if(isset($_SESSION['regsuccess'])){ /* Registration was successful */ if($_SESSION['regsuccess']){ echo "<h1>Registered!</h1>"; echo "<p>Thank you <b>".$_SESSION['reguname']."</b>, your information has been added to the database, " ."you may now <a href=\"index.php\">log in</a>.</p>"; } /* Registration failed */ else{ echo "<h1>Registration Failed</h1>"; echo "<p>We're sorry, but an error has occurred and your registration for the username <b>".$_SESSION['reguname']."</b>, " ."could not be completed.<br>Please try again at a later time.</p>"; } unset($_SESSION['regsuccess']); unset($_SESSION['reguname']); } else{ ?> <br> <span class="style1 style4">Register an account!</span> <br> <?php if($form->num_errors > 0){ echo "<td><font size=\"2\" color=\"#ff0000\">".$form->num_errors." error(s) found</font></td>"; } ?> <form action="process.php" method="POST"> <table align="left" border="0" cellspacing="0" cellpadding="3"> <tr><td>Username:</td><td><input name="user" type="text" value="<? echo $form->value("user"); ?>" size="38" maxlength="30"></td><td><?php echo $form->error("user"); ?></td></tr> <tr><td>Password:</td><td><input name="pass" type="password" value="<? echo $form->value("pass"); ?>" size="38" maxlength="30"></td><td><?php echo $form->error("pass"); ?></td></tr> <tr><td>Email:</td><td><input name="email" type="text" value="<? echo $form->value("email"); ?>" size="38" maxlength="50"></td><td><? echo $form->error("email"); ?></td></tr> <tr><td>Location:</td> <td><select name="location"> <option value="<?php echo $form->value("location"); ?>" selected><? echo $form->value("location"); ?></option> <option value="Afghanistan">Afghanistan</option> <option value="Albania">Albania</option> <option value="Algeria">Algeria</option> <option value="Andorra">Andorra</option> <option value="Anguila">Anguila</option> <option value="Antarctica">Antarctica</option> <option value="Antigua and Barbuda">Antigua and Barbuda</option> <option value="Argentina">Argentina</option> <option value="Armenia ">Armenia </option> <option value="Aruba">Aruba</option> <option value="Australia">Australia</option> <option value="Austria">Austria</option> <option value="Azerbaidjan">Azerbaidjan</option> <option value="Bahamas">Bahamas</option> <option value="Bahrain">Bahrain</option> <option value="Bangladesh">Bangladesh</option> <option value="Barbados">Barbados</option> <option value="Belarus">Belarus</option> <option value="Belgium">Belgium</option> <option value="Belize">Belize</option> <option value="Bermuda">Bermuda</option> <option value="Bhutan">Bhutan</option> <option value="Bolivia">Bolivia</option> <option value="Bosnia and Herzegovina">Bosnia and Herzegovina</option> <option value="Brazil">Brazil</option> <option value="Brunei">Brunei</option> <option value="Bulgaria">Bulgaria</option> <option value="Cambodia">Cambodia</option> <option value="Canada">Canada</option> <option value="Cape Verde">Cape Verde</option> <option value="Cayman Islands">Cayman Islands</option> <option value="Chile">Chile</option> <option value="China">China</option> <option value="Christmans Islands">Christmans Islands</option> <option value="Cocos Island">Cocos Island</option> <option value="Colombia">Colombia</option> <option value="Cook Islands">Cook Islands</option> <option value="Costa Rica">Costa Rica</option> <option value="Croatia">Croatia</option> <option value="Cuba">Cuba</option> <option value="Cyprus">Cyprus</option> <option value="Czech Republic">Czech Republic</option> <option value="Denmark">Denmark</option> <option value="Dominica">Dominica</option> <option value="Dominican Republic">Dominican Republic</option> <option value="Ecuador">Ecuador</option> <option value="Egypt">Egypt</option> <option value="El Salvador">El Salvador</option> <option value="Estonia">Estonia</option> <option value="Falkland Islands">Falkland Islands</option> <option value="Faroe Islands">Faroe Islands</option> <option value="Fiji">Fiji</option> <option value="Finland">Finland</option> <option value="France">France</option> <option value="French Guyana">French Guyana</option> <option value="French Polynesia">French Polynesia</option> <option value="Gabon">Gabon</option> <option value="Germany">Germany</option> <option value="Gibraltar">Gibraltar</option> <option value="Georgia">Georgia</option> <option value="Greece">Greece</option> <option value="Greenland">Greenland</option> <option value="Grenada">Grenada</option> <option value="Guadeloupe">Guadeloupe</option> <option value="Guatemala">Guatemala</option> <option value="Guinea-Bissau">Guinea-Bissau</option> <option value="Guinea">Guinea</option> <option value="Haiti">Haiti</option> <option value="Honduras">Honduras</option> <option value="Hong Kong">Hong Kong</option> <option value="Hungary">Hungary</option> <option value="Iceland">Iceland</option> <option value="India">India</option> <option value="Indonesia">Indonesia</option> <option value="Ireland">Ireland</option> <option value="Israel">Israel</option> <option value="Italy">Italy</option> <option value="Jamaica">Jamaica</option> <option value="Japan">Japan</option> <option value="Jordan">Jordan</option> <option value="Kazakhstan">Kazakhstan</option> <option value="Kenya">Kenya</option> <option value="Kiribati ">Kiribati </option> <option value="Kuwait">Kuwait</option> <option value="Kyrgyzstan">Kyrgyzstan</option> <option value="Lao People's Democratic Republic">Lao People's Democratic Republic</option> <option value="Latvia">Latvia</option> <option value="Lebanon">Lebanon</option> <option value="Liechtenstein">Liechtenstein</option> <option value="Lithuania">Lithuania</option> <option value="Luxembourg">Luxembourg</option> <option value="Macedonia">Macedonia</option> <option value="Madagascar">Madagascar</option> <option value="Malawi">Malawi</option> <option value="Malaysia ">Malaysia </option> <option value="Maldives">Maldives</option> <option value="Mali">Mali</option> <option value="Malta">Malta</option> <option value="Marocco">Marocco</option> <option value="Marshall Islands">Marshall Islands</option> <option value="Mauritania">Mauritania</option> <option value="Mauritius">Mauritius</option> <option value="Mexico">Mexico</option> <option value="Micronesia">Micronesia</option> <option value="Moldavia">Moldavia</option> <option value="Monaco">Monaco</option> <option value="Mongolia">Mongolia</option> <option value="Myanmar">Myanmar</option> <option value="Nauru">Nauru</option> <option value="Nepal">Nepal</option> <option value="Netherlands Antilles">Netherlands Antilles</option> <option value="Netherlands">Netherlands</option> <option value="New Zealand">New Zealand</option> <option value="Niue">Niue</option> <option value="North Korea">North Korea</option> <option value="Norway">Norway</option> <option value="Oman">Oman</option> <option value="Pakistan">Pakistan</option> <option value="Palau">Palau</option> <option value="Panama">Panama</option> <option value="Papua New Guinea">Papua New Guinea</option> <option value="Paraguay">Paraguay</option> <option value="Peru ">Peru </option> <option value="Philippines">Philippines</option> <option value="Poland">Poland</option> <option value="Portugal ">Portugal </option> <option value="Puerto Rico">Puerto Rico</option> <option value="Qatar">Qatar</option> <option value="Republic of Korea Reunion">Republic of Korea Reunion</option> <option value="Romania">Romania</option> <option value="Russia">Russia</option> <option value="Saint Helena">Saint Helena</option> <option value="Saint kitts and nevis">Saint kitts and nevis</option> <option value="Saint Lucia">Saint Lucia</option> <option value="Samoa">Samoa</option> <option value="San Marino">San Marino</option> <option value="Saudi Arabia">Saudi Arabia</option> <option value="Seychelles">Seychelles</option> <option value="Singapore">Singapore</option> <option value="Slovakia">Slovakia</option> <option value="Slovenia">Slovenia</option> <option value="Solomon Islands">Solomon Islands</option> <option value="South Africa">South Africa</option> <option value="Spain">Spain</option> <option value="Sri Lanka">Sri Lanka</option> <option value="St.Pierre and Miquelon">St.Pierre and Miquelon</option> <option value="St.Vincent and the Grenadines">St.Vincent and the Grenadines</option> <option value="Sweden">Sweden</option> <option value="Switzerland">Switzerland</option> <option value="Syria">Syria</option> <option value="Taiwan ">Taiwan </option> <option value="Tajikistan">Tajikistan</option> <option value="Thailand">Thailand</option> <option value="Trinidad and Tobago">Trinidad and Tobago</option> <option value="Turkey">Turkey</option> <option value="Turkmenistan">Turkmenistan</option> <option value="Turks and Caicos Islands">Turks and Caicos Islands</option> <option value="Ukraine">Ukraine</option> <option value="UAE">UAE</option> <option value="UK">UK</option> <option value="USA">USA</option> <option value="Uruguay">Uruguay</option> <option value="Uzbekistan">Uzbekistan</option> <option value="Vanuatu">Vanuatu</option> <option value="Vatican City">Vatican City</option> <option value="Vietnam">Vietnam</option> <option value="Virgin Islands (GB)">Virgin Islands (GB)</option> <option value="Virgin Islands (U.S.) ">Virgin Islands (U.S.) </option> <option value="Wallis and Futuna Islands">Wallis and Futuna Islands</option> <option value="Yemen">Yemen</option> <option value="Yugoslavia">Yugoslavia</option> </select><td><?php echo $form->value("location"); ?></td> <tr><td colspan="2" align="right"> <input type="hidden" name="subjoin" value="1"> <input type="submit" value="Join!"></td></tr> <tr> <td colspan="2" align="left" class="style1 style4"><a href="http://www.myvee.co.uk">back </a></td> </tr> </table> </form> <p> </p> <p> <?php } ?> </p> <p> </p> <p> </p> <p> </p> <p> </p> <label></label> <p> </p> </div> </div> Though, im not sure what I did with location, is correct.
  8. This is the whole of the database.php file, where everything is set and inserted into the database. <?php include("constants.php"); class MySQLDB { var $connection; //The MySQL database connection var $num_active_users; //Number of active users viewing site var $num_active_guests; //Number of active guests viewing site var $num_members; //Number of signed-up users /* Note: call getNumMembers() to access $num_members! */ /* Class constructor */ function MySQLDB(){ /* Make connection to database */ $this->connection = mysql_connect(DB_SERVER, DB_USER, DB_PASS) or die(mysql_error()); mysql_select_db(DB_NAME, $this->connection) or die(mysql_error()); /** * Only query database to find out number of members * when getNumMembers() is called for the first time, * until then, default value set. */ $this->num_members = -1; if(TRACK_VISITORS){ /* Calculate number of users at site */ $this->calcNumActiveUsers(); /* Calculate number of guests at site */ $this->calcNumActiveGuests(); } } /* confirms user pass */ function confirmUserPass($username, $password){ /* Add slashes if necessary (for query) */ if(!get_magic_quotes_gpc()) { $username = addslashes($username); } /* Verify that user is in database */ $q = "SELECT password FROM ".TBL_USERS." WHERE username = '$username'"; $result = mysql_query($q, $this->connection); if(!$result || (mysql_numrows($result) < 1)){ return 1; //Indicates username failure } /* Retrieve password from result, strip slashes */ $dbarray = mysql_fetch_array($result); $dbarray['password'] = stripslashes($dbarray['password']); $password = stripslashes($password); /* Validate that password is correct */ if($password == $dbarray['password']){ return 0; //Success! Username and password confirmed } else{ return 2; //Indicates password failure } } function confirmUserID($username, $userid){ /* Add slashes if necessary (for query) */ if(!get_magic_quotes_gpc()) { $username = addslashes($username); } /* Verify that user is in database */ $q = "SELECT userid FROM ".TBL_USERS." WHERE username = '$username'"; $result = mysql_query($q, $this->connection); if(!$result || (mysql_numrows($result) < 1)){ return 1; //Indicates username failure } /* Retrieve userid from result, strip slashes */ $dbarray = mysql_fetch_array($result); $dbarray['userid'] = stripslashes($dbarray['userid']); $userid = stripslashes($userid); /* Validate that userid is correct */ if($userid == $dbarray['userid']){ return 0; //Success! Username and userid confirmed } else{ return 2; //Indicates userid invalid } } /** * usernameTaken - Returns true if the username has * been taken by another user, false otherwise. */ function usernameTaken($username){ if(!get_magic_quotes_gpc()){ $username = addslashes($username); } $q = "SELECT username FROM ".TBL_USERS." WHERE username = '$username'"; $result = mysql_query($q, $this->connection); return (mysql_numrows($result) > 0); } /** * emailTaken - returns true if email has * been taken by another user, false otherwise. */ function emailTaken($email){ $q = "SELECT email FROM ".TBL_USERS." WHERE email = '$email'"; $result = mysql_query($q, $this->connection); return (mysql_numrows($result) > 0); } /** * usernameBanned - Returns true if the username has * been banned by the administrator. */ function usernameBanned($username){ if(!get_magic_quotes_gpc()){ $username = addslashes($username); } $q = "SELECT username FROM ".TBL_BANNED_USERS." WHERE username = '$username'"; $result = mysql_query($q, $this->connection); return (mysql_numrows($result) > 0); } /** * addNewUser - Inserts the given (username, password, email) * info into the database. Appropriate user level is set. * Returns true on success, false otherwise. */ function addNewUser($username, $password, $email, $location){ $time = time(); /* If admin sign up, give admin user level */ if(strcasecmp($username, ADMIN_NAME) == 0){ $ulevel = ADMIN_LEVEL; }else{ $ulevel = USER_LEVEL; } $q = "INSERT INTO ".TBL_USERS." VALUES ('$username', '$password', '0', $ulevel, '$email', '$location', $time)"; return mysql_query($q, $this->connection); } /** * updateUserField - Updates a field, specified by the field * parameter, in the user's row of the database. */ function updateUserField($username, $field, $value){ $q = "UPDATE ".TBL_USERS." SET ".$field." = '$value' WHERE username = '$username'"; return mysql_query($q, $this->connection); } /* Get user info */ function getUserInfo($username){ $q = "SELECT * FROM ".TBL_USERS." WHERE username = '$username'"; $result = mysql_query($q, $this->connection); /* Error occurred, return given name by default */ if(!$result || (mysql_numrows($result) < 1)){ return NULL; } /* Return result array */ $dbarray = mysql_fetch_array($result); return $dbarray; } /*Number of users on website*/ function getNumMembers(){ if($this->num_members < 0){ $q = "SELECT * FROM ".TBL_USERS; $result = mysql_query($q, $this->connection); $this->num_members = mysql_numrows($result); } return $this->num_members; } /** * calcNumActiveUsers - Finds out how many active users * are viewing site and sets class variable accordingly. */ function calcNumActiveUsers(){ /* Calculate number of users at site */ $q = "SELECT * FROM ".TBL_ACTIVE_USERS; $result = mysql_query($q, $this->connection); $this->num_active_users = mysql_numrows($result); } /** * calcNumActiveGuests - Finds out how many active guests * are viewing site and sets class variable accordingly. */ function calcNumActiveGuests(){ /* Calculate number of guests at site */ $q = "SELECT * FROM ".TBL_ACTIVE_GUESTS; $result = mysql_query($q, $this->connection); $this->num_active_guests = mysql_numrows($result); } /** * addActiveUser - Updates username's last active timestamp * in the database, and also adds him to the table of * active users, or updates timestamp if already there. */ function addActiveUser($username, $time){ $q = "UPDATE ".TBL_USERS." SET timestamp = '$time' WHERE username = '$username'"; mysql_query($q, $this->connection); if(!TRACK_VISITORS) return; $q = "REPLACE INTO ".TBL_ACTIVE_USERS." VALUES ('$username', '$time')"; mysql_query($q, $this->connection); $this->calcNumActiveUsers(); } /* addActiveGuest - Adds guest to active guests table */ function addActiveGuest($ip, $time){ if(!TRACK_VISITORS) return; $q = "REPLACE INTO ".TBL_ACTIVE_GUESTS." VALUES ('$ip', '$time')"; mysql_query($q, $this->connection); $this->calcNumActiveGuests(); } /* These functions are self explanatory, no need for comments */ /* removeActiveUser */ function removeActiveUser($username){ if(!TRACK_VISITORS) return; $q = "DELETE FROM ".TBL_ACTIVE_USERS." WHERE username = '$username'"; mysql_query($q, $this->connection); $this->calcNumActiveUsers(); } /* removeActiveGuest */ function removeActiveGuest($ip){ if(!TRACK_VISITORS) return; $q = "DELETE FROM ".TBL_ACTIVE_GUESTS." WHERE ip = '$ip'"; mysql_query($q, $this->connection); $this->calcNumActiveGuests(); } /* removeInactiveUsers */ function removeInactiveUsers(){ if(!TRACK_VISITORS) return; $timeout = time()-USER_TIMEOUT*60; $q = "DELETE FROM ".TBL_ACTIVE_USERS." WHERE timestamp < $timeout"; mysql_query($q, $this->connection); $this->calcNumActiveUsers(); } /* removeInactiveGuests */ function removeInactiveGuests(){ if(!TRACK_VISITORS) return; $timeout = time()-GUEST_TIMEOUT*60; $q = "DELETE FROM ".TBL_ACTIVE_GUESTS." WHERE timestamp < $timeout"; mysql_query($q, $this->connection); $this->calcNumActiveGuests(); } function query($query){ return mysql_query($query, $this->connection); } }; /* Create database connection */ $database = new MySQLDB; ?> Hope its all in there. I'm really confused about the date and time, I've not really set the location looking through it, im not sure how, I'm guessing by default it sets as a timestamp? I've set it tso it enters the location in, as this bit of the code here is from the code above <?php function addNewUser($username, $password, $email, $location){ $time = time(); /* If admin sign up, give admin user level */ if(strcasecmp($username, ADMIN_NAME) == 0){ $ulevel = ADMIN_LEVEL; }else{ $ulevel = USER_LEVEL; } $q = "INSERT INTO ".TBL_USERS." VALUES ('$username', '$password', '0', $ulevel, '$email', '$location', $time)"; return mysql_query($q, $this->connection); } ?>
  9. Could you help me with the code, theres the register form, with the location in, and then the database.php which sends the location to the database, which is more likely to be wrong, and why where i insert date()
  10. How would I extract real date and time? the location, I don't know if its correct, I just tried my best so that you register using location involved too, and on database.php it passes the location to the database, or should do. Not sure if it works, but I come across no errors.
  11. You'll need to pass the data as a query to the database, and then retreive the details onto the other page.
  12. I have a register login page, though the username, and email and userlevel are the correct values. Yet, the rest don't. This is what they come up like (random generated codes I'm guessing) password: 8b1bfe77cb4bc077728e6b1607c8b73a UserID: 83e23af276758792a355a3f0b47b862f Timestamp: 1238764994 Location: 1238764982 I'm guessing the userID is like that? I don't know, but either way, the rest is incorrect. Do you know why its doing this? I want the password to be displayed as the password, location as the location, etc etc, the values behind this is correct, as it recognises the password etc. Just coming up with random generated numbers. Any ideas? Thanks
  13. Hello there, This is a good script to start off with http://www.evolt.org/article/PHP_Login_System_with_Admin_Features/17/60384/index.html after the bottom of the article (not the page as theres comments) theres a .zip or .rar file to download, which is all the things involved, including admin system. It works clean, I've used it, ive editted it though. if you have any problems with this script PM me. Please do not put errors of this script inside the forums, as this forum is the wrong place for third party coding. Jeanie.
  14. Nothing doesn't work yet, I added a location dropdown menu to the register form. The first option in the menu, is blank, that one cant be chosen, so if it's set as default, error returns 'location not selected' It needs to be in the whole code I sent, so that it checks for errors basically. This code below $field = "location"; if(!$sublocation || strlen($sublocation = trim($sublocation)) == 0){ $form->setError($field, "* Location not selected"); is a textfield error, so if nothings typed in, it recieves the error, I don't know what to do about a dropdown. Do you understand now? thanks
  15. Maybe, its the power of the code. The weaker the code, and yet the more emails it sends out, the slower it'll take as its dealing with more loops. I'm not sure. This isn't what I study at.
  16. I'm not too sure what it would be. I have a guess. This is the whole register form code in session.php function register($subuser, $subpass, $subemail, $sublocation){ global $database, $form, $mailer; //The database, form and mailer object /* Username error checking */ $field = "user"; //Use field name for username if(!$subuser || strlen($subuser = trim($subuser)) == 0){ $form->setError($field, "* Username not entered"); } else{ /* Spruce up username, check length */ $subuser = stripslashes($subuser); if(strlen($subuser) < 5){ $form->setError($field, "* Username below 5 characters"); } else if(strlen($subuser) > 30){ $form->setError($field, "* Username above 30 characters"); } /* Check if username is not alphanumeric */ else if(!eregi("^([0-9a-z])+$", $subuser)){ $form->setError($field, "* Username not alphanumeric"); } /* Check if username is reserved */ else if(strcasecmp($subuser, GUEST_NAME) == 0){ $form->setError($field, "* Username reserved word"); } /* Check if username is already in use */ else if($database->usernameTaken($subuser)){ $form->setError($field, "* Username already in use"); } /* Check if username is banned */ else if($database->usernameBanned($subuser)){ $form->setError($field, "* Username banned"); } } /* Password error checking */ $field = "pass"; //Use field name for password if(!$subpass){ $form->setError($field, "* Password not entered"); } else{ /* Spruce up password and check length*/ $subpass = stripslashes($subpass); if(strlen($subpass) < 4){ $form->setError($field, "* Password too short"); } /* Check if password is not alphanumeric */ else if(!eregi("^([0-9a-z])+$", ($subpass = trim($subpass)))){ $form->setError($field, "* Password not alphanumeric"); } } /* Email error checking */ $field = "email"; //Use field name for email if(!$subemail || strlen($subemail = trim($subemail)) == 0){ $form->setError($field, "* Email not entered"); } $regex = "^[_+a-z0-9-]+(\.[_+a-z0-9-]+)*" ."@[a-z0-9-]+(\.[a-z0-9-]{1,})*" ."\.([a-z]{2,}){1}$"; if(!eregi($regex,$subemail)){ $form->setError($field, "* Email invalid"); } $subemail = stripslashes($subemail); if($database->emailTaken($subemail)){ $form->setError($field, "* Email already in use"); } I'm not sure if the following code is correct, as its a drop down menu, more than a field. Could you help me out?, and I know where I'd put it though. $field = "location"; if(!$sublocation || strlen($sublocation = trim($sublocation)) == 0){ $form->setError($field, "* Location not selected"); Thanks.
  17. Good job, redarrow. No errors with that one I still have location to put in.
  18. Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION in /home/myveeco/public_html/include/session.php on line 143 <?php $field = "pass"; //Use field name for password if(!$subpass){ $form->setError($field, "* Password not entered"); } /* Return if form errors exist */ if($form->num_errors > 0){ return false; }?> Line 143 = $field = "pass"; //Use field name for password Shall I put all the origional code, before I started the email is in use bit, so when it last worked properly, so it'll help figure out where 'email is not in use' should go?
  19. This error now occurs Parse error: syntax error, unexpected '{' in /home/myveeco/public_html/include/database.php on line 131 Line 131 = if(!$subuser || strlen($subuser = trim($subuser)) == 0){ The block of code is <?php function login($subuser, $subpass, $subremember){ global $database, $form; //The database and form object /* Username error checking */ $field = "user"; //Use field name for username if(!$subuser || strlen($subuser = trim($subuser)) == 0){ $form->setError($field, "* Username not entered"); } else{ /* Check if username is not alphanumeric */ if(!eregi("^([0-9a-z])*$", $subuser)){ $form->setError($field, "* Username not alphanumeric"); } } ?> Thanks. (none of these errors use to occur until I tried to put in 'email is being used' part.
  20. I recieve this error when using the code below; Parse error: syntax error, unexpected T_ELSE in /home/myveeco/public_html/include/session.php on line 315 <?php /* Email error checking */ $field = "email"; //Use field name for email if(!$subemail || strlen($subemail = trim($subemail)) == 0){ $form->setError($field, "* Email not entered"); } else{ /* Check if valid email address */ $regex = "^[_+a-z0-9-]+(\.[_+a-z0-9-]+)*" ."@[a-z0-9-]+(\.[a-z0-9-]{1,})*" ."\.([a-z]{2,}){1}$"; if(!eregi($regex,$subemail)){ $form->setError($field, "* Email invalid"); } $subemail = stripslashes($subemail); } else{ if($database->emailTaken($subemail)){ $form->setError($field, "* Email already in use"); } } ?> Line 315 is this "else{" Just above "if($database->emailTaken($subemail)){" I want it so it checks if an email is entered, then checks if the email is valid, then checks if the email is already in use. If it is in use, it gives en error as shown there, the problem isn't the code itself, its the if and else statements. Don't know how to work it out. Any ideas?
  21. Okay, what about the sizeof the image itself, not the file.
  22. I take it nobody wants to help x.x Kay, ill try sort it out I don't know the problem tho thats the thing, if i knew I might be able to fix it ,but whats wrong with the if statement tho :/
  23. sorry about not using proper PHP tags, its just became a habbit to do short tags. Anyone know the problem.
  24. It could be 3 things Type of image (eg: JPG, IMG ) Size of the image file Size of the image itself (W by H) The easiest way, is to test out other image files, or check, lets say if you've uploaded a JPG, and it shows up, and the file that isn't showing, is JPG, then we can ignore the type of image. Now we can keep the file as JPG, but maybe create an image the same file size, bit a smaller image itself (W by H). If that doesn't show up still, then easy solution is, its the size of the file. Though, if it shows up, its the size of the image itself. Alot of work there to check out if it works. If you find the problem, and you don't know how to change the sizes, or type. Post the code, and someone will assist you. Hope this actually helps you.
  25. <? /* Requested Username error checking */ $req_user = trim($_GET['user']); if(!$req_user || strlen($req_user) == 0 || !eregi("^([0-9a-z])+$", $req_user) || !$database->usernameTaken($req_user)){ die("Username not registered"); } /* Logged in user viewing own account */ if(strcmp($session->username,$req_user) == 0){ echo "<h1>My Account</h1>"; } /* Visitor not viewing own account */ else{ echo "<h1>User Info</h1>"; } /* Display requested user information */ $req_user_info = $database->getUserInfo($req_user); /* Display Username */ echo "<b>Username: ".$req_user_info['username']."</b><br>"; /* Display Email */ echo "<b>Email:</b> ".$req_user_info['email']."<br>"; if(strcmp($session->username,$req_user) == 0){ echo "<br><a href=\"useredit.php\">Edit Account Information</a><br>"; } ?> However, I modified the code to the following (this involves the htm so look out for the php mainly) <? /** * UserInfo.php * * This page is for users to view their account information * with a link added for them to edit the information. * * Written by: Jpmaster77 a.k.a. The Grandmaster of C++ (GMC) * Last Updated: August 26, 2004 */ include("include/session.php"); if(strcmp($session->username,$req_user) == 0){ ?> <title>MyVee! User Info</title> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <link href="Style2.css" rel="stylesheet" type="text/css"> <div id="wrapper"> <div id="Layer4"> <div style="color:WHITE;"> <script type="text/javascript"> var d=new Date() var weekday=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday") var monthname=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec") document.write(weekday[d.getDay()] + " ") document.write(d.getDate() + ". ") document.write(monthname[d.getMonth()] + " ") document.write(d.getFullYear()) </script> </div></div> <div id="Layer2"></div> <div id="Layer1"></div> <div id="Layer3"> <p> <? echo "<h1>My Account</h1>"; /* Display requested user information */ $req_user_info = $database->getUserInfo($req_user); /* Username */ echo "<b>Username: ".$req_user_info['username']."</b><br>"; /* Email */ echo "<b>Email:</b> ".$req_user_info['email']."<br>"; /** * Note: when you add your own fields to the users table * to hold more information, like homepage, location, etc. * they can be easily accessed by the user info array. * * $session->user_info['location']; (for logged in users) * * ..and for this page, * * $req_user_info['location']; (for any user) */ /* If logged in user viewing own account, give link to edit */ echo "<br><a href=\"useredit.php\">Edit Account Information</a><br>"; ?> </p> <p>[ <a href="http://www.myvee.co.uk">back</a> ] </p> </div> </div> <?php } else { header("index.php"); } ?> This displays to all users, including the user visiting there own page just the [ back ] link, which sends you back to index.php, when initially, as set at the top, if the user is viewing there OWN ACCOUNT DETAILS, it shows the page with account details, else, which is at the bottom redirects users to index.php. The first codde displayed, (the html isn't included) this shows the user logged in viewing there account details, the "edit account details" link, aswell as the heading "MY ACCOUNT" if user isn't viewing there own account details, the heading is "USER INFO" and does not display "edit account details" link. I want the userlogged in viewing there own account details to be able to view there account details, as for everyone else, if they aint viewing there own account details, they dont find out the users details, so they get redirected back to index.php. I want to know what is wrong with the second code, and repairing. Thank you
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.