All In One Insert OOP

3 comments
<?php
ini_set('mysql.connect_timeout',300);
ini_set('default_socket_timeout',300);
?>

<?php

include_once("all.php");
$checkdata=new Databases();

$error='';
$save='';
if(isset($_POST['submit'])){

$fname=$_POST['fname'];
$username=$_POST['username'];
$password=$_POST['password'];
$email=$_POST['email'];

$query=$checkdata->checkun($username);

if($query > 0 ) { //check if there is already an entry for that username
$error = "Username is already taken , Use another Username !!";
}else{

$filetmp = $_FILES["file_img"]["tmp_name"];
$filename = $_FILES["file_img"]["name"];
$filetype = $_FILES["file_img"]["type"];
$file_size =$_FILES['file_img']['size'];
$tmp_ext = explode( '.', $filename );
$file_ext = strtolower( end( $tmp_ext ) );

$filepath = "flimg/".$filename;

$expensions= array("jpeg","jpg","png","JPEG","JPG","PNG");
     
      if(in_array($file_ext,$expensions)=== false){
         $errors="extension not allowed, please choose a JPEG or PNG file.";
      }
     
      if($file_size > 2097152){
         $errors='File size must be excately 2 MB';
      }
     
      if(empty($errors)==true){
         move_uploaded_file($filetmp,$filepath);
         echo "Success";
      }else{
         print_r($errors);
      }

$sql=$checkdata->imgreg($fname,$username,$password,$filename,$filepath,$filetype);

if (isset($_REQUEST['email']))  {

//Email information
$admin_email = "kistlakall@gmail.com";
$email = $_REQUEST['email'];
$subject = $_REQUEST['fname'];
$comment = $_REQUEST['username'];

//send email
mail($admin_email, "$subject", $comment, "From:" . $email);
}

$save = "".$_POST["fname"]." ".$_POST["username"]." , You Have Successfully Registed !! <br><br>
We will reply you as soon as possible to your email which you have filled in this form.<br><br>
Thank You !!<br><br>";

}
}
?>

<html>
<head>

<meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <meta name="description" content="">
    <meta name="author" content="">

    <!-- Bootstrap core CSS -->
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet">

<style>

@media (max-width: 767px) {

.col-md-6 .col-sm-3 .hero-feature
{
visibility:hidden;
}

}

</style>

</head>

<body>

<div class="container"> <!-- Start Of The Container Class -->

<div class="row"> <!-- Start Of The Row Class -->

<div class="col-md-6 col-sm-12"> <!-- Start Of Right The Col Class -->

<br>

<form action="AllInOneInsert.php" method="post" enctype="multipart/form-data">
<h4><span><?php echo $error; ?></span></h4> <br>
<h4><span><?php echo $save; ?></span></h4> <br>

<div class="form-group">
    <label>Name : *</label>
    <input type="text" class="form-control" name="fname" placeholder="Enter Your Name" required>
  </div>

  <div class="form-group">
    <label>Username : *</label>
    <input type="text" class="form-control" name="username" placeholder="Enter Your Userame" required>
  </div>
 
  <div class="form-group">
    <label>Password : *</label>
    <input type="password" class="form-control" name="password" placeholder="Enter Your Password" required>
  </div>
 
  <div class="form-group">
    <label>Email : *</label>
    <input type="email" class="form-control" name="email" placeholder="Enter Your Password" required>
  </div>
 
  <div class="form-group">
    <label>Upload Profile Picture :</label>
    <input type="file" class="form-control-file" name="file_img" aria-describedby="fileHelp">
    <small id="fileHelp" class="form-text text-muted">If U Want , U Can Skip Upload A Profile Picture</small>
  </div>
 
  <button type="submit" class="btn btn-primary" name="submit">Submit</button>
 
</form>
</div> <!-- End Of Right The Col Class -->

</div> <!-- End Of The Row Class -->

</div> <!-- End Of The Container Class -->

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"></script>

</body>
</html>

Read More »

Delete OOP

2 comments
<?php

include_once ('all.php');
$deletedata = new Databases;

if(isset($_GET['id']))
{
$id = $_GET['id'];


$up=$deletedata->del($id);

if($up)
{
echo "<meta http-equiv='refresh' content='0; url=select.php'>";
}
else
{
echo "Didnt Update";
}
}

?>

Read More »

Update OOP

0 comments
<?php

 include_once ('all.php');
 $updatedata = new Databases;

if(isset($_GET['id']))
{
$id = $_GET['id'];

if(isset($_POST['update']))
{
$name=$_POST['name'];
$username=$_POST['username'];
$password=$_POST['password'];

$up=$updatedata->update($id,$name,$username,$password);

if($up)
{
echo "<meta http-equiv='refresh' content='0; url=select.php'>";
}
else
{
echo "Didnt Update";
}
}

$vfurow=$updatedata->viewforup($id);

?>

<html>

<head>

</head>

<body>

<form action="" method="POST">
Name : <input type="text" name="name" value="<?php echo $vfurow['name'] ?>"> <br><br>
Username : <input type="text" name="username" value="<?php echo $vfurow['username'] ?>"> <br><br>
Password : <input type="text" name="password" value="<?php echo $vfurow['pw'] ?>"> <br><br>
<input type="submit" name="update" value="Update"> <br><br>
</form>

<?php
}
?>

</body>
</html>

Read More »

View / Select OOP

1 comments
<?php
include('Session.php');

