New Trending Topics and Study Material

Breaking

Tag

Tricks & Tips (17) News (5) PHP (5) Android (3) SEO (1) free paytm cash (1)
Showing posts with label PHP. Show all posts
Showing posts with label PHP. Show all posts

Monday, 5 March 2018

21:09

How to Animate HTML Elements Using jQuery On Button Click | 2018 | PHP Tutorial |





Syntax : 

$(selector).hide(speed,callback);



<!DOCTYPE html>
<html>
    <head>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
        <script>
            $(document).ready(function () {
                $("#hide").click(function () {
                    $("#my").hide(1000);
                });
            });
        </script>
    </head>
    <body>
        <div id="my">Click On The Hide Button Start Animation ...</div>
        <br>
        <button id="hide">Hide</button>
    </body>
</html>





--------------------------------------------------------------------------------------------


Check This Top searching Topics

20:43

How to hide & show html elements using jQuery | 2018 | PHP Tutorial |


jQuery hide() and show()



hide and show Image |  jQuery Image
jQuery 1




Here is the raw HTML code for the demo:


<!DOCTYPE html>
<html>
    <head>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
        <script>
            $(document).ready(function () {
                $("#hide").click(function () {
                    $("p").hide();
                });
                $("#show").click(function () {
                    $("p").show();
                });
            });
        </script>
    </head>
    <body>

        <p>Click on the Hide & Show Button...</p>

        <button id="hide">Hide</button>
        <button id="show">Show</button>

    </body>

</html>







--------------------------------------------------------------------------------------------


Check This Top searching Topics

Monday, 26 February 2018

23:18

How to create Session in PHP and use of session | vrsavani 2018


First, create one PHP page paste this code in this file



<div class="jumbotron bg-white text-center text-white">
 <div class="container bg-danger" >
  <form action="SessionDemo.php" method="post">
   <br>
   <hr class="bg-light">
   <h2 > Enter Session Value </h2>
   <hr class="bg-light">
   <div class="form-group">
    <input type="text" name="name" class="form-control" placeholder="Enter Session Value..." >
   </div>
   <input type="submit" value="Save Session" name="Save"  class="btn btn-success btn-block"/>
   <input type="submit" value="Show Session" name="show"  class="btn btn-warning btn-block"/>
   <input type="submit" value="Destroyed Session" name="del"  class="btn btn-light btn-block"/>
   <br><br>
  </form>
 </div>
</div> 
        
  
  






Design 1

Session in php | vrsavani blog | use of session



1) Start a PHP Session

A session is started with the session_start() function.
Session variables are set with the PHP global variable: $_SESSION.

$_SESSION["Session Name"] = "Value"; 

in this tutorial ,I set session like this


if (isset($_POST['Save'])) {
 if (!empty($_POST['name'])) {
  $a = $_POST['name'];
  // Set session variables
  $_SESSION["demo"] = $a;
  echo "<h3 class='alert alert-success alert-dismissable fade show text-center'>Session variables are set.</h3><br><br>";
 } else {
 //if session is not set ...
  echo "<h3 class='alert alert-danger alert-dismissable fade show text-center'>Session variables are Not set.</h3><br><br>";
 }
} 



If User Click One Save Button So that time Session is created and set the values of the session.....


Design 2


error in session | vrsavani | session variables are not set
2.1





session variables are set | vrsavani | session img
2.2



2) Get PHP Session Variable Values

Also notice that all session variable values are stored in the global $_SESSION variable:

if (isset($_POST['show'])) {
 // Show session variables
 echo "<h3 class='alert alert-success alert-dismissable fade show text-center'>Your 
        Session variables =  " . $_SESSION["demo"] . "</h3><br><br>";
} 



Design 3

show session variables | vrsavani | savani blog

3) Destroy a PHP Session: 

To remove all global session variables and destroy the session, use session_unset() and session_destroy():

if (isset($_POST['del'])) {
 // destroy  the session 
 session_destroy();
 echo "<h3 class='alert alert-success alert-dismissable fade show text-center'>All 
        session variables are now removed, and the session is destroyed.</h3><br><br>";
} 



Design 4


removed session | destroyed session | vrsavani blog | PHP




Download Source File With Designing...

vrsavani blog | download tutorial






Sunday, 25 February 2018

01:59

Add Dynamic Textbox Using PHP jQuery

In this tutorial helps to add Textbox dynamically using jQuery and PHP. When user click on add button New textbox will add.

::::: Demo :::::






1) Add This Link on Your PHP File

Css / Script #

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">

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

        <!-- Popper JS -->
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
        
		
		





2) Html Design


Note : Add bootstrap file for perfect design....
<div class="container">
	<h2>Add Dynamic Textbox</h2>
        <button type="submit" class="btn btn-primary" onclick="addTextBox();">Add <i class="fa fa-plus-square"></i></button>
		<br><br>
        <div id="newBox">
			<div class="form-group">
				<input type="text" class="form-control" placeholder="Dynamic Text Box..." name="txt_1">
            </div>
        </div>
</div>			




3) Write some script for add new textbox :

<script>
	var id = 2, txt_box;
            function addTextBox() {       
                txt_box = '<div class="form-group"><input type="text" name="txt_' + id + '" placeholder="Dynamic Text Box ' + id + '..." class="form-control"/></div>';
                $("#newBox").append(txt_box);
                id++;
            }
</script>        
		
		





Thursday, 22 February 2018

23:13

PHP Prepared Statements

Note : Prepared statements are very useful against SQL injections.


A prepared statement is a feature used to execute the same (or similar) SQL statements repeatedly with high efficiency.


MySQLi supports the use of anonymous positional placeholder (?), as shown below:

" INSERT INTO counselor(name) VALUES(?) "

Information About Code

Attempt MySQL server connection. Assuming you are running MySQL server with default setting (user 'root' with no password)
Host Name : localhost
Database Name : test
TextBox Name : txtname
Submit Button Name : Save



PHP Code Example #

<?php
if (isset($_GET['Save'])){
if (!empty($_GET['txtname'])) {$n = $_GET['txtname'];
// MySQL server connection.
$c = new mysqli("localhost", "root", "", "test");
// Prepare an insert statement
$q = $c->prepare("insert into counselor(name) values(?)");
// Bind variables to the prepared statement as parameters
 $->bind_param("s", $n);
// Attempt to execute the prepared statement
$q->execute();
//Data Notification 
echo "<br><br>
<div class='container'>
   <div class='alert alert-success alert-dismissable fade show' >
      <button type='button' class='close' data-dismiss='alert'>&times;</button>
      <strong>Data</strong> Enter Successfully...
   </div>
 </div>";
 } else {
//Error Notification 
echo "<br><br>
<div class='container'>
  <div class='alert alert-danger alert-dismissable fade show' >
      <button type='button' class='close' data-dismiss='alert'>&times;</button>
      <strong>Error!</strong> In Data Entry.....
   </div>
</div>";
}
}
?>
                

Html Code Example #

<div class="jumbotron bg-dark text-white">
    <br><br>
    <h1 class="text-center">Prepare Statement</h1>
<br>
<div class="container">
<form method="get" action="#">
<div class="form-group">
<h4>Enter Name </h4>
<input type="text" name="txtname" class="form-control"/>
</div>
<input type="submit" value="Save" name="Save"  class="btn btn-primary btn-block"/>
</form>
</div>
</div>
   


             

Css / Script #

Note : Script Use For Show Notification....
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">

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

<!-- Popper JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>

<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" ></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js"></script>

<style>
    input[type=text] {
    width: 100%;
    padding: 12px 20px;
    margin: 8px 0;
    box-sizing: border-box;
    border: 3px solid #ccc;
    -webkit-transition: 0.5s;
    transition: 0.5s;
    outline: none;
    }

    input[type=text]:focus {
    border: 3px solid #555;
    transition: 1s;
    }
</style>
<script>

window.setTimeout(function () {
    $(".alert").fadeTo(500, 0).slideUp(500, function () {
        $(this).remove();
    });
}, 3000);

</script>




Layout #


Download PHP file