New to our community ?

Discover a world of possibilities! Join us and explore a vibrant community where ideas flourish and connections thrive.

One of Our Valued Members

Thank you for being part of our community. Your presence enriches our shared experiences. Let's continue this journey together!

Home Blog Page 12

User registration using ajax , Jquery and php

0

welcome back to shortlearner.com, in this post we will see how to create a signup or registration page with the help of AJAX, PHP and MySQL.
Before start this tutorial we should know a little bit about AJAX.
so basically it stands for Asynchronous JavaScript and XML .

signup using ajax php

A user can continue to use the application while the client program requests information from the server in the background.

so first we create a database with the name of task, and also create a database table with the name of emp_details. in this table we take employees personal details like employee name, email, password and mobile number as well.

CREATE TABLE `emp_details` (
  `id` int(11) NOT NULL auto_increment,
  `emp_name` varchar(222) default NULL,
  `email` varchar(222) default NULL,
  `mobile` varchar(22) default NULL,
  `password` varchar(22) default NULL,
  `status` int(10) default '1',
  `user_type` varchar(222) default NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ;


After creating database we need to establish a connection between our PHP code and MySQL database. so we create a config.php page and make a database connection inside it.
config.php

Also Read :
PHP Login Script With Remember me.
Change password using javascript, php and mysqli.
Password and Confirm Password Validation Using JavaScript
Check Email is Already Registered in Database using Ajax and JavaScript.
How to hide extension of html and php file.?

<?php 
$conn = mysqli_connect("localhost","root","root","task");
?>

Now we design a responsive signup form with the help of bootstrap, html and css.
index.php

<!DOCTYPE html>
<html>
<head>
	<title></title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"><!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<link rel="stylesheet" href="style.css">
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
</head>
<body>
	<div class="container login-container">
	    <div class="row">
<div class="col-md-6 login-form-2">
	        	<h3>User Registration</h3>
	        	<hr>
		        <form method="post" onsubmit="return do_signup();">
		        	<div class="col-md-6">
		        	 	<div class="form-group">
		                	<input type="text" class="form-control" name="emp_name" id="emp_name" placeholder="Employee Name*" required="required" />
		                   	</div>
		    	 	</div>
		    	 	<div class="col-md-6">
		    	 		<div class="form-group">
		            	    <input type="number" onKeyDown="if(this.value.length==15 && event.keyCode!=8) return false;" class="form-control" name="emp_mobile" id="emp_mobile" placeholder="Your Mobile No *" required="required" />
		            	</div>
		    	 	</div>

		            <div class="col-md-6">
		            	<div class="form-group">
		            	    <input type="email" class="form-control" name="emp_email" id="emp_email" placeholder="Your Email *" required="required" />
		            	</div>
		            </div>
		            <div class="col-md-6">
						<div class="form-group">
		                	<input type="password" name="emp_pass" id="emp_pass" class="form-control" placeholder="Your Password *" value="" />
		            	</div>
		            </div>
		            
		            <div class="form-group">
		                <input type="submit" class="btnSubmit" value="Login" />
		            </div>
		            <div class="form-group">

		                <a href="#" class="ForgetPwd" value="Login">Forget Password?</a>
		            </div>
		        </form>
	    	</div>
	    </div>
	</div>

</body>
</html>

and put the css file in style.css

.login-container{
    margin-top: 5%;
    margin-bottom: 5%;
}
.login-form-1{
    padding: 5%;
    box-shadow: 0 5px 8px 0 rgba(0, 0, 0, 0.2), 0 9px 26px 0 rgba(0, 0, 0, 0.19);
}
.login-form-1 h3{
    text-align: center;
    color: #333;
}
.login-form-2{
    padding: 5%;
    background: #0062cc;
    box-shadow: 0 5px 8px 0 rgba(0, 0, 0, 0.2), 0 9px 26px 0 rgba(0, 0, 0, 0.19);
}
.login-form-2 h3{
    text-align: center;
    color: #fff;
}
.login-container form{
    padding: 10%;
}
.btnSubmit
{
    width: 50%;
    border-radius: 1rem;
    padding: 1.5%;
    border: none;
    cursor: pointer;
}
.login-form-1 .btnSubmit{
    font-weight: 600;
    color: #fff;
    background-color: #0062cc;
}
.login-form-2 .btnSubmit{
    font-weight: 600;
    color: #0062cc;
    background-color: #fff;
}
.login-form-2 .ForgetPwd{
    color: #fff;
    font-weight: 600;
    text-decoration: none;
}
.login-form-1 .ForgetPwd{
    color: #0062cc;
    font-weight: 600;
    text-decoration: none;
}

on form submit we call a JQuery function do_signup, which takes all the values of input fields on the behalf of their ids itself, than we send all the data to our do_login.php page using action tag.

<script>
function do_signup()
	{
var name=$("#emp_name").val();
	 var password=$("#emp_pass").val();
	 var email=$("#emp_email").val();
	 var mobile=$("#emp_mobile").val();
	 if(email!="" && name!="" && mobile!="" && password!="")
	 {
	  
	  $.ajax
	  ({
	  type:'post',
	  url:'do_login.php',
	  data:{
	   action:'signup',
	   name:name,
	   email:email,
	   mobile:mobile,
	   password:password
	  },
	  success:function(response) {
	  if(response=="success")
	  {
alert('Employee Successfully Signed Up.!');
	    window.location.href="index.php";
	  }
	  else
	  {
alert("Wrong Details");
	  }
	  }
	  });
	 }
else
	 {
	  alert("Please Fill All The Details");
	 }

	 return false;
	}
	</script>

now create our last do_login.php page which will help us to insert all the user details into our database without refreshing the current page.
do_login.php

if ($_POST['action']=='signup') 
{
	require('config.php');
	$email =  filter_var($_POST['email'], FILTER_SANITIZE_EMAIL);
	$password = filter_var($_POST['password']);
	$name =  filter_var($_POST['name']);
	$mobile = filter_var($_POST['mobile'], FILTER_SANITIZE_NUMBER_INT);

	$ins = $conn->query("INSERT INTO emp_details(`emp_name`,`email`,`mobile`,`password`,`user_type`) VALUES('$name','$email','$mobile','$password','emp')");
	if($ins){
		echo "success";
	}
}

if we received success in the response than we show an alert pop up of employee successfully registered.

return all dates between two dates in php.

0

welcome back to shortlearner.com . In this post we will see how to find dates between two selected dates using php .
most of the time we need to fetch all the dates between two dates to show our data on the behalf of dates and days. so before start this tutorial ,we need to understand the script flow . first of all we makes two php variable which indicates two dates like $date_from and $date_to .

fetch all dates between two dates in php

Also Read :
PHP Login Script With Remember me.
Change password using javascript, php and mysqli.
Password and Confirm Password Validation Using JavaScript
Check Email is Already Registered in Database using Ajax and JavaScript.
How to hide extension of html and php file.?

find dates between two dates in php

after defining variables we needs to convert our dates into unix timestamps. so doing this process php provides us a pre-defined function strtotime,

which helps to convert English text date time strings into UNIX timestamps . after converts dates string to unix timestamp we run a for loop from $date_from to less than equal to our $date_to variable.

there are many methods to Return all dates between two dates in an array in PHP

<?php
$date_from = "2020-01-12";
$date_from= strtotime($date_from);
$date_to ="2020-01-18";
$date_to =strtotime($date_to);
for($i=$date_from; $i<=$date_to;$i==86400)
{ 
echo date("Y-m-d",$i).'<br>';
}

Save the above script in your htdocs directory if you are using XAMPP server.

Launch Bootstrap Modal on page load

0

Welcome back to shortlearner.com, today we will see how to Launch Bootstrap Modal on page load using JavaScript. so in the very first step we will create a index.html file than we will write our JavaScript code which are helps to show our Bootstrap modal on loading of index.html file.

on page load show modal

In the index.html file we will call the bootstrap.min.js and bootstrap.min.css to load bootstrap files in our web page.

index.html

<!DOCTYPE html>
<html>
<head>
	<title></title>
</head>
<body>

<!-- A Bootstrap Modal -->
<div id="myModal" class="modal fade">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title">Subscribe our Newsletter</h4>
            </div>
            <div class="modal-body">
                <p>Subscribe to our mailing list to get the latest updates straight in your inbox.</p>
                <form>
                    <div class="form-group">
                        <input type="text" class="form-control" placeholder="Name">
                    </div>
                    <div class="form-group">
                        <input type="email" class="form-control" placeholder="Email Address">
                    </div>
                    <button type="submit" class="btn btn-primary">Subscribe</button>
                </form>
            </div>
        </div>
    </div>
</div>
</body>
</html>

Add the below bootstrap maxcdn files in the head section of index.html

Also Read :
PHP Login Script With Remember me.
Change password using javascript, php and mysqli.
Password and Confirm Password Validation Using JavaScript
Check Email is Already Registered in Database using Ajax and JavaScript.
How to hide extension of html and php file.?

<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">

<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>

now we write down our JavaScript code to launch bootstrap modal on the loading of index.html web page. so put the below JavaScript code on the body section of the index file.

<script type="text/javascript">
    $(document).ready(function(){
        $("#myModal").modal('show');
    });
</script>

on the above JavaScript code we called the modal id and change its behavior from fade to show.

just go to the browser and run your index.html file, the bootstrap modal will automatically launch on page load.

Also Read

Check Email is already registered in database with the help PHP, AJAX And JQuery

Upload multiple images using PHP and MySQL.

0

Welcome back to shortlearner.com . Today we will see how to upload more than 5 images in database with the help of php and mysql.

multiple image upload using php

so before start this tutorial let me clear the over all scenario of this post.we will create three PHP page here ,
in the very first step we establish our database connection .

in the second step we design a responsive form for uploading images and in the very last step
we will start to write code for uploading images in a specific folder and stores image name inside the database table.

upload multiple images using php

connection.php

In this first step we write a code which are use for establishing a database connection.
we have our test_db database.
and the username and password are same root.

<?php 
$db_con= mysqli_connect("localhost","root","root","test_db");
?>

index.php

in this page we are design a html form which will use to take images from local system .

<!DOCTYPE html>
<html>
<head>
	<title></title>
</head>
<body>
<form action="upload.php" method="post" enctype="multipart/form-data">
    <table width="100%">
        <tr>
            <td>Select Photo (one or multiple):</td>
            <td><input type="file" name="files[]" multiple/></td>
        </tr>
        <tr>
            <td colspan="2" align="center">Note: Supported image format: .jpeg, .jpg, .png, .gif</td>
        </tr>
        <tr>
            <td colspan="2" align="center"><input type="submit" value="Create Gallery" id="selectedButton"/></td>
        </tr>
    </table>
</form>
</body>
</html>

In the upload.php page we will fetch images from local system and check the extensions of all images and store inside the storage folder.

upload.php

<?php extract($_POST);
$error=array();
$extension=array("jpeg","jpg","png","gif");
foreach($_FILES["files"]["tmp_name"] as $key=>$tmp_name) {
    $file_name=$_FILES["files"]["name"][$key];
    $file_tmp=$_FILES["files"]["tmp_name"][$key];
    $ext=pathinfo($file_name,PATHINFO_EXTENSION);

    if(in_array($ext,$extension)) {
        if(!file_exists("storage/".$txtGalleryName."/".$file_name)) {
            move_uploaded_file($file_tmp=$_FILES["files"]["tmp_name"][$key],"photo_gallery/".$txtGalleryName."/".$file_name);
        }
        else {
            $filename=basename($file_name,$ext);
            $newFileName=$filename.time().".".$ext;
            move_uploaded_file($file_tmp=$_FILES["files"]["tmp_name"][$key],"photo_gallery/".$txtGalleryName."/".$newFileName);
        }
    }
    else {
        array_push($error,"$file_name, ");
    }
} 
?>

Read More: Date calculatio

A Step by Step Guide for Placement Preparation

0

कैं पस प्लेसमेंट का सीजन आते ही फाइनल

ईयर केज्यादातर छात्र प्लेसमेंट इटरव्यं ूसे

बहतु तनाव मेंहोतेहैं.हालाककं येस्वाभाकवक

है लेककनआपको इसेकनयत्रणं मेंकरना आना

चाकहए.ऐसी कस्िकत में आपको अपनाबेस्ट

करने पर ध्यान देना चाकहए |

दरअसल इस दौरान उनके कदमाग में कई

सवाल दौड़ रहेहोतेहैंजैसेकौन सी कंपनी

दरअसल यही एक मौका होता हैजब स्टूडेंट को कॉलेजसेआसानी सेजॉब कमल जाता हैनही तो एक बार कॉलेज

सेपासआउट हो गयेतो जॉब ढूढनेंकेकलए काफी मशक्कत करनी पड़ती है।अगर आप भी चाहतेहैकक कैं पस

प्लेसमेंटकेदौरान ही आपको जॉब कमल जाए तो आपको इसकेकलए सही तैयारीकरना जूरी है।

क्योकक इटरव्यं ूकेशआती तीन कमनट सामनेवालेकेकदलोकदमाग मेंआपकेप्रकत फस्टटइम्प्प्रेशन तैयार करनेकेकलए काफी होतेहैं.इस छोटेसेवक्त मेंइटरव्यं ूलेनेवाला येकाफी हद तक तय कर लेता है कक आप जॉब के कलए कफट हैं या नहीं.इसकलए शआती तीन कमनट मेंआप अच्छा बोलें, बॉडी लेंग्वेज पॉकजकटव रखें, आई-कॉन्टेक्ट बनाए रखें, सेन्टेंस और आइकडयाज को बेहतर ढगं सेशेयर करें.

आज मैंआपको कैं पसप्लेसमेंटक्रैककरनेकेकुछ कटप्स देनेजा रहा हु, कजनकी मदद सेआप अपनी मनपसदं कंपनी मेंनौकरी हाकसल करनेमेंकामयाब रहेंगे|

1 रिज्यूमे:

ककसी भी नौकरी को हाकसल करनेकी सबसेपहली सीढी होती है|दरअसल आपका ररज्यमेूही आपकेबारेमें सबकुछ कहता हैइसकलए इटरव्यं ूमेंजानेसेपहलेररज्यमेूको अच्छेसेचेककरलेंकी इसमेंकोई समस्या तो नही है।एक ररक्रूटर सबसेपहलेरेज्यमेूदेखता हैकफर सवाल करता है.रेज्यमेूआपका इप्रेशनं बना भी सकती हैऔर कबगाड़ भी सकती है.इसकलए इटरव्यं ूमेंजानेसेपहलेया रेज्यमेूभेजनेसेपहलेउसेअच्छी तरह सेजाचं लेंऔर समय-समय पर अपडेट करतेरहें |

2- ड्रेसकोड

रेज्यमेूकेबाद जो आपका इप्रेशनं बनानेमेंमदद करती हैवो हैआपका ड्रेस कोड | सही ड्रेसपहनेंफॉमटलकपड़े पहनकर ही इटरव्यं ूमेंजाए.ंतड़क-भड़क वालेकपड़ेन पहनें.

3- एप्टीट्यूड टेस्टकी प्रैनटटसकिें:

आमतौर पर ककसी भी नौकरी केकलए एप्टीट्यडू टेस्टदेनाहोता है,कजसेपास करनेकेबाद इटरव्ंय ूक्वाकलफाई करना होता हैऔर तब कहीं जाकर कमलती हैनौकरी. ककसी भी कंपनी केइटरव्यं ूदेनेकेकलए पहला राउंड ररटेनटेस्टहोता है. इस राउंड मेंएप्टीटुड एडं रेकिकनगं और सब्जेक्टसेररलेटेडमल्टीप्ल चॉइस प्रश्न पछतेूहै| तो ककसी भी कंपनी के इटरव्यं ूराउंड तक पहचनेुंसेपहलेयेराउंड सेगजरनाु पड़ेगा| यही राउंड प्रमखु होता है| इसकेकलए आप को कनरंतर प्रयाश करना पड़ेगाक्योकक एक कदन मेंपढ केआप इस टेस्टको कक्लयर नहीं कर सकतेहै| इसकेकलए आप डेली एक घटां प्रैकक्टसकरे|

4 – ग्रपु नडस्कशि की प्रैनटटसकिें:

कई बार स्टूडेंट्स का सेलेक्शन सीधा इटरव्यं ूपर होता हैलेककन कभी- कभी स्टूडेंट्स को ग्रपु कडस्कशन भी फेस करना पड़ता है.अगर आपको ग्रपु कडस्कशन सेघबराहट होती हैतो अपनेदोस्तों केसाि कमलकर इसकी प्रैकक्टस करें. कोई भी एक टॉकपक उठा लेंऔर उसपर अपनेदोस्तों केसाि प्रैकक्टस करें.इससेन कसफटआपकी घबराहट दरू होगी बकल्क आत्मकवश्वास बढेगा.

5 – सब्जेटटकी जािकािी िखें:

अक्सर ररक्रूटर आपकेफील्ड सेसवाल करतेहैंक्योंकक वेदेखना चाहतेहैंकक आपको अपने कवषय की जानकारी है

या नहीं. ऐसेमेंअगर आपको अपनेसब्जेक्ट मेंककसी भी टॉकपक को लेकर कुछ कंफ्यजनू हैतो उसकेबारेमेंअच्छी

तरह सेपढ लें.खदु का कॉन्सेप्ट क्लीयर रहेगा तभी सामनेवालेको समझा पाएगें

अगर ककसी प्वाइटं पर आपकेऔर इटरव्यंवरू केबीच मतभेद होतेहैंतो आपको दृढता केसाि अपनेप्वाइटं पर कटके रहना चाकहए.लेककन आप कजद्दी ना रहें.या तो इस छोड़ देंऔर आगेबढ जाए ंया कफर कह देंकक ‘हो सकता हैकक मैं गलत ह,ंमैंएक बार सेचेक कूंगा।’ आपका मकसद जॉब पाना है, सामनेवालेको गलत साकबत करना नहीं.

6- जॉब प्रोफाइल केबािेमेंपता िखें:

कैंपस प्लेसमेंट मेंजानेसेपहलेइस बात का खास ख्याल रखेंकक आप कौन सी कंपनी केककस जॉब प्रोफाइल के कलए जा रहे हैंक्योंकक. इटरव्यं ूकेदौरान आपसेआपकी जॉब प्रोफाइल केबारेमेंही सवाल पछाू जाएगा। कजस कंपनी

के प्लेसमेंट में भाग लेने जा रहे हैं उसके बारे में ज्यादा से ज्यादा जानकारी होनी चाकहए. इससे न कसफट आपकी पॉकजकटव ईमेज बनेगी बकल्क नौकरी के प्रकत आपकी ुकच कदखेगी.

7 सीनियि सेबात किें:

कॉलेज के कैं पस प्लेसमेंट में सीकनयर का रोल भी अहमकैं पसप्लेसमेंटहोताहै.केजूरी कटप्स आपको अपने सीकनयर केअलावा कोई और नही देसकता है,इसकलए अपनेसीकनयरों केटच मेंरहे,और कैं पसप्लेसमेंटकोलेकर उनसेजाननेकी कोकशश करेंकक उनकेसमय कौन-कौन सी कंकपनयांआई िी, और उन्होनेइटरव्यं ूको कै सेफे सककया िा।

8 कॉनफफडेंटिहें:

कैंपस प्लेसमेंट अकधकाशं छात्रों का लाइफ का पहला जॉब इटरव्यं ूहोता है.जाकहर हैसभी नवसटहोंगे.लेककन आप आत्मकवश्वास को बनाए रखें.बात को सनतेु-कहतेवक्त इटरव्यं ूलेनेवालेसेआई-कॉन्टेक्ट होना जूरी है. ओवरकॉकन्फडेंट ना रहेंऔर तनाब पर काब ूपाए.ं

9 तिाव में िा िहे:

ज्यादातर छात्र प्लेसमेंट इटरव्यं ूसेबहतु तनाव मेंहोतेहैं.हालांकक येस्वाभाकवक हैलेककन आपको इसेकनयत्रणं में करना आना चाकहए.ऐसी कस्िकत में आपको अपना बेस्ट करनेध्यानपर देना चाकहए| कभी भी आप निराश मह्ससू करतेहो तो माता नपता सेबात करेकेनिनिए वो हमेशाआप को अच्छा और सच्चा मार्गनििाएर्ें, क्योनक वो तम्हेुबचपि सेजाितेहै|

  1. सोशल मीनडया पि अपडेट िहे:

आज केदौर मेंसोशल मीकडया भी ककसी कंपनी मेंप्लेसमेंट पानेमेंअहम ्भकमकाू कनभा रही हैतो आप सोशल मीकडया पर भी एकक्टव रह सकतेहै.. जैसेकी फेसबकु , कलक्डं इन .

अगर आप को ककसी कंपनी केकसलेक्शन प्रोसेस पछनाू हैया कफर ररटेन टेस्ट पैटनटपछनाू है| तो आज का हिारो ऐसे फेसबकु ग्रपु हैजो जॉब सीकर की काफी मदद करते है | आप उनके ज्वाइन कररये और आप के जो भी प्रश्न है आप डायरेक्ट बहा पछू सकतेहै| यहााँतक की आप को बहा कैंपस ड्राइव सेररलेटेड इनफामेशन कमल सकती है| जैसेकी कलक्डं इन पर सभी कंपकनयों केएम्प्प्लोयी का अकाउंट रहता है| तो आप डायरेक्टली आप उनसेकनेक्ट हो सकते है और आप केजो भी प्रश्न हैआप उनसेपछू सकतेहै|

प्लेसमेंटडेस्क:हरिओम िाजपतू (ओम )