Braveheartt Posted March 18, 2008 Share Posted March 18, 2008 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? Quote Link to comment Share on other sites More sharing options...
moon 111 Posted March 18, 2008 Share Posted March 18, 2008 We need the whole script to tell you that.... Quote Link to comment Share on other sites More sharing options...
Braveheartt Posted March 18, 2008 Author Share Posted March 18, 2008 Of course, sorry! 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> Quote Link to comment Share on other sites More sharing options...
conker87 Posted March 18, 2008 Share Posted March 18, 2008 Well, for a start you need curly brackets {} around your first and second if statements. Your redirect header code needs to be: header("Location: redirect.php") Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted March 18, 2008 Share Posted March 18, 2008 odds are your server is configed so if php errors it outputs an internal server error header error (500 I believe) instead of a php error. You will need to adjust your error reporting to do any true debugging Quote Link to comment Share on other sites More sharing options...
conker87 Posted March 18, 2008 Share Posted March 18, 2008 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) Quote Link to comment 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.