Skip to content

Instantly share code, notes, and snippets.

View NitishDiwakar's full-sized avatar
🏝️
Software Developer | Writer | Nature Lover

Nitish Kumar Diwakar NitishDiwakar

🏝️
Software Developer | Writer | Nature Lover
View GitHub Profile
@NitishDiwakar
NitishDiwakar / hello.c
Created May 28, 2017 06:56
Hello World! in C
#include <stdio.h>
int main()
{
printf("Hello World!\n");
return 0;
}
@NitishDiwakar
NitishDiwakar / add.c
Created May 28, 2017 07:09
Addition in C
#include<stdio.h>
int main()
{
// declare three variables.
int a = 0, b = 0, sum = 0;
printf("Please enter a number: \n" );
// read first variable
scanf("%d", &a);
printf("Please enter second number: \n" );
// read second variable
@NitishDiwakar
NitishDiwakar / calculator.cpp
Created May 28, 2017 07:26
A command line calculator in C++
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
//-------defining variables and initializing them-------------
double num1, num2;
char operation, redo;
@NitishDiwakar
NitishDiwakar / login.php
Last active June 25, 2017 09:54
Register and login in php & mysqli using oop
<?php
session_start();
?>
<!DOCTYPE html>
<html>
<head>
<title>Login</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
@NitishDiwakar
NitishDiwakar / registration.php
Last active June 25, 2017 19:17
Register and login with php & mysqli using oop
<?php session_start(); ?>
<!DOCTYPE html>
<html>
<head>
<title>Registration</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="text/javascript">
@NitishDiwakar
NitishDiwakar / home.php
Last active June 25, 2017 09:52
Register and login with php & mysqli using oop
<?php
session_start();
include 'include/class.user.php';
$user = new User();
$uid = $_SESSION['uid'];
if (!$user->get_session()){
header("location:login.php");
exit();
}
@NitishDiwakar
NitishDiwakar / register.php
Last active June 24, 2017 16:48
Register and login with php & mysqli using oop
<?php
// filename: include/register.php
session_start();
//n
include 'class.user.php';
$user = new User(); // Checking for user logged in or not
if (isset($_REQUEST['register'])){
extract($_REQUEST);
$register = $user->reg_user($fullname, $uname,$upass, $uemail);
@NitishDiwakar
NitishDiwakar / login.php
Created June 24, 2017 16:47
Register and login with php & mysqli using oop
<?php
// filename: include/login.php
session_start();
include 'class.user.php';
if (isset($_REQUEST['login'])) {
$user = new User();
extract($_REQUEST);
$login = $user->check_login($emailusername, $password);
if ($login) {
// Registration Success
@NitishDiwakar
NitishDiwakar / connection.php
Created June 24, 2017 16:49
Register and login with php & mysqli using oop
<?php
// filename include/connection.php
define('DB_SERVER', 'localhost');
define('DB_USERNAME', 'root');
define('DB_PASSWORD', '');
define('DB_DATABASE', 'oop');
function db () {
static $conn;
if ($conn===NULL){
@NitishDiwakar
NitishDiwakar / class.user.php
Last active June 25, 2017 05:42
Register and login with php & mysqli using oop
<?php
// filename: include/class.user.php
include 'connection.php';
class User{
public $db;
/*** for registration process ***/
public function reg_user($name,$username,$password,$email){
$conn = db();