Jump to content

Password problems.


Braveheartt

Recommended Posts

 if($_POST['password'] == "password") 
    //more code...
elseif($_POST['password'] != "password")
      header ( "redirect.php" ); 

 

The 'password' comes from another script which has a text input called "password". The above code (with the rest of my script) gives me an "internal server error"... Any ideas?

Link to comment
Share on other sites

Of course, sorry! :D

 

Input script:

<html><body BGCOLOR="black">
<center><img border="0" src="header.jpg" width="700" height="190" ALT="Bugs login">
<center><form method="POST" action="pass.php"> 

<font face="Verdana, ariel" color="red" size=5>Password required for access</font><br />
<br />
<input type="password" name="password" size="20">

<input type="submit" name="login" value="Login">

</center></body></html>

 

 

Main script which I want to limit access to with a password:

<?php require("menu.php");	
$ida = $id += 0;
if(isset($_POST['login']))
  if($_POST['password'] == "password") 
  //Connect to MYSQL server
   mysql_connect("Localhost", "*removed*", "*removed*") or die(mysql_error());
   //echo "<center><font color='white'>Successfully connected to MySQL!</font></center><br />"; 

  //Connect to MYSQL database   
   mysql_select_db("*removed*") or die(mysql_error());
      echo "<center><font color='white'><h4>Successfully connected to the Bugs Database!</h4></font></center>";
   
   //Retrieve all the data from the table
   $result = mysql_query("SELECT * FROM bugs ORDER BY ID DESC")
   or die(mysql_error());  

  //store the record of table into $row
   echo "<CENTER><TABLE BORDER='2' BORDERCOLOR='#336699' CELLPADDING='2' BGCOLOR='#000000' CELLSPACING='2' WIDTH='100%'></CENTER>";
  echo "<tr> <th><font color='#FFFFFF'>ID</font></th> <th><font color='#FFFFFF'>Priority</font></th> <th><font color='#FFFFFF'>Bug Type</font></th> <th><font color='#FFFFFF'>Poster</font></th> <th><font color='#FFFFFF'>Bug Description</font></th> <th><font color='#FFFFFF'>Screenshot 1</font></th> <th><font color='#FFFFFF'>Screenshot 2</font></th> <th><font color='#FFFFFF'>Screenshot 3</font></th><th><font color='#FFFFFF'>Update</font></th></tr>";
  //keeps getting the next row until there are no more to get
  while($row = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table
   echo "<tr><td align='center'>";
   echo "<font color='white'>".$ida++."</font>"; 
   echo "</td><td align='center'>";
  if($row['priority'] == Urgent)
     echo "<strong><font color='#FF0000'>Urgent</font></strong>";
  elseif($row['priority'] == Medium)   
       echo "<strong><font color='#FF6600'>Medium</font></strong>";	
    elseif($row['priority'] == Low)   
       echo "<strong><font color='#FFCC00'>Low</font></strong>";
       echo "</td><td align='center'>";
     echo "<font color='#FFFFFF'>".$row['type']."</font>";
     echo "</td><td align='center'>"; 
     echo "<font color='#FFFFFF'>".$row['poster']."</font>";
     echo "</td><td align='center'>"; 
     echo "<TEXTAREA wrap='hard' name='des' rows=3 cols=60 COLOR='#FFFFFF' readonly='yes' MAXLENGTH=9999>".$row['description']."</TEXTAREA>";
     echo "</td><td align='center'>"; 	
  if(empty($row['screen1']))
       echo "<font color='#FFFFFF'>No Screenshot submitted</font>";
  else
     echo "<A HREF=".$row['screen1']."><font color='#0099FF'>Screenshot1</font></A>";	  
     echo "</td><td align='center'>";  
  if(empty($row['screen2']))
      echo "<font color='#FFFFFF'>No Screenshot submitted</font>";
  else 	   	  
    echo "<A HREF=".$row['screen2']."><font color='#0099FF'>Screenshot2</font></A>";
    echo "</td><td align='center'>";
  if(empty($row['screen3']))
      echo "<font color='#FFFFFF'>No Screenshot submitted</font>";
  else  
  	  echo "<A HREF=".$row['screen3']."><font color='#0099FF'>Screenshot3</A>";
      echo "</td><td align='center'>";
      echo "<form method='POST' action='bugs_main.php'> <input type='text' value='Your name' name='editor'></form>";
      echo "<form method='POST' action='bugs_main.php'> <input type='submit' value='Fixed!' name='fixed'><br /></form>";
      echo "<form method='POST' action='bugs_main.php'> <input type='submit' value='Working on' name='work'></form>";
      echo "</td></tr>";
} 
  echo "</TABLE>";
  
