Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- include ("connection.php");
- echo "<form method='post'>";
- echo "Search For User: <input type='text' name='searchString' />";
- echo "<input type='submit' name='search' value='search' />";
- if(isset($_POST['search']))
- {
- if(strlen($_REQUEST['searchString']))
- {
- $sql="SELECT * FROM login WHERE username LIKE '%".$_REQUEST['searchString']."%'";
- $result=$conn->query($sql);
- echo "<table border=1><tr><th>id</th><th>username</th><th>password</th><th>image</th><th>date</th><th>comments</th></tr>";
- while($test = $result->fetch_assoc())
- {
- echo "<tr align='center'><td>".$test['id']."</td><td>".$test['username']."</td><td>".$test['password']."</td>";
- echo "<td><img src=".$test['imagepath']." style='width:50px; height:50px;' /></td><td>".$test['date']."</td><td>".$test['comment']."</td><td><input type='checkbox' name='deletecb[]' value=".$test['id']." /></td></tr>";
- }
- echo "<tr><td><input type='submit' name='edit' value='edit' /></td><td><input type='submit' name='search' value='search' /></td><td><input type='submit' name='delete' value='delete' /></td></tr>";
- echo "</table>";
- }
- }
- if(isset($_POST['edit']))
- {
- header("Location:edit.php");
- exit();
- }
- echo "</form>";
- ?>
- <?PHP
- include ("connection.php");
- $sql="SELECT * FROM login";
- $result=$conn->query($sql);
- if($result->num_rows>0)
- {
- echo "<form method='post' enctype='multipart/form-data'>";
- echo "<table border=1><tr><th>id</th><th>username</th><th>password</th><th>image</th><th>date</th><th>comments</th></tr>";
- while($test = $result->fetch_assoc())
- {
- echo $test['comment'];
- echo "<tr align='center'><td><input type='hidden' name='id[]' value=" . $test['id'] . " />" . $test['id'] . "</td><td><input type='text' name='username[]' value=" . $test['username'] . " /></td><td><input type='text' name='password[]' value=" . $test['password'] . " /></td><td><img src=".$test['imagepath']." style='width:50px; height:50px;' /><input type='hidden' name='imagepath[]' value=" . $test['imagepath'] . " /><br><input type='file' name='fileToUpload[]' accept='image/*' /></td><td><input type='date' name='date[]' value=" . $test['date'] . " /></td><td><input type='text' name='comment[]' value='".$test['comment']."' /></td></tr>";
- }
- echo "<tr><td></td><td><input type='submit' name='done' value='done' /></td></tr>";
- echo "</table> </form>";
- }
- if(isset($_POST['done']))
- {
- print_r($_POST);
- echo "<br><br>";
- echo "following values are updates:<br>";
- $target_dir = "images/";
- for ($i = 0; $i < count($_POST['id']); $i++)
- {
- //$_FILES['fileToUpload']['name'][$i] will get just image name
- if(strlen($_FILES['fileToUpload']['name'][$i]))
- {
- $target_file = $target_dir . basename($_FILES['fileToUpload']['name'][$i]);
- }
- else
- {
- $target_file = $_POST['imagepath'][$i];
- }
- //to upload images
- move_uploaded_file($_FILES['fileToUpload']['tmp_name'][$i], $target_file);
- echo $_POST['id'][$i]." ".$_POST['username'][$i]." ".$_POST['password'][$i]." ".$_FILES['fileToUpload']['name'][$i];
- echo $id;
- echo "<br>";
- $id=$_REQUEST['id'][$i];
- $username=$_REQUEST['username'][$i];
- $password=$_REQUEST['password'][$i];
- $date=$_REQUEST['date'][$i];
- $comment=$_REQUEST['comment'][$i];
- echo "<br>";
- $sql="UPDATE login SET username='". $username. "',password='". $password ."',imagepath='". $target_file ."',date='". $date ."',comment='". $comment ."' WHERE id=". $id;
- //$sql="UPDATE login SET username='briano',password='briano' WHERE id='7'";
- $conn->query($sql);
- }
- //header("Refresh:0");
- header("Location:display.php");
- /* foreach( $_POST as $stuff ) {
- if( is_array( $stuff ) ) {
- foreach( $stuff as $thing ) {
- echo "<br>";
- echo $thing;
- }
- } else {
- echo "<br>";
- echo $stuff;
- }
- }
- */
- }
- echo "</form>";
- ?>
- <?php
- include('config.php');
- session_start();
- $user_check = $_SESSION['login_user'];
- $ses_sql = mysqli_query($db,"select username from admin where username = '$user_check' ");
- $row = mysqli_fetch_array($ses_sql,MYSQLI_ASSOC);
- $login_session = $row['username'];
- if(!isset($_SESSION['login_user'])){
- header("location:login.php");
- }
- ?>
- <?php
- include('connection.php');
- session_start();
- ?>
- <html">
- <head>
- <title>Welcome </title>
- </head>
- <body>
- <h1>Welcome <?php echo $_SESSION['login_user']; ?></h1>
- <h2><a href = "logout.php">Sign Out</a></h2>
- </body>
- </html>
- <?PHP
- $host="localhost";
- $username="root";
- $password="";
- $dbname="company";
- $conn=new mysqli($host, $username, $password, $dbname);
- if($conn->connect_error)
- {
- die("connection error" . $conn->connect_error);
- }
- ?>
- <html>
- <table border="1">
- <tr>
- <th>id</th>
- <th>username</th>
- <th>password</th>
- <th>image</th>
- <th>date</th>
- <th>comments</th>
- </tr>
- <?PHP
- include ("connection.php");
- $sql="SELECT * FROM login ORDER BY date";
- $result=$conn->query($sql);
- if($result->num_rows>0)
- {
- echo "<form method='post'>";
- while($test = $result->fetch_assoc())
- {
- ?>
- <tr>
- <td><?php echo $test['id']; ?></td>
- <td><?php echo $test['username']; ?></td>
- <td><?php echo $test['password']; ?></td>
- <td><img src="<?php echo $test['imagepath']; ?>" style='width:50px; height:50px;' /></td>
- <td><?php echo $test['date']; ?></td>
- <td><?php echo $test['comment']; ?></td>
- <td><input type='checkbox' name='deletecb[]' value="<?php echo $test['id']; ?>" /></td>
- </tr>
- <?php } ?>
- <tr>
- <td> <input type='submit' name='edit' value='edit' /> </td>
- <td> <input type='submit' name='search' value='search' /> </td>
- <td> <input type='submit' name='delete' value='delete' /> </td>
- </tr>
- </form>
- </table>
- <?php } ?>
- </html>
- <?PHP
- include ("connection.php");
- $sql="SELECT * FROM login ORDER BY date";
- $result=$conn->query($sql);
- if($result->num_rows>0)
- {
- echo "<form method='post'>";
- echo "<table border=1><tr><th>id</th><th>username</th><th>password</th><th>image</th><th>date</th><th>comments</th></tr>";
- while($test = $result->fetch_assoc())
- {
- echo "<tr align='center'><td>".$test['id']."</td><td>".$test['username']."</td><td>".$test['password']."</td>";
- echo "<td><img src=".$test['imagepath']." style='width:50px; height:50px;' /></td><td>".$test['date']."</td><td>".$test['comment']."</td><td><input type='checkbox' name='deletecb[]' value=".$test['id']." /></td></tr>";
- }
- echo "<tr><td><input type='submit' name='edit' value='edit' /></td><td><input type='submit' name='search' value='search' /></td><td><input type='submit' name='delete' value='delete' /></td></tr>";
- echo "</table>";
- }
- if(isset($_POST['search']))
- {
- echo "coming";
- header("Location:search.php");
- exit();
- }
- if(isset($_POST['delete']))
- {
- $deleteCb=$_REQUEST['deletecb'];
- for($i=0;$i<count($deleteCb);$i++)
- {
- $id=$deleteCb[$i];
- $sql="DELETE FROM login WHERE id=".$id;
- $conn->query($sql);
- }
- header("Refresh:0");
- }
- if(isset($_POST['edit']))
- {
- header("Location:edit.php");
- exit();
- }
- echo "</form>";
- ?>
- <html>
- <head>
- </head>
- <body>
- <form method="post">
- username: <input type="user" name="user">
- password: <input type="pass" name="pass">
- <input type="submit" name="add" value="add">
- <?PHP
- if(isset($_POST['add']))
- {
- //store form variables
- $user=$_POST['user'];
- $pass=$_POST['pass'];
- //make connection
- include("connection.php");
- //insert query
- $sql="INSERT INTO login(username,password) VALUES ('$user','$pass')";
- $conn->query($sql);
- }
- include("display.php");
- ?>
- </form>
- </body>
- </html>
- <html>
- <head>
- <title>Login Page</title>
- <style type = "text/css">
- body {
- font-family:Arial, Helvetica, sans-serif;
- font-size:14px;
- }
- label {
- font-weight:bold;
- width:100px;
- font-size:14px;
- }
- .box {
- border:#666666 solid 1px;
- }
- </style>
- </head>
- <body bgcolor = "#FFFFFF">
- <div align = "center">
- <div style = "width:300px; border: solid 1px #333333; " align = "left">
- <div style = "background-color:#333333; color:#FFFFFF; padding:3px;"><b>Login</b></div>
- <div style = "margin:30px">
- <form method = "post">
- <label>UserName :</label><input type = "text" name = "username" class = "box"/><br /><br />
- <label>Password :</label><input type = "password" name = "password" class = "box" /><br/><br />
- <input type = "submit" value = " Submit "/><br />
- </form>
- <div style = "font-size:11px; color:#cc0000; margin-top:10px"><?php //echo $error; ?></div>
- </div>
- </div>
- </div>
- </body>
- </html>
- <?php
- include("connection2.php");
- session_start();
- if($_SERVER["REQUEST_METHOD"] == "POST") {
- // username and password sent from form
- $myusername = mysqli_real_escape_string($conn,$_POST['username']);
- $mypassword = mysqli_real_escape_string($conn,$_POST['password']);
- $sql = "SELECT id FROM login WHERE username = '".$myusername."' and password = '".$mypassword."'";
- $result = $conn->query($sql);
- $count = $result->num_rows;
- // If result matched $myusername and $mypassword, table row must be 1 row
- if($count == 1) {
- session_start();
- $_SESSION['login_user'] = $myusername;
- header("location: welcome.php");
- }else {
- $error = "Your Login Name or Password is invalid";
- }
- }
- ?>
- <?php
- session_start();
- if(session_destroy()) {
- header("Location: login.php");
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement