small firewall help

Im working on a site that requires it to be closed temporarily I have made the code but it doesn’t seem to work, I get an unexpected $end on the last line of code
i have no idea why, i was told it should work.

ALSO;
Theres an issue with forms in IE where it makes it bigger (adds padding) than it should if you know how to fix this i would greatly appriecitate it.

[attachment deleted by admin]

You’re not closing the opening brackets for the if statement.

thanks I was scratching my head over it, Can’t believe I missed such a small thing, Any how I fix that but the header doesn’t work

I get this, I dont know much about redirecting.
Warning: Cannot modify header information - headers already sent by (output started at /home/dri49407/public_html/index.php:2) in /home/dri49407/public_html/index.php on line 6

-I never imagined such a simple thing could be trouble, anyhow heres the code.

<?php $closed_password = $_POST['closed_password']; if ( $closed_password == 'test' ) { header( 'Location: http://www.password_correct.com/'); } ?> This is a Closed website, to Enter
you must type in the password


right now the php is at the top of the page,
can’t remember if its supposed to be after the tag or not, I believe it shouldn’t though. :-?

i figure i need to refresh the page.

header() outputs header information, which can only be sent before anything is sent to the browser. You’re trying to call header() after outputting HTML (the DOCTYPE tag), which generates the error.

I figured that was the problem… Im not too great with php recently ive got to relearn most of it but thats beside the point.
SOooo… what would you recommend as an alternative solution?

--------------------edit----------------------
i read that it may have somthing to do with utf8 with bom

“Is there a serious problem with utf8 encoding?
Answer: no- utf8 with bom is a problem…”

Although I have no idea about this and believe theres an easier and better way.

It has nothing to do with UTF-8 encoding, nor with whatever bom’s supposed to be. What you need to do is move any non-PHP characters (DOCTYPE tag) below the PHP part of your page. Non-PHP characters are directly sent to the browser, thus blocking any further headers.

i get no errors now but for some reason it does nothing
visit here…
http://drivingqueensland.com/
although the server is changing it soon so try
http://drivingqld.com/

password is currently test
the code for the site is

<?php
$closed_password = $_POST['closed_password'];

if ( $closed_password == 'test' ) {
  header( 'Location: http://www.password_correct.com/');
  }
?>
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>

  
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1' />
<title>CLOSED WEBSITE</title>
<style type='text/css'>
<!--
.style1 {
	color: #FFFFFF;
	font-weight: bold;
}
-->
</style>
</head>

<body bgcolor='#AADBFF'>
<center>
  
  <table width='400' border='0' cellpadding='5' cellspacing='10' bordercolor='#0099FF' bgcolor='#66CCFF'>
    <tr>
      <td width='5' height='15' bgcolor='#AADBFF'></td>
      <td width='330' height='5' bgcolor='#AADBFF'></td>
      <td width='5' height='5' bgcolor='#AADBFF'></td>
    </tr>
    <tr>
      <td width='5' height='5' bgcolor='#AADBFF'></td>
      <td width='330' height='200' align='left' valign='middle' background='images/closed_image.jpg' bgcolor='#AADBFF'>
	  
	  <!-- doesn't work for some reason screws up text  <form method='post' action=''> -->
	  
	  <form method='post' action='index.php'>

		<span class='style1'>This is a Closed website, to Enter</span> <br />
		<span class='style1'>you must type in the password</span><br />
	        <br />
			<div align='center'>
			<input name='closed_password' type='password' id='closed_password' />
			<br />
			<input name='submit' type='button' value='Enter' />
			</div>
	  </form>
	  
	  </td>
      <td width='5' height='5' bgcolor='#AADBFF'></td>
    </tr>
    <tr>
      <td width='5' height='5' bgcolor='#AADBFF'></td>
      <td width='330' height='5' bgcolor='#AADBFF'></td>
      <td width='5' height='15' bgcolor='#AADBFF'></td>
    </tr>
  </table>
  <br />
  
</center>
</body>
</html>

WAIT it works!!!.. but only if you press enter on your keyboard while in the text field… :(

Your button’s type attribute should be set to submit, otherwise it won’t submit the form.

What do you mean?

I’ve always used this^ and never had any issues, :oops: I’m afraid i don’t know how to set attributes on a button

Instead of using , you should use . That way, the form gets submitted.

type=attribute?
ok thank you.
Once ive tested and got it working i’ll upload a final version for everyone to use.

Input, type, name, value, class, href, etc. They’re all attributes for HTML elements.

Sponsor our Newsletter | Privacy Policy | Terms of Service