supergrame Posted October 28, 2009 Share Posted October 28, 2009 ok so i started making my site using mostly.html files now i have added a fair chunk of php. My index,html file had to be renamed to index.php because i am using a include function, I got told that if there is any php in any file it has to be named .php so the web server knows that there is php in there. my problem is when i renamed index to .php it wont show up in ie or FF it just reverts back to index.html every time when i would of thought it would of just said file not found or gone to the folder content. So here I am realy confused!?!?!? Please any advise would be brilliant. Quote Link to comment https://forums.phpfreaks.com/topic/179329-solved-keeps-going-back-to-indexhtml/ Share on other sites More sharing options...
supergrame Posted October 28, 2009 Author Share Posted October 28, 2009 THE ERROR Not Found The requested URL /index.html was not found on this server. this is what i put in the URL: http://127.0.0.1/index.php http://localhost/index.php very odd Quote Link to comment https://forums.phpfreaks.com/topic/179329-solved-keeps-going-back-to-indexhtml/#findComment-946168 Share on other sites More sharing options...
supergrame Posted October 28, 2009 Author Share Posted October 28, 2009 maybe is could be a file association issue. Just giving some ideas Quote Link to comment https://forums.phpfreaks.com/topic/179329-solved-keeps-going-back-to-indexhtml/#findComment-946169 Share on other sites More sharing options...
supergrame Posted October 28, 2009 Author Share Posted October 28, 2009 would it have anything to do with this <!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"> <head> <link rel="stylesheet" type="text/css" href="styles.css" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> in index.php ? Quote Link to comment https://forums.phpfreaks.com/topic/179329-solved-keeps-going-back-to-indexhtml/#findComment-946172 Share on other sites More sharing options...
asmith Posted October 28, 2009 Share Posted October 28, 2009 First: Just calm down and do not post one after another without getting any replies. Second, Are you trying local on your own computer? Or It is upload to some server somewhere? If you are trying on a server, There's a file named '.htaccess' there. Paste that file content here. Quote Link to comment https://forums.phpfreaks.com/topic/179329-solved-keeps-going-back-to-indexhtml/#findComment-946178 Share on other sites More sharing options...
supergrame Posted October 28, 2009 Author Share Posted October 28, 2009 ok sorry... Yes it is local on my PC. and yes php is working. Quote Link to comment https://forums.phpfreaks.com/topic/179329-solved-keeps-going-back-to-indexhtml/#findComment-946180 Share on other sites More sharing options...
asmith Posted October 28, 2009 Share Posted October 28, 2009 ok, There are ways to fix that. If your apache is redirecting index.php to index.html, Then you probably have this on httpd.conf file. I gotta see your apache httpd.conf file, I don't remember where it is exactly. However, You can tell your php to look for php codes in the HTML files (or any other extension) also. To do this, Find your apache httpd.conf file and find this line: AddType application/x-httpd-php This line probably looks something like this at your pc: AddType application/x-httpd-php .php .php5 You can add any extension you want, In this case: AddType application/x-httpd-php .php .html after changing that, save the file and restart apache. Now apache interpret your php codes in HTML also. Quote Link to comment https://forums.phpfreaks.com/topic/179329-solved-keeps-going-back-to-indexhtml/#findComment-946183 Share on other sites More sharing options...
supergrame Posted October 28, 2009 Author Share Posted October 28, 2009 ok after alot of reinstalling and messing around with wamp server. It was nothing to do with it. it was this one line of code im my index.php file <?php include("login.php"); ?> I dont understand Quote Link to comment https://forums.phpfreaks.com/topic/179329-solved-keeps-going-back-to-indexhtml/#findComment-946189 Share on other sites More sharing options...
asmith Posted October 28, 2009 Share Posted October 28, 2009 That line is making index.php to index.html? If so, Paste the content of that file here. Quote Link to comment https://forums.phpfreaks.com/topic/179329-solved-keeps-going-back-to-indexhtml/#findComment-946198 Share on other sites More sharing options...
supergrame Posted October 28, 2009 Author Share Posted October 28, 2009 yes that is correct here is the index.php file content <!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"> <head> <link rel="stylesheet" type="text/css" href="styles.css" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Smoking</title> </head> <body> <div id="container"> <div id="header" class="border"><h1>Smokin</h1></div> <div id="navbar" class="border"> <a href="index.html">Home</a> | <a href="forum.php">Forum</a> | <a href="growingguides.html">Growing</a> | <a href="about.html">About</a> | <a href="contact.html">Contact</a> </div> <div id="sidebar" class="border"> <?php include("login.php"); ?> </div> <div id="contentIndex" class="border"> <h2>Welcome to <a href="www.smokin.com">www.smokin.com</a> <p class="content">What you will find on this website!</p> <ol class="content"> <li>Indoor Growing tips and Guides</li> <li>Outdoor Growing tips and Guides</li> <li>IRC chat client setup help for all your marijuana chatting needs</li> <li>Much much more to come</li> </ol> <p class="content">Look around have a bong and don't forget to tell your friends</p> </div> <div id="footer" class="border"> <P class="footer">smokin 2009 © Powerd by <a href="www.superwebs.com">Superwebs</a></P> </div> </div> </body> </html> if i remove the one PHP line it works with the .php ext Quote Link to comment https://forums.phpfreaks.com/topic/179329-solved-keeps-going-back-to-indexhtml/#findComment-946203 Share on other sites More sharing options...
supergrame Posted October 28, 2009 Author Share Posted October 28, 2009 I know you said don't keep posting but i think this is valuable info to save some time. in dreamweaver i click inside this line of code <div id="sidebar" class="border"> and at the bottom of dreamweaver this is the error.. Invalid markup marked invalid because its an overlapping or unclosed tag if the display looks correct it is safe to delete these tags ok so i get rid of this <?php and just use <? and it works but it does not include login.php very frustrating Quote Link to comment https://forums.phpfreaks.com/topic/179329-solved-keeps-going-back-to-indexhtml/#findComment-946220 Share on other sites More sharing options...
dgoosens Posted October 28, 2009 Share Posted October 28, 2009 That line is making index.php to index.html? If so, Paste the content of that file here. probably meant your login.php file Quote Link to comment https://forums.phpfreaks.com/topic/179329-solved-keeps-going-back-to-indexhtml/#findComment-946226 Share on other sites More sharing options...
asmith Posted October 28, 2009 Share Posted October 28, 2009 Yes , Please paste the login.php content here mate. Quote Link to comment https://forums.phpfreaks.com/topic/179329-solved-keeps-going-back-to-indexhtml/#findComment-946230 Share on other sites More sharing options...
supergrame Posted October 28, 2009 Author Share Posted October 28, 2009 here is login.php aswell <?php include("dbconnect.php"); $username=$_POST['username']; $password=$_POST['password']; if (!isset($username) || !isset($password)) { header("Location:index.html"); } elseif (empty($username) || empty($password)) { header("Location:index.html"); } else{ $result=mysql_query("select * from members where username='$username' AND password='$password'"); $rowCheck = mysql_num_rows($result); if($rowCheck > 0){ while($row = mysql_fetch_array($result)){ session_start(); $_SESSION['username'] = "$username"; echo 'Success!'; header("Location:members/membersIndex.php"); } } else { echo 'Incorrect login name or password. Please try again.'; } } ?> <html> <form class="login" action="login.php" method="POST"> Please login below!<br /> <label>User name:</label> <input type="text" name="username"/> <label>Password:</label> <input type="password" name="password" /> <input type="submit" value="Login"/><br /> Not a member? <a href="register.html">Register</a><br /> Forgot your password click <a href="forgotPassword.html">HERE!</a> </form> </html> Quote Link to comment https://forums.phpfreaks.com/topic/179329-solved-keeps-going-back-to-indexhtml/#findComment-946231 Share on other sites More sharing options...
asmith Posted October 28, 2009 Share Posted October 28, 2009 Do you see these lines: header("Location:index.html"); in this file? rename all of these lines to: header("Location:index.php"); Quote Link to comment https://forums.phpfreaks.com/topic/179329-solved-keeps-going-back-to-indexhtml/#findComment-946234 Share on other sites More sharing options...
supergrame Posted October 28, 2009 Author Share Posted October 28, 2009 Ahh yes. How stupid of me sorry for the time wasting Been working on this for over 10 hours starting to get tired. ok well that did work but now for the new error lol The page isn't redirecting properly Firefox has detected that the server is redirecting the request for this address in a way that will never complete. * This problem can sometimes be caused by disabling or refusing to accept cookies. taking a stab im guessing its my sessions code? I was using the old sessions but my browsers keeps saying its old code don't use it Quote Link to comment https://forums.phpfreaks.com/topic/179329-solved-keeps-going-back-to-indexhtml/#findComment-946235 Share on other sites More sharing options...
supergrame Posted October 28, 2009 Author Share Posted October 28, 2009 again sorry for the double posting I think it is because there is php and html in that page and for some reason it keeps redirecting it over and over and over. I will take another look in the morning. your help is much appreciated Quote Link to comment https://forums.phpfreaks.com/topic/179329-solved-keeps-going-back-to-indexhtml/#findComment-946240 Share on other sites More sharing options...
asmith Posted October 28, 2009 Share Posted October 28, 2009 Delete ALL the data in the login.php, And put this one instead to solve your issue: <?php if (isset($_POST['submit'])) { include("dbconnect.php"); $username=$_POST['username']; $password=$_POST['password']; if (!isset($username) || !isset($password)) { header("Location:index.php"); } elseif (empty($username) || empty($password)) { header("Location:index.php"); } else{ $result=mysql_query("select * from members where username='$username' AND password='$password'"); $rowCheck = mysql_num_rows($result); if($rowCheck > 0){ while($row = mysql_fetch_array($result)){ session_start(); $_SESSION['username'] = "$username"; echo 'Success!'; header("Location:members/membersIndex.php"); } } else { echo 'Incorrect login name or password. Please try again.'; } } } ?> <html> <form class="login" action="login.php" method="POST"> Please login below!<br /> <label>User name:</label> <input type="text" name="username"/> <label>Password:</label> <input type="password" name="password" /> <input type="submit" name="submit" value="Login"/><br /> Not a member? <a href="register.html">Register</a><br /> Forgot your password click <a href="forgotPassword.html">HERE!</a> </form> </html> Quote Link to comment https://forums.phpfreaks.com/topic/179329-solved-keeps-going-back-to-indexhtml/#findComment-946344 Share on other sites More sharing options...
mrMarcus Posted October 28, 2009 Share Posted October 28, 2009 when dealing with databases, make sure to sanitize your incoming vars: $username = mysql_real_escape_string ($_POST['username']); $password = mysql_real_escape_string ($_POST['password']); also, lose the double-quotes around $username: $_SESSION['username'] = "$username"; should be: $_SESSION['username'] = $username; Quote Link to comment https://forums.phpfreaks.com/topic/179329-solved-keeps-going-back-to-indexhtml/#findComment-946361 Share on other sites More sharing options...
supergrame Posted October 28, 2009 Author Share Posted October 28, 2009 hey thank you guys that works perfectly Quote Link to comment https://forums.phpfreaks.com/topic/179329-solved-keeps-going-back-to-indexhtml/#findComment-946560 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.