All In One Insert OOP
<?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>
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>
3 comments: