<?php
if ($_SERVER["REQUEST_METHOD"] == 'POST'){
$firstname = $_POST["firstname"];
$dbc = mysqli_connect('localhost','root','','mydatabase') or die ("connection Error");
$query = "insert into my_table(firstname) values('$firstname')";
$myArray = array();
if (mysqli_query($dbc, $query)){
$myArray["msg"] = "happened";
}else {
$myArray["msg"] = "notHappened". mysqli_error($dbc);
}
mysqli_close($dbc);
echo json_encode($myArray);
}
?>
Note: Use your own database name in place of mydatabase and table name where my_table is specified.
Sunday, November 22, 2015
Saturday, October 31, 2015
GIT Work Flow
- Create an account in GitHub. Login to GitHub and create a new repository, say "TestRepo".
- On your local computer, download Git.exe following the instructions at https://git-scm.com/downloads
- On your local computer, create a folder, say "TestRepo".
- Go to command prompt, change directory to TestRepo and C:\TestRepo>git init
- This above command creates a ".git" folder in TestRepo folder.
- Now create couple of files, test1.txt, test2.txt, in TestRepo folder.
- C:\TestRepo>git add . (Note: after git add, a period is there, don't forget that)
- The above command moves the files test1.txt, test2.txt to staging area.
- C:\TestRepo>git commit -m "committing test1, test2 files"
- The above command moves the files test1.txt, test2.txt to local repository.
- C:\TestRepo>git remote add origin <https clone URL from github>
- The above command connects to the github when you provide the correct username and password.
- C:\TestRepo>git push origin master
- The above command pushes your files from your local repository to github remote repository
- C:\TestRepo>git pull origin master
- The above command pulls the files from github remote repository to your local repository.
- Happy programming!!
Thursday, October 22, 2015
How to install packages in Sublime
- Open https://packagecontrol.io/installation and select the content under the tabs based on your Sublime (Sublime Text 2 or Sublime Text 3)
- Open your Sublime, press (Ctrl + `) in Windows.
- In the console (the console shows up as a single gray line at the bottom of the sublime), enter the copied text and hit enter.
- Sublime may ask you to restart Sublime couple of times, and please do so.
- Once the above steps are done, you are good to access and install any packages.
- Press Ctrl + Shift + P and type Install Package.
- Enter the name of a package that you want to install, for example...SublimeLinter, and select it.
- The plugin gets installed automatically.
- That's pretty much it!
Tuesday, April 21, 2015
Callback Function
Read more details about Callback Function from the following web site:
Couple of lines from the above site "A callback function, also known as a higher-order function, is a function that is passed to another function (let's call this other function "otherFunction") as a parameter, and the callback function is called (or executed) inside the otherFunction."
Read more...
http://javascriptissexy.com/understand-javascript-callback-functions-and-use-them/
Couple of lines from the above site "A callback function, also known as a higher-order function, is a function that is passed to another function (let's call this other function "otherFunction") as a parameter, and the callback function is called (or executed) inside the otherFunction."
Read more...
http://javascriptissexy.com/understand-javascript-callback-functions-and-use-them/
Promises
"Jo vaadaa kiya voo nibhana padegaa"
How people explain things in simple words so that many others can understand? I am really thankful to Sandeep Panda for explaining JavaScript Promises in simple English!
Couple of lines from this site "If you use the Promise API to make an asynchronous call to a remote web service you will create a Promise object which represents the data that will be returned by the web service in future...".
Read more...
http://www.sitepoint.com/overview-javascript-promises/
How people explain things in simple words so that many others can understand? I am really thankful to Sandeep Panda for explaining JavaScript Promises in simple English!
Couple of lines from this site "If you use the Promise API to make an asynchronous call to a remote web service you will create a Promise object which represents the data that will be returned by the web service in future...".
Read more...
http://www.sitepoint.com/overview-javascript-promises/
Sunday, April 5, 2015
module.exports in Node.js
Suppose you want to write a module, say a functions module and access it in another module, say main.js, how are you going to do it in Node.js?
Real simple!
Create two .js files under C:\nodetest folder: functions.js, main.js
functions.js
module.exports = { addNumbers : function() { var total = 0; for (var a = 0; a < arguments.length; a++){ total += parseInt(arguments[a]); } return total; }, findArea : function(r){ return 3.142 * r * r; } };
functions.js:
this.addNumbers = function() { var total = 0; for (var a = 0; a < arguments.length; a++){ total += parseInt(arguments[a]); } return total; }; this.findArea = function(r){ return 3.142 * r * r; };
main.js
var functions = require('./functions.js'); console.log(functions.addNumbers(1,2)); console.log(functions.findArea(2));
Run the main.js from command prompt!
C:\nodetest>node main
Reference:
http://www.sitepoint.com/understanding-module-exports-exports-node-js/
Real simple!
Create two .js files under C:\nodetest folder: functions.js, main.js
functions.js
module.exports = { addNumbers : function() { var total = 0; for (var a = 0; a < arguments.length; a++){ total += parseInt(arguments[a]); } return total; }, findArea : function(r){ return 3.142 * r * r; } };
or
this.addNumbers = function() { var total = 0; for (var a = 0; a < arguments.length; a++){ total += parseInt(arguments[a]); } return total; }; this.findArea = function(r){ return 3.142 * r * r; };
main.js
var functions = require('./functions.js'); console.log(functions.addNumbers(1,2)); console.log(functions.findArea(2));
Run the main.js from command prompt!
C:\nodetest>node main
Reference:
http://www.sitepoint.com/understanding-module-exports-exports-node-js/
Friday, February 20, 2015
Using NodeJS, express, and MongoDB
Using NodeJS, express, and MongoDB stack? The following web site gives an introduction about how to install and run a full stack using these technologies in easy steps. Cool!
http://cwbuecheler.com/web/tutorials/2013/node-express-mongo/
http://cwbuecheler.com/web/tutorials/2013/node-express-mongo/
Tuesday, January 27, 2015
Predefined JavaScript function methods: apply(), call()
I was searching online to find a way to explain JavaScript predefined function methods: apply() and call(). This site http://hangar.runway7.net/javascript/difference-call-apply explains in simple English. Thanks a bunch!
Monday, January 19, 2015
Sample Ajax using jQuery & PHP
I started searching for a simple example that covers "PHP, jQuery, Ajax" and I found this web site which is simple and awesome: http://brian.staruk.me/php/2013/sample-jquery-php-ajax-script/. Thanks to Brian Staurk!
Subscribe to:
Posts (Atom)