Jump to content


  • Posts

  • Joined

  • Last visited

Everything posted by kaseytraeger

  1. Hi everyone, Got another PHP coding question for y'all. In trying to modularize my web site, I decided to create a "header.php" page that contains all the code common at the top of each of my web pages and use the php include() command to add the header to each web page. The header.php file contains the standard protocol for each web page (i.e., <!doctype>,<head>,<title>, and <meta> tags). In fact, here is the code for my header page. ><?php echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?".">"; ?> <!doctype html public "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="content-Type" content="text/html; charset=windows-1252" /> <meta http-equiv="content-Language" content="en-us" /> <meta http-equiv="imagetoolbar" content="no" /> <meta http-equiv="pragma" content="no-cache" /> <meta http-equiv="expires" content="-1" /> <meta name="copyright" content="Copyright 2004, Kasey's Creations" /> <meta name="mytopic" content="Kasey's Creations" /> <meta name="robots" content="noimageclick,noimageindex,nocache,noarchive" /> <meta name="description" content="Kasey's Creations web site graphics for your personal and small business web sites." /> <meta name="keywords" content="kasey's creations, Kasey's Creations, kaseyscreations, KaseysCreations, Kaseys Creations, kaseys creations" /> <title></title> <!-- StyleSheet --> <link rel="stylesheet" href="css/interface3.css" type="text/css" /> </head> <body class="background"> <div id="container_page"> <div id="image_header"> <img src="graphics/Interface3_Header.gif" width="753 px" height="208px" alt="Page Header" /> </div> <div id="contactbutton"> <a href="" onmouseover="mouseover(0)" onmouseout="mouseout(0)"> <img src="graphics/Interface3_ContactButton_up.gif" width="123px" height="18px" alt="Contact Us" id="Interface3_Contactbutton" name="Interface3_ContactButton" /></a> </div> <div id="privacybutton"> <a href="privacypolicy.php" onmouseover="mouseover(1)" onmouseout="mouseout(1)"> <img src="graphics/Interface3_PrivacyButton_up.gif" width="123px" height="18px" alt="Privacy Policy" id="Interface3_PrivacyButton" name="Interface3_PrivacyButton" /></a> </div> <div id="date-time" class="smalltext"> <?php $hour = date(g)-3; if ( $hour<=0 ) $hour += 12; echo( "$hour:".date(i)." ".date(a) ); echo(" :: &nbsp"); echo( date("d-M-Y") ); ?> </div> You'll notice that my header file contains some of the body content, including buttons for "contact us", "privacy policy", the date and time, etc. You'll also notice that the <title> block of the header is blank. In order to make the header file truly modular, I want to be able to pass a unique page <title> for each page I use it on. This header file is called from each web page in my site using the php include() command as the very first line of the page file, as seen here: ><?php include("header.php"); ?> <div id="hansel-gretel" class="smalltext"> You are here: Home </div> <div id="menu" class="smalltext" align="right" style="position:absolute; left:635px; top: 150px; visibility:visible; z-index:1;"> Services<br />Pricing<br />Portfolio<br />Privacy Policy<br />Terms & Conditions<br />Members/Clients<br />Contact Us<br />About Us<br /> </div> . . . I have no problem getting the scripts to run correctly when I use them in this manner. When I try to pass the page title (from index.php to header.php) as a variable, however, the header does not execute and any page content directly coded within the page header (including my css file) does not load. So, for example, if header.php is "included" as the first line in index.php, only the content in index.php will load into the browser. Here is the code I was trying to use to insert a unique page title for each page. In index.php: ><?php include("header.php?mytitle=ThisIsThePageTitle"); ?> In header.php: >. . . <title> <?php $thetitle = $_GET['mytitle']; echo("$thetitle"); ?> </title> . . . I need a fresh set of eyes to look at this. I'm so cross-eyed now that I honestly don't see what I'm doing wrong. Thanks, in advance, to anyone who takes some time out of their day to help me! Good luck...it seems like a needle in a haystack to me! Kasey
  2. So does this mean that my backup will be deleted since I did not specify another server as the destination for the FTP process? Kasey
  3. Hi all, I just noticed this cool backup feature that's now part of cPanel. Decided I'd like to try it out but soon learned that I don't really know what I'm doing. Help please! On my main cPanel page, I clicked the link for "Backup" under the section for "Site Maintenance." Once at the Backup page, I clicked the link for "Generate/Download a Full Backup." At the next page, I chose "Remote FTP Server" as my backup destination and entered my email address. So my steps were... cPanel Home >> Backup >> Generate/Download a Full Backup >> Destination: Remote FTP Server. After the backup was complete, I received an email containing the following information: Can't call method "login" on an undefined value at /usr/local/cpanel/bin/ftpput line 24. -------------------------------------------------------- Copying Mail files....Done Copying frontpage file....Done Copying proftpd file....Done Copying www logs.............Done Grabbing mysql dbs...Done Grabbing mysql privs...Done Copying mailman lists....Done Copying mailman archives....Done Copying homedir....Done Copying cpuser file.......Done Copying crontab file.......Done Copying quota info.......Done Storing Subdomains....Done Storing Parked Domains....Done Storing Addon Domains....Done Copying password.......Done Copying shell.......Done pkgacctfile is: /tmp/backup-1.31.2004_03-13-22_kaseysc.tar.gz Creating Archive ....Done I tried looking in my /tmp/ directory for the backup file, but it's not there. Can anyone clarify for me what the email is telling me and where I can find my backup file? At this point, I'm not sure exactly where my tar.gz backup file is, except that perhaps its lost somewhere in the vast ether of cyberspace! Also, there are three choices for backup download destination, but I'm not sure what the benefits/disadvantages of each method is, and which method is the most common one in use. If you can explain this to me, you truly rock. The three download destinations are: (1) Home Directory (2) FTP Remote Server (3) FTP Remote Server (passive mode transfer) Thanks a bunch, Kasey
  4. I want to say thank you to everyone for spending so much time helping me with this code. Big thanks to Tracy -- your suggestion fit the bill. The code runs -- yaaaay! So what was the deal with this? Is it conflicting processors (e.g., PHP processor trying to run an XML directive?) I hadn't heard of that before, but I guess if they both use the same <? symbol to declare the start of a sequence of code to be processed, then that would make sense. Thanks again everyone! Kasey
  5. Hiya TCH-Raul Yes, the file does have a .php extension. I didn't clearly state that ... sorry for the confusion! Kasey
  6. Hello out there all you TCH folk! I've got a basic PHP question. Does anyone know of any conflicts between PHP and XML or XHTML? I'm trying to update my web site to be XHTML compliant and I've discovered a problem. Here is the basic skeleton of one of my web pages. I've removed non-essential fluff (e.g., graphics, extra text, etc.) to make it easier to read. Even this simplified page will not display on my browser. All I see is a blank, white screen. <?xml version="1.0" encoding="UTF-8"?> <!doctype html public "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Testing PHP inside XHTML</title> </head> <body> <p>Here is the clock -- <?php echo( date("g:i a") ); echo(", "); echo( date("d-M-Y") ); ?> </p> </body> </html> Can anyone tell me why this code will not run? I've tried various versions of the code, including removing the <?xml ...> line and the xmlns="http://... " statement from the document. Even removing these two items doesn't help. In fact, the only way I can get this page to display at all is to code it like this. <html> <head> <title>Testing PHP inside XHTML</title> </head> <body> <p> Here is the clock -- <?php echo( date("g:i a") ); echo(", "); echo( date("d-M-Y") ); ?> </p> </body> </html> I know there has to be some way to run PHP language inside an XHTML document, but I just don't know how to do it. Can someone help me out? Thanks! Kasey
  7. vendlus, Thank you so much for your reply. I modified my code based on your suggestion, and voila' ... it works again! Thank you, thank you, thank you! You rock! Kasey
  8. Hi everyone, Boy, I sure hope someone out there in TCH forum land can help me. I'm a PHP newbie who is running across errors when trying to use a simple authentication script. Here's the low-down ... Approximately two months ago (sometime in August or early September), I installed a very simple PHP authentication script on my website, along with a dedicated MySQL database to hold user names and passwords. I created two dummy users in the database and tested the authentication script with each "user". Testing involved (1) logging in, (2) moving from page to page while in the same session, and (3) logging out. For each of the dummy users, the script worked beautifully. Since the authentication script was working, I felt safe in putting the project aside while I worked on website for my mother-in-law. Fast forward two months. I pick up where I left off and have done no additional work to my website nor have I modified anything since I last tested the authentication script several weeks ago. Now, however, when I try to log in using my dummy accounts, I receive PHP error messages. Clearly, something has happened since the last time I worked on my website, but I don't know what it is. (FYI -- I am the only person with access to cPanel and the file manager for my website, so there's no chance that anyone has monkeyed with the code. Plus, the current code matches a hard copy of the code that I printed once I got the authentication script to work way back then, so I am confident that nothing's going on with the code.) Here are the error messages I am receiving. Number 1 -- Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /php-bin/verifysession.php:3) in /php-bin/verifysession.php on line 4 Number 2 -- Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /php-bin/verifysession.php:3) in /php-bin/verifysession.php on line 4 I'm really stuck and need to get this login/authentication feature working again. If anyone can tell me what's going on, I'd really appreciate it. It seems to me like it's something with PHP itself, and not necessarily my code, since the errors occur as a result of a standard PHP session function -- session_start(). Immediately following this message, I'm including the source code for my entire PHP authentication script for your review and examination. There are three files -- (1) login.php is the main login page, (2) verifysession.php is used on each page while the user is browsing during a logged-in session, and (3) logout.php closes the session and logs the user out. Thank you in advance to anyone who can shed some light on this for me and help me figure out how to resolve this issue. Thanks so much! Kasey LOGIN.PHP <?php // This script found at www.etronicscomputers.com/docs/phpforbeginners.htm // Check that form fields are not empty; redirect back to login page if any // fields are empty. if( empty($username) || empty($password) ){ header("Location: http://www.kaseyscreations.com"); } else { // Convert field values to simple variables. Add slashes to the username // and md5() the password. $user = addslashes($_POST['username']); $pass = md5($_POST['password']); // Retrieve the keys to unlock the database (set the database connection variables) include("deliberately blacked out the location of keys"); // Connect to the database server $db = mysql_connect("$dbHost", "$dbUser", "$dbPass") or die ("Error connecting to database server."); // Locate and select the database to use mysql_select_db("$dbDatabase", $db) or die ("Unable to locate proper database."); // Search for the proper username/password combo in the database $result = mysql_query("select * from users where username='$user' AND password='$pass'", $db); // Check that at least one row was returned (i.e., there was a match) $rowCheck = mysql_num_rows($result); // If there is a match, grant access to member's-only area if ($rowCheck>0) { // Start the session and register a variable session_start(); session_register('username'); // Redirect the user to another page where we will make sure // they've logged in. echo ('<meta http-equiv="refresh" content="0;url=verifysession.php" />'); } // There was no database match. Send user back to login page. else { echo ("Incorrect username or password. Please click the 'Back' button and try again."); header("Location: http://www.kaseyscreations.com"); } } ?> VERIFYSESSION.PHP <html><head><title>Logout Page</title></head> <body bgcolor="#DEDEBA"> <?php session_start(); if (session_is_registered('username')){ ?> You are logged in.<br/><br /><a href="deliberately/blacked/out/logout.php">Logout</a> <?php } // The session variable is not registered. Return to login page. else { header("Location: http://www.kaseyscreations.com"); } ?> </body></html> LOGOUT.PHP <html><head><title>Successful Logout</title></head> <body bgcolor="#DEDEBA" text="#000000"> <?php session_start(); if (session_is_registered('username')) { // Session variable is registered. The user is ready to logout. session_unset(); session_destroy(); ?> Logout was successful. <?php } else { // The session variable is not registered. // The user should even be on this page. header("Location: http://www.kaseyscreations.com"); } ?> </body></html>
  9. Hi Andy, Thanks for much for taking the time to look at the files. I've uploaded them as simple text files, so you should be able to see them quite easily. The file names are: (1) login.txt (2) logout.txt (3) checklogin.txt (4) login.htm Again, I can't say thank you enough for taking time out of your day to look at this for me! Kasey
  10. Andy, Thanks for looking at my problem. Yes, you are correct. I moved some stuff around in my directories -- still trying to figure out the problem. I was getting myself so confused, that I decided to wipe out all the files I had been working on because I was getting confused as to which ones were related. The stuff you saw in the directory (memberlogin.php and index.php) work fine in Internet Explorer but don't work at all in Netscape. It also doesn't use a MySQL database, so I was told I would have me some performance and security issues. Anyway, I have re-uploaded the files that were giving me the error so you can go in again and see them as I had tried running them. There are four files that go hand-in-hand with each other -- (1)login.htm, (2)login.php, (3)logout.php, (3)checklogin.php. I discovered a typo in the login.htm page ("actoin" instead of "action"), which I corrected. I no longer get the 405 error , but I'm not sure if the script is doing anything because I get a blank white screen after pressing the submit button. It'll take me a little while to make my way through the content of the code (I got it from a tutorial website). Perhaps all is well and good now and I just need to learn what to do now that the user is "logged in". Feel free to take another look at it if you've got the time. This is all new territory to me! All four files are in my public_html directory. Kasey
  11. Hello, I'm just learning PHP, so many times I don't understand all of the error messages that come my way. Here's one for all of you who understand PHP and the idiosyncratic error messages that can come your way ... I am attempting to add a simple login form to my website. The actual page where logins are to occur is called login.htm (located in "public_html/login.htm"). The actual coding of the form looks like this: <form method="post" action="login.php"> UserName: <input type="text" name="username" size="20"><br /> Password: <input type="password" name="password" size="20"><br /> <input type="submit" name="login" value="Submit"> </form> I've set up the script login.php in the same directory as the login form (location = public_html/login.php). I tried to test my code, but was "greeted" by an unfriendly 405 error telling me "METHOD NOT ALLOWED. The requested method POST is not allowed for the URL /login.htm." Mad!!! I have no idea why I'm getting this error. I have other pages in the same directory with forms whose method=post, and they work wonderfully. Can anyone help me? I've been working on this for nearly 4 days and I'm about to pull the last remaining pieces of hair from my head (lookout Yule Brenner, here I come). Thanks a bunch! Kasey P.S. I'm attaching the login.php file in case it's needed to analyze this problem.
  • Create New...