include_once ('all.php');
$data = new Databases;
 
 ?>
 <!DOCTYPE html>
 <html>
      <head>
           <title>Webslesson Tutorial | Select or Fetch Data from Mysql Table using OOPS in PHP</title>
           <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
           <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
           <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
      </head>
      <body>
           <br /><br />
           <div class="container" style="width:700px;">

                <br />
                <div class="table-responsive">
                     <table class="table table-bordered">
                          <tr>
                               <td width="30%">ID</td>
                               <td width="50">Name</td>
                               <td width="10%">Username</td>
                               <td width="10%">Password</td>
                          </tr>
                          <?php
                          $post_data = $data->select('academic');
                          foreach($post_data as $row)
                          {
                          ?>
                          <tr>
                               <td><?php echo $row["id"]; ?></td>
                               <td><?php echo substr($row["name"], 0, 200); ?></td>
                               <td><?php echo substr($row["username"], 0, 200); ?></td>
                               <td><?php echo substr($row["pw"], 0, 200); ?></td>
                               <td><a href="update.php?id=<?php echo $row["id"]; ?>">Edit</a></td>
                               <td><a href="deloop.php?id=<?php echo $row["id"]; ?>">Delete</a></td>
                          </tr>
                          <?php
                          }
                          ?>
                     </table>
                </div>

<h3><a href="Logout.php"> Logout </a></h3>

           </div>
      </body>
 </html>

Read More »

Insert With Folder Img

0 comments
<?php

include_once("db.php");
$insertdata=new Databases();


if(isset($_POST['insert']))
{

    $name = $_POST['name'];
    $email = $_POST['email'];
    $num = $_POST['num'];
    $msg = $_POST['msg'];

$target_dir = "flimg/";
$target_file = $target_dir . basename($_FILES["fileName"]["name"]);
$uploadOk = 1;
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);

    $check = getimagesize($_FILES["fileName"]["tmp_name"]);
    if($check !== false) {
        echo "File is an image - " . $check["mime"] . ".";
        $uploadOk = 1;
    } else {
        echo "File is not an image.";
        $uploadOk = 0;
    }

// Check if file already exists
if (file_exists($target_file)) {
    echo "Sorry, file already exists.";
    $uploadOk = 0;
}
// Check file size
if ($_FILES["fileName"]["size"] > 500000) {
    echo "Sorry, your file is too large.";
    $uploadOk = 0;
}
// Allow certain file formats
if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
&& $imageFileType != "gif" && $imageFileType != "JPG" && $imageFileType != "PNG" && $imageFileType != "JPRG") {
    echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
    $uploadOk = 0;
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
    echo "Sorry, your file was not uploaded.";
// if everything is ok, try to upload file
} else {
    if (move_uploaded_file($_FILES["fileName"]["tmp_name"], $target_file)) {
        echo "The file ". basename( $_FILES["fileName"]["name"]). " has been uploaded.";
$sql=$insertdata->insert($name,$email,$num,$msg);
if (isset($_REQUEST['email']))  {

//Email information
$admin_email = "kistlakall@gmail.com";
$email = $_REQUEST['email'];
$subject = $_REQUEST['name'];
$comment = $_REQUEST['msg'];

//send email
mail($admin_email, "$subject", $comment, "From:" . $email);
}
    } else {
        echo "Sorry, there was an error uploading your Data and File.";
    }
  }
 
}

?>

<!DOCTYPE html>

<html>

    <head>

        <title> PHP INSERT DATA </title>

        <meta charset="UTF-8">

        <meta name="viewport" content="width=device-width, initial-scale=1.0">

    </head>

    <body>
        <form action="" method="post" enctype="multipart/form-data">

            Name <input type="text" name="name"><br><br>

            Email <input type="email" name="email"><br><br>

            Number <input type="text" name="num"><br><br>

            Message <input type="text" name="msg"><br><br>

            Upload <input type="file" name="fileName"><br><br>

            <input type="submit" name="insert" value="Add Data To Database">

        </form>

    </body>

</html>

Read More »

Insert OOP

1 comments
<?php

 include_once ('all.php');  
 $data = new Databases;
 $success_message = '';
 if(isset($_POST["submit"]))
 {
      $insert_data = array(
           'name'     =>     mysqli_real_escape_string($data->con, $_POST['name']),
           'username'          =>     mysqli_real_escape_string($data->con, $_POST['username']),
           'pw'          =>     mysqli_real_escape_string($data->con, $_POST['password'])
      );
      if($data->insert('academic', $insert_data))
      {
           $success_message = 'Post Inserted';
      }      
 }
 ?>
 <!DOCTYPE html>
 <html>
      <head>
           <title>Insert data into Table using OOPS in PHP</title>
           <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
           <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
           <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
      </head>
      <body>
           <br /><br />
           <div class="container" style="width:700px;">
                <form method="post">
                     <label>Name</label>
                     <input type="text" name="name" class="form-control" />
                     <br />
                     <label>Username</label>
                     <input type="text" name="username" class="form-control" />
                     <br />
<label>Password</label>
                     <input type="password" name="password" class="form-control" />
                     <br />
                     <input type="submit" name="submit" class="btn btn-info" value="Submit" />
                     <span class="text-success">
                     <?php
                     if(isset($success_message))
                     {
                          echo $success_message;
                     }
                     ?>
                     </span>
                </form>
           </div>
      </body>
 </html>

Read More »

Session OOP

0 comments
<?php

include_once ('all.php');
$sesdata = new Databases;

session_start();
$user_check=$_SESSION['login_user'];

$row=$sesdata->ses($user_check);

$login_session=$row['username'];
if(!isset($_SESSION['login_user']))
{
header('location: Login.php');
exit;
}

?>

Read More »

Tweet Now !!

Recommend us on Google!