SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    Patience... bronze trophy solidcodes's Avatar
    Join Date
    Jul 2006
    Location
    Philippines
    Posts
    911
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Server Error, basic PHP error?

    Hi guys I have a simple PHP page below are the codes,


    Code:
    <!DOCTYPE html>
    <head>
    	<title></title>
    </head>
    
    <body>
    	<?php
    		error_reporting(E_ALL);
    	
    		$username = "admin";
    		$password = "pass";
    	?>
    	
    
    	<?php
    		if(isset($_POST['sb'])) {
    			if($_POST['username'] == $username && $_POST['password'] == $password)
    			{
    				echo "Download here";
    				echo "<button>download</button>";
    			}
    		}
    		else
    		}
    	?>
    			<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
    			username : <input type="text" name="username"><br/>
    			password : <input type="password" name="password"><br/>
    					   <input type='submit' name='sb' id='sb' value='login'>
    			</form>
    	<?php
    		{
    	?>
    </body>		
    </html>
    The problem is the page keep saying "SERVER ERROR"
    I check the CPanel error_log and the error_log filename in the root folder.
    I can't see the error.

    Can you help me spot the not above.

    Thanks in advance.
    I Love coding...
    Don't click this link.

  2. #2
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    8,891
    Mentioned
    138 Post(s)
    Tagged
    2 Thread(s)
    The curly brace after the ELSE must be the other one. You have }, but it must be { (about half way down the code)
    Rémon - Hosting Advisor

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy

  3. #3
    Patience... bronze trophy solidcodes's Avatar
    Join Date
    Jul 2006
    Location
    Philippines
    Posts
    911
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    @ScallioXTX ;

    Thank you.
    I Love coding...
    Don't click this link.

  4. #4
    Barefoot on the Moon! silver trophy
    Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    4,516
    Mentioned
    51 Post(s)
    Tagged
    1 Thread(s)
    Not related to your problem, but a good tip: When you have PHP code blocks intermixed with HTML and spanning across multiple blocks, you can use an alternate syntax instead of braces.

    PHP Code:
    if($something==true):
       echo 
    "hello";
    else:
       echo 
    "goodbye";
    endif; 
    This sometimes helps keep track of when you open and close if, for, while, and foreach control structures, especially when they're nested a few levels deep.


    http://php.net/manual/en/control-str...ive-syntax.php
    Visit The Blog | Follow On Twitter
    301tool 1.1.5 - URL redirector & shortener (PHP/MySQL)
    Can be hosted on and utilize your own domain


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •