Error Posting To A Php Script

liunx

Guest
Hello,<br /><br />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 ... <br /><br />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:<br /><br /><form method="post" action="login.php"><br />UserName: <input type="text" name="username" size="20"><br /><br />Password: <input type="password" name="password" size="20"><br /><br /><input type="submit" name="login" value="Submit"><br /></form><br /><br />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<br />"METHOD NOT ALLOWED. The requested method POST is not allowed for the URL /login.htm." Mad!!! <br /><br />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.<br /><br />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).<br /><br />Thanks a bunch!<br />Kasey<br /><br />P.S. I'm attaching the login.php file in case it's needed to analyze this problem.<!--content-->
Hi Kasey,<br /><br />Welcome to the family <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> <br /><br />I just had a quick look, and I think you may have made some changes since posting here. The attached file was not complete (on my download anyway), so I can only guess at some of the issues.<br /><br />login.php does not exist. But index.php does, and uses memberlogin.php, which seems to work with an incorrect password - it just takes me back to the login screen <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/biggrin.gif" style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif" /> <br /><br />Andy<!--content-->
Andy,<br /><br />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.<br /><br />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 <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/biggrin.gif" style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif" /> , 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".<br /><br />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.<br /><br />Kasey<!--content-->
Kasey,<br /><br />I'm happy to have a quick look at it if you like, but you will either need to provide the source code (php) or a password for me to get in (by PM, not via posting on the forum).<br /><br />The easiest may be to put a copy of the files in .txt files and then I can link directly to them and read the source code.<br /><br />Andy<!--content-->
Hi Andy,<br /><br />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:<br />(1) login.txt<br />(2) logout.txt<br />(3) checklogin.txt<br />(4) login.htm<br /><br />Again, I can't say thank you enough for taking time out of your day to look at this for me!<br /><br /><img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> Kasey<!--content-->
Kasey,<br /><br />As an aside I'll say that if you want a better script for doing this I would have a look at <a href="http://membership.cgi-central.net/scripts/amember/free.php" target="_blank">amember</a> which I think does everything you are looking for, and has been used by a number of people on this forum.<br /><br />However, in terms of learning PHP, then let's carry on with this script.<br /><br />The checklogin.php will effectively have to go in every web page that you use, if you want to stop people linking to the pages directly. <br /><br />In that file you have<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><?php<br />// Start the session<br />session_start();<br /><br />// Check to make sure the session variable is registered<br />if (session_is_registered('username')){<br /><br />    // The session variable is registered, the user is allowed to see anything that follows.<br />    echo ('Welcome. You are still logged in.');<br />}<br />else {<br /><br />    // The session variable is not registered. Send them back to the login page.<br />    header("Location: /login.htm");<br />}<br />?><!--c2--></div><!--ec2--><br /><br />Where you have the echo ('Welcome...'); you will need to put the information you want to display on the page. Other than that, the bulk of the rest of it should work. Have a search on this forum for how you include files and html into php. Surefire and others have written some very good articles on it. If you can't find them I will add some links tomorrow.<br /><br />I will have a look at setting this up on one of my sites tomorrow (it's 22:25 in the UK now)<br /><br />Andy<!--content-->
 
Top