Jump to content

[SOLVED] keeps going back to index.html ???????


Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/179329-solved-keeps-going-back-to-indexhtml/
Share on other sites

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 ?

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.

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.

 

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

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

 

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>

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

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  :)

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>

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;

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.