Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>0807_Login_Validation</title>
- </head>
- <body style="font-family: Arial, Helvetica, sans-serif; color: Blue; background-color:">
- <form id="myform" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" >
- <h2 style="background-color: #F5DEB3;">Login Validation</h2>
- <?php
- //*****************************************************
- //*
- //* Get Userid and password
- //*
- //*****************************************************
- if (isset($_POST['userid']))
- {
- $userid = $_POST['userid'];
- } else {
- $userid = '';
- }
- if (isset($_POST['password']))
- {
- $password = $_POST['password'];
- } else {
- $password = '';
- }
- if (isset($_POST['userid']))
- {
- echo "<input type='hidden' name='userid' size='11' value='".$userid."' /><br />";
- echo "<input type='hidden' name='password' size='11' value='".$password."' /><br />";
- } else {
- echo "<h2> Enter valid user/Password to Login: </h2>";
- echo "<table> ";
- echo "<tr> ";
- echo "<td>User ID</td><td><input type ='text' name='userid' size='11' /><br /> ";
- echo "</tr>";
- echo "<tr> ";
- echo "<td>Password</td><td><input type='text' name='password' size='11' value='".$password."' /><br />";
- echo "</tr> ";
- echo "</table> ";
- echo "<p><input type='submit' name='mysubmit' value='Login' /> ";
- echo "</form></body></html>";
- exit;
- }
- //********************************************************
- //*
- //* Connect to MYSQL and Database
- //**
- //********************************************************
- $db = mysqli_connect('localhost','root','', 'working');
- if (!$db)
- {
- echo "<h1>Unable to Connect to MYSQL</h1>";
- }
- //*****************************************************
- //*
- //* SELECT from table and display results
- //*
- //*****************************************************
- $sql_statement = "SELECT userid ";
- $sql_statement .= "FROM validusers ";
- $sql_statement .= "WHERE userid = '".$userid."' ";
- $sql_statement .= "AND password = '".$password."' ";
- $result = mysqli_query($db, $sql_statement);
- $outputDisplay = "";
- $myrowcount = 0;
- if (!$result) {
- $outputDisplay .= "<p style='color: red;'>MySQL' NO: ".mysqli_errno($db)."<br>";
- $outputDisplay .= "MySQL Error: ".mysqli_error($db)."<br>";
- $outputDisplay .= "<br>SQL: ".$sql_statement."<br>";
- } else {
- $numresults = mysqli_num_rows($result);
- if ($numresults == 0)
- {
- $outputDisplay .= "Invalid Login <br /> ";
- $outputDisplay .= "Please go BACK and try again ";
- } else {
- $outputDisplay .= doShowList($db);
- }
- }
- ?>
- <h2 size="4" style="background-color: #F5DEB3; color: #F5DEB3;" />
- <?php
- echo $outputDisplay;
- ?>
- </form>
- </body>
- </html>
- <?php
- function doShowList($db)
- {
- $sql_statement = "SELECT Microphone_Audio_Kits, Microphone_Equip_Condition, Camera_Kits, Camera_Equip_Condition, Lighting_Kits, Lighting_Equp_Condition, Monitors_TriPods_Extras, Monitors_TriPods_Extras_Condition ";
- $sql_statement .="FROM equipment ";
- $sql_statement .= "ORDER BY Microphone_Audio_Kits ";
- $result = mysqli_query($db, $sql_statement);
- $outputDisplay = "";
- $myrowcount = 0;
- if (!$result) {
- $outputDisplay .= "<p style='color: red;'>MySQL' NO: ".mysqli_errno($db)."<br>";
- $outputDisplay .= "MySQL Error: ".mysqli_error($db)."<br>";
- $outputDisplay .= "<br>SQL: ".$sql_statement."<br>";
- } else {
- $outputDisplay = "<h3>cameras</h3>\n";
- $outputDisplay .= '<table border=1 style="color: black;">';
- $outputDisplay .= '<tr><th>Microphone_Audio_Kits</th><th>Microphone_Equip_Condition</th><th>Camera_Kits</th><th>Camera_Equip_Condition</th><th>Lighting_Kits</th><th>Lighting_Equp_Condition</th><th>Monitors_TriPods_Extras</th><th>Monitors_TriPods_Extras_Condition</th></tr>' ."\n";
- $numresults = mysqli_num_rows($result);
- for ($i = 0; $i < $numresults; $i++)
- {
- if (!($i % 2) == 0)
- {
- $outputDisplay .= "<tr style=\"background-color: #F5DEB3;\">";
- } else {
- $outputDisplay .= "<tr style=\"background-color:\">";
- }
- $row = mysqli_fetch_array($result);
- $Microphone_Audio_Kits = $row['Microphone_Audio_Kits'];
- $Microphone_Equip_Condition = $row['Microphone_Equip_Condition'];
- $Camera_Kits = $row['Camera_Kits'];
- $Camera_Equip_Condition = $row['Camera_Equip_Condition'];
- $Lighting_Kits = $row['Lighting_Kits'];
- $Lighting_Equp_Condition = $row['Lighting_Equp_Condition'];
- $Monitors_TriPods_Extras = $row['Monitors_TriPods_Extras'];
- $Monitors_TriPods_Extras_Condition = $row['Monitors_TriPods_Extras_Condition'];
- $outputDisplay .= "<td>".$Microphone_Audio_Kits."</td>";
- $outputDisplay .= "<td>".$Microphone_Equip_Condition."</td>";
- $outputDisplay .= "<td>".$Camera_Kits."</td>";
- $outputDisplay .= "<td>".$Camera_Equip_Condition."</td>";
- $outputDisplay .= "<td>".$Lighting_Kits."</td>";
- $outputDisplay .= "<td>".$Lighting_Equp_Condition."</td>";
- $outputDisplay .= "<td>".$Monitors_TriPods_Extras."</td>";
- $outputDisplay .= "<td>".$Monitors_TriPods_Extras_Condition."</td>";
- }
- $outputDisplay .="</table>\n";
- }
- return $outputDisplay;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement