<html>
<head>
<title>Week #5 ADVANCED ~ Lestat</title>
<link rel="stylesheet" type="text/css" href="/css/scriptskewl.css">
</head>

<body>
<? /*Write a script to submit a username and password to enter a 
page. 

If the username and password does not match the variable 
hardcoded in the script show the login form again with an error 
message. The password field should be private so that as you 
type you'll see ****. 

Upon correct login display a list of banners in an array from 
a select box to display (you can use either a single or 
multi-dimensional array). Upon choosing a banner and 
pressing submit, then have the script print the banner to the browser. 

This will allow for an account of banners that only a person with the 
correct username/password can get in and view by image path. 

Use either a for() or while() loop to create the dropdown SELECT box 
with the available banners in the array and hidden form tags to 
transfer the validated password. This should all be one self-contained 
script with NO include() or require() files.*/
?>


<?

// Hard code password
$password "pass";
$username "user";

// Image path
$image_path 'gifs';

// Set banner Array
$banner = array("1gif","2gif","3gif","4gif","5gif","6gif","7gif");

// Code to accept and display selected banner
if($_POST['choice'] == "true"){
    print(
" Here is the banner you chose: <br><br>");
             
             
/* Compare the selected name to the array to get the selected image
                **I Don't like this part, Theres gotta be a better way */
              
if($_POST['banner_list'] == '0'){print("<img src=\"$image_path/1.gif\" height=50 width=50>&nbsp; $banner[0]");}
              if(
$_POST['banner_list'] == '1'){print("<img src=\"$image_path/2.gif\" height=50 width=50>&nbsp; $banner[1]");}
              if(
$_POST['banner_list'] == '2'){print("<img src=\"$image_path/3.gif\" height=50 width=50>&nbsp; $banner[2]");}
              if(
$_POST['banner_list'] == '3'){print("<img src=\"$image_path/4.gif\" height=50 width=50>&nbsp; $banner[3]");}
              if(
$_POST['banner_list'] == '4'){print("<img src=\"$image_path/5.gif\" height=50 width=50>&nbsp; $banner[4]");}
              if(
$_POST['banner_list'] == '5'){print("<img src=\"$image_path/6.gif\" height=50 width=50>&nbsp; $banner[5]");}
              if(
$_POST['banner_list'] == '6'){print("<img src=\"$image_path/7.gif\" height=50 width=50>&nbsp; $banner[6]");}

    print(
"
    <br><br><a href='../index.html'>BACK</a><br><br>
    <iframe src='wk5advsrc.php' width='850' height='300'></iframe>
    </body></html>
    "
);
    exit;
    }

// Code to run when submit is clicked
if($_POST['action'] == "true"){

   if(
$password == $_POST['pass_entry'] & $username == $_POST['name_entry']){
       print(
"Thank you for entering the correct password<br><br>"); // If password matches
       
print("Please select a banner");

   
// Start new form
      
print("
             <form method = \"post\" action = \"wk5adv.php\">
             <input type = \"hidden\" name = \"choice\"  value = \"true\">
             <select name= \"banner_list\">
             "
);

    
// Loop to create select box
         
for($i 0$i7$i++){
         print(
"
                <option value = \"$i\" name = \"banner_list_fill\"> $banner[$i]</option>
                "
);
          }

    
// close up the form
    
Print("
           </select>
           <input type = \"submit\" value = \"submit\">
           </form>
           <a href='../index.html'>BACK</a><br><br>
          <iframe src='wk5advsrc.php' width='850' height='300'></iframe>
           </body></html>
           "
);
exit;}
else{
    print(
"<strong><font color='red'>Sorry, Either Your Username or Password is Incorrect<br>Please try again</font></strong>"); // If password doesnt match entry
        
}
}
?>

<form method="POST" action="wk5adv.php">
<input type="hidden" name="action" value="true">
Please Enter Your Username:
<input type="text"  name="name_entry"><br>
Please Enter Your Password: 
<input type="password"  name="pass_entry"><br>
<input type="submit" value="Try Your Luck">
</form>




<pre>
</pre>
<br>
<iframe src='wk5advsrc.php' width='850' height='300'></iframe>
<br>

<a href='../index.html'>BACK</a>

</body>
</html>