Monday, December 16, 2019

search code

<h1>SEARCH PAGE</h1>
<div class="container">
<div class="card-body">
<table id="example2" class="table table-bordered table-hover">
<thead>
              <tr>
                <th>profile Image</th>
                <!-- <th>first name</th> -->
                <th>first name</th>
                <th>last name</th>
                <th>username</th>
                <th>email</th>
              </tr>
            </thead>

            <tbody>
<?php
//connecting to database
$dbserver = "localhost";
$dbusername = "root";
$dbpassword = "";
$dbname = "login";
$conn = mysqli_connect($dbserver, $dbusername, $dbpassword, $dbname);
//fetching search results from database
if (isset($_POST['submit-search'])) {
$search = mysqli_real_escape_string($conn, $_POST['search']);
$sql = "SELECT * FROM users WHERE  image LIKE '%$search%' OR fname LIKE '%$search%' OR lname LIKE '%$search%' OR username LIKE '%$search%' OR email LIKE '%$search%'";
$result = mysqli_query($conn, $sql);
     $queryResult = mysqli_num_rows($result);

     echo "There are ".$queryResult."results!";
                  if ($queryResult > 0) {
                  while ($row = mysqli_fetch_assoc($result)) {
                 
                  //displaying search results on the search page
                 
echo "<tr>
                   
                      <td><img src='images/".$row['image']."' height='200px' width='200px'> </td>
                      <td>".$row['fname']. "</td>
                      <td>".$row['lname']. "</td>
                      <td>".$row['username']. "</td>
                      <td>".$row['email']. "</td>
                      </tr>";                 
                       }

                    }
                                     
                    else {
                    echo "there are no result matching your search";
                    }


}
 ?>
</tbody>
</table>
</div>
  </div>

Friday, December 13, 2019

php mailer

<?php
   $to_email = "recipient@example.com";
   $subject = "Simple Email Test via PHP";
   $body = "Hi,nn This is test email send by PHP Script";
   $headers = "From: sender@example.com";

   if ( mail($to_email, $subject, $body, $headers)) {
      echo("Email successfully sent to $to_email...");
   } else {
      echo("Email sending failed...");
   }
?>

creating regestration form using html


<!DOCTYPE html>
<html>
<head>
  <title>Registration</title>
  <meta charset="utf-8">
  <link rel="stylesheet" type="text/css" href="css/bootstrap.css">
  <link rel="stylesheet" type="text/css" href="css/bootstrap-theme.css">
  <link rel="stylesheet" type="text/css" href="style.css">


</head>
<body>
  <div class="header">
  <h2>Register</h2>
  </div>

  <form >
 
    <div>
    <input type="file" name="image">
    </div>
    <div>
      <label>First name</label>
      <input type="text" name="fname" >
    </div>
    <div>
      <label>Last name</label>
      <input type="text" name="lname">
    </div>
  <div>
    <label>Username</label>
    <input type="text" name="username" >
  </div>
  <div class="form-group">
    <label>Email</label>
    <input type="email" name="email"  >
  <div >
    <label>Password</label>
    <input type="password" name="password" >
  </div>
  <div>
    <label>Confirm password</label>
    <input type="password" name="password_2">
  </div>
  <div>
    <button type="submit"  name="reg">Register</button>
  </div>
  <p>
  Already a member? <button class="btn btn-primary"><a href="login.php">Sign in</a></button>
  </p>
  </form>
</body>
</html>

creating a login form using html

<!DOCTYPE html>
<html>
<head>
  <title>login</title>
</head>
<body>
  <div class="header">
  <h2>Login</h2>
  </div>


  <form>
      <label>Email</label>
      <input type="text" name="email" >
    </div>
  <label>Password</label>
  <input type="password" name="password">
  </div>
  <div >
  <button type="submit" name="login_user">Login</button>
  </div>
 
  </form>
</body>
</html>

php udate results code

CREATE A FILE NAME IT update.php <?php session_start(); // Include config file require_once "config.php"; // Define ...