Author Topic: small firewall help  (Read 2239 times)

digimbyte

  • New Member
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
small firewall help
« on: February 28, 2008, 09:47:26 PM »
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]

Zyppora

  • Global Moderator
  • Senior Member
  • *****
  • Posts: 1401
  • Karma: +0/-0
    • View Profile
Re: small firewall help
« Reply #1 on: February 29, 2008, 05:24:04 AM »
You're not closing the opening brackets for the if statement.
HAVE YOU TRIED DEBUGGING? Example code in this reply deliberately contains BUGS. PHP forum for beginners.

digimbyte

  • New Member
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: small firewall help
« Reply #2 on: March 02, 2008, 09:09:56 PM »
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/');
}
?>

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

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

i figure i need to refresh the page.

Zyppora

  • Global Moderator
  • Senior Member
  • *****
  • Posts: 1401
  • Karma: +0/-0
    • View Profile
Re: small firewall help
« Reply #3 on: March 03, 2008, 04:56:36 AM »
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.
HAVE YOU TRIED DEBUGGING? Example code in this reply deliberately contains BUGS. PHP forum for beginners.

digimbyte

  • New Member
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: small firewall help
« Reply #4 on: March 07, 2008, 08:39:36 AM »
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.

Zyppora

  • Global Moderator
  • Senior Member
  • *****
  • Posts: 1401
  • Karma: +0/-0
    • View Profile
Re: small firewall help
« Reply #5 on: March 07, 2008, 08:56:39 AM »
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.
HAVE YOU TRIED DEBUGGING? Example code in this reply deliberately contains BUGS. PHP forum for beginners.

digimbyte

  • New Member
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: small firewall help
« Reply #6 on: March 12, 2008, 02:11:28 AM »
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

Code: [Select]
<?php
$closed_password 
$_POST['closed_password'&#93;;

if ( $closed_password == 'test' ) {
  
header'Location&#58; http&#58;//www&#46;password_correct&#46;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>

digimbyte

  • New Member
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: small firewall help
« Reply #7 on: March 12, 2008, 02:14:34 AM »
WAIT it works!!!... but only if you press enter on your keyboard while in the text field..  :(

Zyppora

  • Global Moderator
  • Senior Member
  • *****
  • Posts: 1401
  • Karma: +0/-0
    • View Profile
Re: small firewall help
« Reply #8 on: March 12, 2008, 08:34:40 AM »
Your button's type attribute should be set to submit, otherwise it won't submit the form.
HAVE YOU TRIED DEBUGGING? Example code in this reply deliberately contains BUGS. PHP forum for beginners.

digimbyte

  • New Member
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: small firewall help
« Reply #9 on: March 12, 2008, 06:45:16 PM »
What do you mean?
<input name='submit' type='button' value='Enter' />
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

Zyppora

  • Global Moderator
  • Senior Member
  • *****
  • Posts: 1401
  • Karma: +0/-0
    • View Profile
Re: small firewall help
« Reply #10 on: March 13, 2008, 04:31:58 AM »
Instead of using <input name='submit' type='button' value='Enter' />, you should use <input name='submit' type='submit' value='Enter' />. That way, the form gets submitted.
HAVE YOU TRIED DEBUGGING? Example code in this reply deliberately contains BUGS. PHP forum for beginners.

digimbyte

  • New Member
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: small firewall help
« Reply #11 on: March 13, 2008, 06:52:52 PM »
type=attribute?
ok thank you.
Once ive tested and got it working i'll upload a final version for everyone to use.

Zyppora

  • Global Moderator
  • Senior Member
  • *****
  • Posts: 1401
  • Karma: +0/-0
    • View Profile
Re: small firewall help
« Reply #12 on: March 14, 2008, 03:35:38 AM »
Input, type, name, value, class, href, etc. They're all attributes for HTML elements.
HAVE YOU TRIED DEBUGGING? Example code in this reply deliberately contains BUGS. PHP forum for beginners.