Jump to content

iarp

Members
  • Posts

    326
  • Joined

  • Last visited

Everything posted by iarp

  1. I'd like to donate, but as the main site is down i can't find any links, email addresses.. nothing. (I have searched both this site and Google) If someone could pm/post the address I'd appreciate it. P.S. I may have just missed seeing a link somewhere in my travels of the site.... just forward me to it thanks.
  2. I figured it out, maybe it was because i was on my laptop and slightly distracted, but $row['site_location'] should have been $row['config_value']; all works now
  3. Hey, function links() { $query = "SELECT config_value FROM " . TBL_CONFIG . " WHERE config_name='site_location'"; $result = mysql_query($query); $row = mysql_fetch_array($result, MYSQL_ASSOC); echo "/" . $row['site_location'] . "/"; } Website coding: The only outcome i get from that is // Test on the page itself. Oops i forgot one part. function login(){ echo '<a href="./index.php">Home</a><br />'; if (isset($_SESSION['user_id']) AND (substr($_SERVER['PHP_SELF'], -10) != 'logout.php')) { echo '<a href="./logout.php">Logout</a><br /> <a href="./admin/profile.php">Profile</a><br /> <a href="./admin/">Admin Panel</a><br />'; if ($_SESSION['userlevel'] >= 9) { echo '<a href="/todo.php">To do list</a><br /> <a href="./admin/view_users.php">View Users</a><br />'; } } else { // Not logged in. echo ' <a href="register.php">Register</a><br /> <a href="' . links() . 'login.php">Login</a><br /> <a href="forgot_password.php">Forgot Password</a><br /> '; } } thats another function that also calls links() and it doesn't work eithor.
  4. Worked, thanks. My understanding for include_once was that it could be included wherever you wanted on the page and it only be evaluated once.
  5. No errors, just Please Try Again.
  6. Hey, I have this function: function site_name() { include_once('mysql_connect.php'); $query = "SELECT site_name FROM " . TBL_CONFIG; $result = @mysql_query($query); $row = mysql_fetch_array($result, MYSQL_ASSOC); if ($result) { echo $row['site_name']; } } which i use in my header title: in my login page i use: function escape_data($data) { if (ini_get('magic_quotes_gpc')){ $data = stripslashes($data); } if(function_exists('mysql_real_escape_string')) { global $dbc; $data = mysql_real_escape_string(trim($data), $dbc); } return $data; } Site_name is interfering with escape_data some how and you can't login if i leave site_name(); in there, but if i comment it out it works fine. Am i missing something? If a user tries to login, they only see "Please try again." because username and pass get blanked out by the escape_data problem. Full login page: <?php include('./includes/header.php'); if (isset($_POST['submitted'])) { // Check if the form has been submitted. require_once ('./includes/mysql_connect.php'); // Connect to the database. // Validate the email address. if (!empty($_POST['username'])) { $un = escape_data($_POST['username']); } else { echo '<p><font color="red" size="+1">You forgot to enter your username!</font></p>'; $un = FALSE; } // Validate the password. if (!empty($_POST['pass'])) { $p = escape_data($_POST['pass']); } else { $p = FALSE; echo '<p><font color="red" size="+1">You forgot to enter your password!</font></p>'; } if ($un && $p) { // If everything's OK. // Query the database. $query = "SELECT user_id, first_name, userlevel FROM " . TBL_USERS . " WHERE (username='$un' AND password=SHA('$p')) AND active IS NULL"; $result = mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error()); if (@mysql_num_rows($result) == 1) { // A match was made. // Register the values & redirect. $row = mysql_fetch_array ($result, MYSQL_NUM); mysql_free_result($result); mysql_close(); // Close the database connection. $_SESSION['user_id'] = $row[0]; $_SESSION['first_name'] = $row[1]; $_SESSION['userlevel'] = $row[2]; // Start defining the URL. $url = 'http://' . $_SERVER['HTTP_HOST']; // Check for a trailing slash. if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\') ) { $url = substr ($url, 0, -1); // Chop off the slash. } // Add the page. $url .= '/index.php'; ob_end_clean(); // Delete the buffer. header("Location: $url"); exit(); // Quit the script. } else { // No match was made. echo '<p><font color="red" size="+1">Either the username and password entered do not match those on file or you have not yet activated your account.</font></p>'; } } else { // If everything wasn't OK. echo '<p><font color="red" size="+1">Please try again.</font></p>'; } mysql_close(); // Close the database connection. } // End of SUBMIT conditional. ?> <h1>Login</h1> <form action="login.php" method="post" class="contact_login"> <p><label>Username:</label> <input type="text" name="username" size="20" maxlength="40" value="<?php if (isset($_POST['username'])) echo $_POST['username']; ?><?php if(isset($_GET['username'])) echo $_GET['username']; ?>" /></p> <p><label>Password:</label> <input type="password" name="pass" size="20" maxlength="20" value="<?php if(isset($_GET['temppassword'])) echo $_GET['temppassword']; ?>" /></p> <div align="center"> <input type="submit" name="submit" value="Login" /><br /> <small><a href="../forgot_password.php">Forgot Password</a> | <a href="../register.php">Register</a></small> </div> <input type="hidden" name="submitted" value="TRUE" /> </form> <?php include ('./includes/footer.php'); ?>
  7. On one of my pages i have <?php site_name(); ?> I get the error: the function site_name() is: function site_name() { include_once('../includes/mysql_connect.php'); $query = "SELECT site_name FROM " . TBL_CONFIG; $result = mysql_query($query) or trigger_error (mysql_error()); if ($result) { echo $page_title; } mysql_close(); } Can you not call a mysql database in a function?
  8. How you would what? combine on a webpage?
  9. if ($Recipient == "test1") { $emailto = 'email1@email.com'; } else if ($Recipient == "test2") { $emailto = 'email2@email.com; } else if($Recipient == "test3") { $emailto = 'email3@email.com'; } else { $errors[] = 'Incorrect Selection #1'; // to prevent people from entering in false e-mail addresses, this provides an error message to be displayed. I used an errors array } Course you could use a switch statement, but i've never used one before so i'm not familiar with writing them. i use this script on http://moha.iarp.ca/contact.php as you can see i also have another one for choosing a subject.
  10. Thank-you, that fixed that page. For my original problem, i went with something simple: <?php include ('../includes/header.php'); include_once('../includes/mysql_connect.php'); $query = "SELECT COUNT(*) FROM " . TBL_USERS . " WHERE active != NULL"; $result = mysql_query($query); $num = mysql_num_rows($result); echo "Number of accounts that don't have <i>NULL</i> for active: " . $num; include('../includes/footer.php'); ?> Dunno about you but i thought that was pretty simple. There's 2 users in the database both, for the active field have been set to NULL. In phpMyAdmin the check box for null is checked just to make sure. Run the script on http://www.iarp.ca/admin/index.php and you can see it shows 1!
  11. Hey, This is the page's full code. <?php # Script 7.4 - view_users.php //retrieves all records from the users table session_name ('MOHA'); session_start(); // Start the session. $page_title = 'View Users'; include('../includes/header.php'); //page header /* if ($userlevel >= "9"){ */ echo '<h1 id="mainhead">Registered Users</h1>'; require_once('../includes/mysql_connect.php'); //display number of records $display = PAGE_DISPLAY; //determine how many pages there are if (isset($_GET['np'])) { //already been determined $num_pages = $_GET['np']; } else {// need to determine //count number of records $query = "SELECT COUNT(*) FROM " . TBL_USERS . " ORDER BY reg_date ASC"; $result = mysql_query($query); $row=mysql_fetch_array($result, MYSQL_NUM); $num_records = $row[0]; //calculate the number of pages if ($num_records > $display) { $num_pages = ceil($num_records/$display); } else { $num_pages = 1; } }//end of np if //determine where in the database to start returning results. if (isset($_GET['s'])) { $start = $_GET['s']; } else { $start = 0; } //default column links. $link1 = "{$_SERVER['PHP_SELF']}?sort=lna"; $link2 = "{$_SERVER['PHP_SELF']}?sort=fna"; $link3 = "{$_SERVER['PHP_SELF']}?sort=dra"; $link4 = "{$_SERVER['PHP_SELF']}?sort=una"; $link5 = "{$_SERVER['PHP_SELF']}?sort=ara"; //determine the sorting order if (isset($_GET['sort'])) { //use existing sorting order. switch ($_GET['sort']) { case 'lna': $order_by = 'last_name ASC'; $link1 = "{$_SERVER['PHP_SELF']}?sort=lnd"; break; case 'lnd': $order_by = 'last_name DESC'; $link1 = "{$_SERVER['PHP_SELF']}?sort=lna"; break; case 'fna': $order_by = 'first_name ASC'; $link2 = "{$_SERVER['PHP_SELF']}?sort=fnd"; break; case 'fnd': $order_by = 'first_name DESC'; $link2 = "{$_SERVER['PHP_SELF']}?sort=fna"; break; case 'dra': $order_by = 'registration_date ASC'; $link3 = "{$_SERVER['PHP_SELF']}?sort=drd"; break; case 'drd': $order_by = 'reg_date DESC'; $link3 = "{$_SERVER['PHP_SELF']}?sort=dra"; break; case 'una': $order_by = 'username ASC'; $link4 = "{$_SERVER['PHP_SELF']}?sort=una"; break; case 'dna': $order_by = 'username DESC'; $link4 = "{$_SERVER['PHP_SELF']}?sort=und"; break; case 'ara': $order_by = 'userlevel ASC'; $link5 = "{$_SERVER['PHP_SELF']}?sort=ara"; break; case 'ard': $order_by = 'userlevel DESC'; $link5 = "{$_SERVER['PHP_SELF']}?sort=ard"; break; default: $order_by = 'reg_date DESC'; break; } $sort = $_GET['sort']; } else { $order_by = 'reg_date ASC'; $sort = 'drd'; } //make the query $query = "SELECT username, first_name, last_name, email, userlevel, active, DATE_FORMAT(reg_date, '%M %d %Y') AS dr, user_id FROM " . TBL_USERS . " ORDER BY $order_by LIMIT $start, $display"; $result = mysql_query($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error()); $num = mysql_num_rows($result); if ($num > 0) { //if it ran ok display the records if ($_GET['activated'] == TRUE){ echo "<div style=\"background-color: #FFFF00\"><h1>Account Activated!</h1></div>"; } echo "<p>There are currently $num_records registered users.</p>\n"; //table header echo '<table align="center" cellspacing="0" cellpadding="5"> <tr> <td align="left"><b>Edit</b></td> <td align="left"><b>Delete</b></td> <td align="left"><b><a href="' . $link4 . '">Username</a></b></td> <td align="left"><b><a href="' . $link2 . '">First Name</a></b></td> <td align="left"><b><a href="' . $link1 . '">Last Name</a></b></td> <td align="left"><b>E-mail Address</b></td> <td align="left"><b><a href="' . $link5 . '">User Level</b></td> <td align="left"><b><a href="' . $link3 . '">Date Registered</a></b></td> <td align="left"><b>Notes</b></td> </tr>'; //Fetch and print all the records $bg = '#eeeeee'; // set the background color while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $bg = ($bg == '#eeeeee' ? '#ffffff' : '#eeeeee'); // switch the background color echo '<tr bgcolor="' . $bg . '"> <td align="left"><a href="edit_user.php?id=' . $row['id'] . '">Edit</a></td> <td align="left"><a href="delete_user.php?id=' . $row['id'] . '">Delete</a></td> <td align="left">' . $row['username'] . '</td> <td align="left">' . $row['first_name'] . '</td> <td align="left">' . $row['last_name'] . '</td> <td align="left">' . $row['email'] . '</td> <td align="left">'; if ($row['userlevel'] == "2"){echo "User";} else if($row['userlevel'] == "9") {echo "Admin";} else if($row['userlevel'] == "10"){echo "System Admin";} else { echo "Fix this person User Level";} echo '</td> <td align="left">' . $row['dr'] . '</td> <td align="left">'; if ($row['active'] != ""){echo "<a href=\"edit_user.php?id=" . $row['user_id'] . "&activated=TRUE\">Activate!</a>";} echo ' </tr>'; } echo '</table>'; //free up the query resources mysql_free_result($result); } else { // if it didn't run ok echo '<p class="error">There are currently no registered users.</p>'; } //close the connection mysql_close(); //make the links ot other pages, if needed. if ($num_pages > 1) { echo '<br /><p>'; //determine what page the script is on. $current_page = ($start/$display) + 1; //if its not on the first page, make a previous button. if ($current_page != 1) { echo ' <a href="view_users.php?s=' . ($start - $display) . '&np=' . $num_pages . '">Previous</a> '; } //make all the number pages. for ($i = 1; $i <= $num_pages; $i++) { if ($i != $current_page) { echo ' <a href="view_users.php?s=' . (($display * ($i - 1))) . '&np=' . $num_pages . '&sort=' . $sort . '">' . $i . '</a> '; } else { echo $i . ' '; } } //if it's not the last page, make a Next button. if ($current_page != $num_pages) { echo ' <a href="view_users.php?s=' . ($start + $display) . '&np=' . $num_pages . '&sort=' . $sort . '">Next</a> '; } echo '</p>'; }// enf of links section include('../includes/footer.php'); /*} else { // Start defining the URL. $url = 'http://' . $_SERVER['HTTP_HOST']; // Check for a trailing slash. if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\') ) { $url = substr ($url, 0, -1); // Chop off the slash. } // Add the page. $url .= '/login.php'; header("Location: $url"); exit(); // Quit the script. }*/ ?> I added or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error()); in a vein attempt to find out what's wrong and i now get this error: So hopefully this is what's going wrong with the page and my supposed "ghost" in the database. I've looked through this code and as far into php as i am i don't see anything wrong. This code is running on my main website in which i just copied and pasted from my test website to my main and still got the same error. Hopefully someone can see this error that i've made somewhere. Link to original post with my problems http://www.phpfreaks.com/forums/index.php/topic,193538.0.html
  12. Hey, I finally figured out how to make pages easily editable by storing all the info in a database. Now I'm trying to figure out how to make it so an admin could make a new page. I don't need the coding, if someone could point me in a general direction of where i'd find out how that would be awesome. I don't understand how wordpress and them work when you make a new page... yet it's not physically there. Unless the pages can be accessed by ?p=### then how does one change ?p### to /page-name
  13. Hey, The other day i transfered a website to my laptop that runs mysql5 and newest php, and it was giving me a ton of errors because my web host uses mysql4 and php 4.4.8. My laptop is giving me an error saying session_start is being ignored in my header file because it was called already in the main page. Which is a better location for session_start() ? in the header.php which is include(''); into each page, or call session_start at the very beginning before the header or anything else.
  14. Hey, I know i could just make a script that allows people to download things, but if i directly link a .exe every browser tries to view it as a page and it can't be downloaded at all. Any clues?
  15. From my understanding you can make your own php.ini file and upload it to the root folder where the script for sending the e-mail is located.
  16. The script i used to create the table was CREATE TABLE `MOHA_users` ( `user_id` int(10) unsigned NOT NULL auto_increment, `username` varchar(15) NOT NULL default '', `first_name` varchar(20) NOT NULL default '', `last_name` varchar(40) NOT NULL default '', `email` varchar(40) NOT NULL default '', `password` varchar(90) NOT NULL default '', `ip_address` varchar(15) NOT NULL default '0', `userlevel` tinyint(1) unsigned NOT NULL default '2', `active` varchar(32) default NULL, `registration_date` datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (`user_id`) ) TYPE=MyISAM; So active's default is NULL, but on the registration page, it sets that column to a string of characters and then gets reset to NULL after they follow an activation link via e-mail
  17. What do u mean? And how's this topic solved? How did u solve the problem? I edited the post so fast you didn't see it.
  18. I thought the OP wanted to Submit & Preview Print which would imply submitting it and the end-user printing out their own copy. Unless the OP has specified that they want to be able to edit it before the final submission, then it should work. Just use mail() before calling the pop-up that way the e-mail is sent and the pop-up happens. Again commit the submitted poem to a variable accessible server wide or in a database and it should work fine. EDIT: Dammit.... it's 12:30 in the morning and i'm not going to be able to sleep.... i'ma try to make this work now.
  19. What about having javascript pop open a window that called upon a $_SESSION['poem_submitted'] and displayed the results on another page thats opened by the pop-up like print.php As long as you commit their poem's info to the session or if it's going to be saved in a database just call upon the database or session in the pop-up window.
  20. Forgot to add database: Table: MOHA_users: Structure: user_id username first_name last_name email password ip_address userlevel active registration_date currently in MOHA_users: 15 iarp Ian R-P iarp@cogeco.ca hd5-password ipaddress 10 NULL 2008-04-22 00:31:58 Table: MOHA_urls Structure: url_id url title description submitter approved currently in MOHA_urls 23 www.moha.on.ca Current MOHA Website The current MOHA website. Ian Y 20 www.omha.net/ Ontario Minor Hockey Association OMHA's Website Ian Y
  21. Hey, If you've used wordpress, when it's first installed it usually shows posts like www.domain.com/?p=123. Theres an option they called Permalinks that allow you to have it like www.domain.com/day/month/year/post-name, or many different configurations. What is this option called? i'm trying to look it up on Google but don't even know where to start looking for a name. EDIT: For some reason i think it's something called php rewrite... i can't remember though.
  22. Alot of hosts only allow sql connections from within their own network for security reasons. Other then that, you'd have to contact tech support for the info because if your using a shared server it's network address won't be myothersite.com
  23. Most likely calls upon a database to retrieve whatever is in # 432 in the table.
×
×
  • 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.