elseif($_POST['password'] != "password")
      header ( "redirect.php" ); 
  

   ?></font></center></body></html>

Link to comment
Share on other sites

A little bit of my own formatting, try:

<?php require("menu.php");	
$ida = $id += 0;
if(isset($_POST['login']))
{
	if($_POST['password'] == "password") 
		{
			//Connect to MYSQL server
			mysql_connect("Localhost", "*removed*", "*removed*") or die(mysql_error());
			//echo "<center><font color='white'>Successfully connected to MySQL!</font></center><br />"; 

			//Connect to MYSQL database   
			mysql_select_db("*removed*") or die(mysql_error());
			echo "<center><font color='white'><h4>Successfully connected to the Bugs Database!</h4></font></center>";

			//Retrieve all the data from the table
			$result = mysql_query("SELECT * FROM bugs ORDER BY ID DESC") or die(mysql_error());  

			//store the record of table into $row
			echo "<CENTER><TABLE BORDER='2' BORDERCOLOR='#336699' CELLPADDING='2' BGCOLOR='#000000' CELLSPACING='2' WIDTH='100%'></CENTER>";
			echo "<tr> <th><font color='#FFFFFF'>ID</font></th> <th><font color='#FFFFFF'>Priority</font></th> <th><font color='#FFFFFF'>Bug Type</font></th> <th><font color='#FFFFFF'>Poster</font></th> <th><font color='#FFFFFF'>Bug Description</font></th> <th><font color='#FFFFFF'>Screenshot 1</font></th> <th><font color='#FFFFFF'>Screenshot 2</font></th> <th><font color='#FFFFFF'>Screenshot 3</font></th><th><font color='#FFFFFF'>Update</font></th></tr>";
			//keeps getting the next row until there are no more to get
			while($row = mysql_fetch_array( $result ))
				{
					// Print out the contents of each row into a table
					echo "<tr><td align='center'>";
					echo "<font color='white'>".$ida++."</font>"; 
					echo "</td><td align='center'>";
					if($row['priority'] == Urgent)
						{ echo "<strong><font color='#FF0000'>Urgent</font></strong>"; }
					elseif($row['priority'] == Medium)   
						{ echo "<strong><font color='#FF6600'>Medium</font></strong>"; }
					elseif($row['priority'] == Low)   
						{ echo "<strong><font color='#FFCC00'>Low</font></strong>"; }

					echo "</td><td align='center'>";
					echo "<font color='#FFFFFF'>".$row['type']."</font>";
					echo "</td><td align='center'>"; 
					echo "<font color='#FFFFFF'>".$row['poster']."</font>";
					echo "</td><td align='center'>"; 
					echo "<TEXTAREA wrap='hard' name='des' rows=3 cols=60 COLOR='#FFFFFF' readonly='yes' MAXLENGTH=9999>".$row['description']."</TEXTAREA>";
					echo "</td><td align='center'>"; 	

					if(empty($row['screen1']))
						{ echo "<font color='#FFFFFF'>No Screenshot submitted</font>"; }
					else
						{ echo "<A HREF=".$row['screen1']."><font color='#0099FF'>Screenshot1</font></A>"; }

					echo "</td><td align='center'>";  

					if(empty($row['screen2']))
						{ echo "<font color='#FFFFFF'>No Screenshot submitted</font>"; }
					else 	   	  
						{ echo "<A HREF=".$row['screen2']."><font color='#0099FF'>Screenshot2</font></A>"; }

					echo "</td><td align='center'>";
					if(empty($row['screen3']))
						{ echo "<font color='#FFFFFF'>No Screenshot submitted</font>"; }
					else  
						{ echo "<A HREF=".$row['screen3']."><font color='#0099FF'>Screenshot3</A>"; }

					echo "</td><td align='center'>";
					echo "<form method='POST' action='bugs_main.php'> <input type='text' value='Your name' name='editor'></form>";
					echo "<form method='POST' action='bugs_main.php'> <input type='submit' value='Fixed!' name='fixed'><br /></form>";
					echo "<form method='POST' action='bugs_main.php'> <input type='submit' value='Working on' name='work'></form>";
					echo "</td></tr>";
				} 
			echo "</TABLE>";
		}
}
elseif($_POST['password'] != "password")
{
	header("Location: redirect.php")
}
  

   ?></font></center></body></html>

 

Just off topic, textarea doesn't have a maxlength attribute ;o)

Link to comment
Share on other sites

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.