Articles by "PHP"

2019 4G LTE 4G VoLTE 5G 7th Pay Commission Aadhaar Actor Wallpapers Actress Wallpaper Adriana Lima AdSense Ahoi Ashtami Airtel Airtel DTH Akshay Kumar Alcatel Alexa Rank Amazon Android Android Pie Android Q Anna university Antivirus Anushka Sharma apna csc online Apple Apps Army Army App Asthma Asus Atal Seva mirchpur Athletics Auto Auto Insurance Avengers Axis Bank Backlinks Badhajmi Bajaj Bang Bang Reloaded Bank Battery Bhai Dooj Katha Bhakti Bharti Bhumi Pednekar Big Bazaar Big TV Bing BlackBerry Blogger BlogSpot Bluetooth BoB Bollywood Boot Boxing Breathlessness Browser BSEH Bsnl Budget Budhvar Business buy Cable TV Camera Car Car Loan Card Less ATM Cash CBSE Celebrity CEO Chandra Grahan Channels Chest Pain Chhath chrome Clean WhatsApp Cache Common Service Centres (CSC) Mirchpur Hisar Haryana - Front of Jyoti Sen Sec School Mirchpur Comparisons Computer Coolpad Corona COVID 19 COVID 19 HARYANA Credit Cricket Crime CSC Cylinder Dama Dard Deepika Padukone Defence Detel Dhanteras Diamond Crypto DigiLocker App DigiPay App Digital India App Digital Indian Gov Dish TV Diwali DNS setting Domain Donate Doogee DTH DTH Activation DTH Installation DTH Plans in India Dusshera E-seva Kender mirchpur Earn Money Education Electronics Email Entertinment Ex-serviceman Extensions Facebook FASTag Fatigue Festivals FlicKr Flipkart Foldable Smartphone Food Foursquare Funny Gadgets Galaxy Galaxy S8 Game Ganesh ganesh chaturthi Gas Problems Gastric Problem Gharelu Gionee Gmail God Google Google + Google Assistant Google Drive Google Duo Google Pixel Google Tez Google Voice Google+ Govardhan Puja GroupMe GST GTA Guide GuruSatsang Guruvar Hamraaz hamraaz app hamraaz app download hamraaz army hamraaz army app hamraaz army app download Hamraaz Army App version 6 Apk Happy New Year Hariyali Teej Hartalika Teej Harvard University Haryana haryana csc online HDFC Bank Headphones Health Heart Attack Heart Fail Heart Problems Heart Stroke Heena Sidhu Hello App Help Hernia Hindi History Hockey Holi Holi Katha Hollywood Home Loan Honor HostGator Hosting Hrithik Roshan HTC Huawei humraaz app iBall IBM ICICI Bank Idea Ilaj India india vs china indian army app Indigestion Infinix InFocus Information Infosys Instagram Insurance Intel Internet Intex Mobile iPad iPhone iPhone 8 IPL IRCTC iVoomi Jan Dhan Account Janmashtami Japanese Encephalitis Javascript JBL Jio Jio GigaFiber Jio Meet JioPOS JioRail JioSaavn Jokes Kamjori Karbonn Kareena Kapoor Kartik Purnima Karva Chauth Karwa Chauth Kasam Tere Pyaar Ki Katrina Kaif Kendall Jenner Keywords Kimbho Kodak Kumkum Bhagya Kushth Rog Landline Laptop Lava Lenovo Leprosy LET Lethargy LG Library of Congress Lifestyle Linkedin Lisa Haydon Livejournal Liver Cancer Loans LPG Gas mAadhaar Macbook Maha Shivratri Makar Sankranti Map Market Mary Kom Massachusetts Institute of Technology Meizu Messages Mi Micromax Microsoft Mobile Modi Mokshada Ekadashi Money Motorcycles Motorola Movie Muscle Pain Music Myspace Narendra Modi Narsingh Jayanti Nature Naukri Navratri Nemonia Netflix Network News Nexus Nia Sharma Nokia Notifications Nuskhe OBC Ocean Office Offrs Ola Cab OMG OnePlus Online Opera Oppo Oreo Android Orkut OS OxygenOS Padmavati PagalWorld Pain Pain Sensation Pakistan PAN PAN Card Panasonic Passwords Patanjali Pay Payment Paypal Paytm PC PDF Peeda Pendrive Pension Personal Loan Pet Me Gas PF Phone Photo PHP Pila Bukhar Pinterest Pixel Plan PNB Bank Pneumonia PNR Poco Poster PPC Pradhan Mantri Kisan Samman Nidhi Pradhanmantri Kisan Samman Nidhi Yojna Pradosh Pragya Jaiswal Prepaid Princeton University Printer Priyanka Chopra promote my youtube channel promote video on youtube cost promote youtube channel promote youtube channel free promote youtube video free PUBG Qualcomm Quora Quotes Race 3 Railway Rambha Tritiya Vrat RBI Realme Recruitment Redmi Relationship Religious Restore Results Review Rule Sai Dharam Tej Saina Nehwal Salman Khan Samsung Sanusha Satsang Video Sawan Somvar Vrat SBI Bank Script Sell SEO Serial Server Shabd Shahid Kapoor Shanivar Sharad Poornima Sharp Shiv Shopping Shreyasi Singh Shruti Haasan Signal Sim Smart Android TV Smartphones SMS Snapchat Social Software Somvar Sonakshi Sinha Sonam Kapoor Soney Songs Sony Xperia Space Speakers Specifications Sports Sql Stanford University State Bank of India Stickers Stomach Upset Story Sun Direct Sunny Leone Surabhi Sushant Singh Rajput Swadeshi Swas Rog Tata Sky Tax Tech Technology Tecno Telegram Telugu Thakan Tiger Shroff Tiger Zinda Hai Tips Tiredness Tollywood Tool Top Trending People Trading Trai TRAI Rules for cable TV Trailer Treatment Trends True Things Truecaller Tubelight Tulsi Vivah Tumblr Tv Twitter Typing Uber Umang App University of Oxford UP Board Upay Upchar Update USA USB Vacancies Valentines Day Verizon Vertu Viber Video Videocon d2h Videos Vijayadashami Viral Bukhar Viral Fever Virat Kohli Virgin Visas Vivo VLE Vodafone Voter Card VPN Vrat Katha Vrat Vidhi Wallpaper War Wayback Machine Weakness WhatsApp WhatsApp Cleaner WhatsApp Status WhatsApp stickers Wi-Fi WiFi Windows Windows 10 Wipro Wireless WordPress workstation WWE Xiaomi Xiaomi Mi 6 Yeh Hai Mohabbatein Yellow Fever Yo Yo Honey Singh Yoga yojna YotaPhone YouTube youtube promotion youtube promotion free ZTE अपच अस्थमा आलस्य इलाज उपचार उपाय उमंग ऐप कहानियाँ कुष्ठरोग कोरोना वायरस गुरुसत्संग घरेलू जन धन योजना जापानी इन्सेफेलाइटिस डिजिटल इंडिया डिजिटल इंडिया अप्प्स डिजिपे ऐप डिजीलॉकर ऐप थकान दमा दर्द निमोनिया नुस्ख़े पीड़ा पीतज्वर पीला बुखार पेट में गैस पैन कार्ड प्रधानमंत्री किसान सम्मान निधि बदहज़मी भक्ति मांसपेशियों में दर्द लीवर कैंसर वायरल बुखार वोटर कार्ड शब्द सच्ची बातें सत्संग वीडियो सरसों सीने में दर्द स्कीम स्वास रोग हर्निया
Showing posts with label PHP. Show all posts

June 21, 2017
This post about "Sending Mail using SMTP and PHP". Now you can send emails with SMTP authentication using this script. Every mail needed server authentication, So you have to buy mail server. It's very useful you can implement this on your web projects.

This tutorial contains three files.

- Index.php
- SMTPconfig.php // SMTP Server Cofiguration
- SMTPClass.php // SMTP Mail Sending Class

SMTPconfig.php
You have to change SMTP server details.
<?php
//Server Address
$SmtpServer="127.0.0.1";
$SmtpPort="25"; //default
$SmtpUser="username";
$SmtpPass="password";
?>

SMTPclass.php
SMTP mail sending class.
<?php
class SMTPClient
{

function SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, $SmtpPass, $from, $to, $subject, $body)
{

$this->SmtpServer = $SmtpServer;
$this->SmtpUser = base64_encode ($SmtpUser);
$this->SmtpPass = base64_encode ($SmtpPass);
$this->from = $from;
$this->to = $to;
$this->subject = $subject;
$this->body = $body;

if ($SmtpPort == "")
{
$this->PortSMTP = 25;
}
else
{
$this->PortSMTP = $SmtpPort;
}
}

function SendMail ()
{
if ($SMTPIN = fsockopen ($this->SmtpServer, $this->PortSMTP))
{
fputs ($SMTPIN, "EHLO ".$HTTP_HOST."\r\n");
$talk["hello"] = fgets ( $SMTPIN, 1024 );
fputs($SMTPIN, "auth login\r\n");
$talk["res"]=fgets($SMTPIN,1024);
fputs($SMTPIN, $this->SmtpUser."\r\n");
$talk["user"]=fgets($SMTPIN,1024);
fputs($SMTPIN, $this->SmtpPass."\r\n");
$talk["pass"]=fgets($SMTPIN,256);
fputs ($SMTPIN, "MAIL FROM: <".$this->from.">\r\n");
$talk["From"] = fgets ( $SMTPIN, 1024 );
fputs ($SMTPIN, "RCPT TO: <".$this->to.">\r\n");
$talk["To"] = fgets ($SMTPIN, 1024);
fputs($SMTPIN, "DATA\r\n");
$talk["data"]=fgets( $SMTPIN,1024 );
fputs($SMTPIN, "To: <".$this->to.">\r\nFrom: <".$this->from.">\r\nSubject:".$this->subject."\r\n\r\n\r\n".$this->body."\r\n.\r\n");
$talk["send"]=fgets($SMTPIN,256);
//CLOSE CONNECTION AND EXIT ...
fputs ($SMTPIN, "QUIT\r\n");
fclose($SMTPIN);
//
}
return $talk;
}
}
?>

index.php
<?php
include('SMTPconfig.php');
include('SMTPClass.php');
if($_SERVER["REQUEST_METHOD"] == "POST")
{
$to = $_POST['to'];
$from = $_POST['from'];
$subject = $_POST['sub'];
$body = $_POST['message'];
$SMTPMail = new SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, $SmtpPass, $from, $to, $subject, $body);
$SMTPChat = $SMTPMail->SendMail();
}
?>
<form method="post" action="">
To:<input type="text" name="to" />
From :<input type='text' name="from" />
Subject :<input type='text' name="sub" />
Message :<textarea name="message"></textarea>
<input type="submit" value=" Send " />
</form>

June 21, 2017
Are you looking for PHP login script, in this post I want to discuss how to create a simple PHP login with welcome page using MySQL database. This will explain you creating user tables, posting form values and storing and destroying the session values.

Database
MySQL admin table columns id, username, passcode.
CREATE TABLE admin
(
id INT PRIMARY KEY AUTO_INCREMENT,
username VARCHAR(30) UNIQUE,
passcode VARCHAR(30)
);

Config.php
Database configuration file.
<?php
define('DB_SERVER', 'localhost');
define('DB_USERNAME', 'username');
define('DB_PASSWORD', 'password');
define('DB_DATABASE', 'database');
$db = mysqli_connect(DB_SERVER,DB_USERNAME,DB_PASSWORD,DB_DATABASE);
?>

Login.php
Contains PHP and HTML code.
<?php
include("config.php");
session_start();
if($_SERVER["REQUEST_METHOD"] == "POST")
{
// username and password sent from Form
$myusername=mysqli_real_escape_string($db,$_POST['username']);
$mypassword=mysqli_real_escape_string($db,$_POST['password']);
$passwordSecure=md5($mypassword);
$sql="SELECT id FROM admin WHERE username='$myusername' and passcode='$passwordSecure'";
$result=mysqli_query($db,$sql);
$row=mysqli_fetch_array($result,MYSQLI_ASSOC);
$active=$row['active'];
$count=mysqli_num_rows($result);


// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1)
{
session_register("myusername");
$_SESSION['login_user']=$myusername;

header("location: welcome.php");
}
else
{
$error="Your Login Name or Password is invalid";
}
}
?>
<form action="" method="post">
<label>UserName :</label>
<input type="text" name="username"/><br />
<label>Password :</label>
<input type="password" name="password"/><br/>
<input type="submit" value=" Submit "/><br />
</form>

lock.php
Session verification. If no session value page redirect to login.php
<?php
include('config.php');
session_start();
$user_check=$_SESSION['login_user'];

$ses_sql=mysqli_query($db,"select username from admin where username='$user_check' ");

$row=mysqli_fetch_array($ses_sql,MYSQLI_ASSOC);

$login_session=$row['username'];

if(!isset($login_session))
{
header("Location: login.php");
}
?>


welcome.php

<?php
include('lock.php');
?>
<body>
<h1>Welcome <?php echo $login_session; ?></h1>
</body>

logout.php
SignOut Destroy the session value.
<?php
session_start();
if(session_destroy())
{
header("Location: login.php");
}
?>

June 21, 2017
I'm using this PHP function to redirect text URLs as Links with Regular Expression validation. Just five lines of code, It's very useful.

To_Link.php
Contains PHP Code $text value validating with Regular Expressions 
<?php
function To_Link($text)
{
$text = html_entity_decode($text);
$text = " ".$text;
$text = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_\+.~#?&//=]+)',
'<a href="\\1">\\1</a>', $text);
$text = eregi_replace('(((f|ht){1}tps://)[-a-zA-Z0-9@:%_\+.~#?&//=]+)',
'<a href="\\1">\\1</a>', $text);
$text = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_\+.~#?&//=]+)',
'\\1<a href="http://\\2">\\2</a>', $text);
$text = eregi_replace('([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})',
'<a href="mailto:\\1">\\1</a>', $text);
return $text;
}
?>


index.php
You have to include To_link.php. Using function To_Link('You Text and URL')
<?php
include('To_Link.php');

$text='jQuery and Ajax best 9lessons http://tinyurl.com/naottn';

echo To_Link($text);

?>

June 21, 2017
This is PHP function split_url_fuction() writter for twitter like application that i am developing, useful to split URL from the updated sentence(posted message), then URL changing like tinyurl and link to the resource.

This function is break up the URL from the sentence, if the URL string length greater than 30 words it's change like TinyURL. 

Step 1. You have to include the file split_url_function.php into the PHP file that will use the function.
include("split_url_function.php");

Now you have to pass the updated data:
<?php echo  split_url_function($message); ?>

Here $message is the value from a SQL query.( Table structure )

This is the code of split_url_funtion() PHP function:

<?php

include("tiny_url.php"); //tinyurl function
function split_url_function($update  
{
    //----URL Checking in Update.
    $http= substr_count($update,"http://");
    $www=substr_count($update,"www.");
    $htp=substr_count($update,"http//");

    if($http==1)
   {
         $str="http://";
         $h=1;
    }
    if($www==1)
   {
      $str="www.";
      $w=1;
    }
    if($h==1 && $w==1)
    {
       $str='http://www.'//--Both
    }
    if($htp==1)
    {
          $comb_str=$update; //--No url
     }
//--- explode the update 
$fa=explode($str,$update);
$cnt_fa=count($fa);
$se=explode(" ",$fa[1]);
$cnt_se=count($se);

for($i=1;$i<=$cnt_se;$i++)
{
     $sep.=$se[$i].' ';
}
     // Split URL 
      $split_url=$str.$se[0];
      if($split_url=='')
     {
         $final_update=$update;
      }
      else
    {
         // URL link sting lenght verfication
         if(strlen($split_url)>=30)
        {
             $tiny = tiny_url($split_url);
$final_update=$fa[0].'<a href="'.$tiny.'" target="_blank">'.$tiny.'</a>'.$sep;
echo $final_update;
         }
         else
        {
          // Combine all the explode parts
$final_update=$fa[0].'<a href="'.$split_url.'" target="_blank">'.$split_url.'</a>'.$sep;
echo $final_update;
         }
     }
}
?>

tiny_url.php Original reference http://davidwalsh.name/create-tiny-url-php
<?php
function tiny_url($url)
{
$ch = curl_init();
$timeout = 5;
curl_setopt($ch,CURLOPT_URL,'http://tinyurl.com/api-create.php?url='.$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
?>

June 21, 2017
In this post I want to explain how to insert encrypted password while registration and accessing the same with login time. I'm just storing encrypted user password in database. Demo username ='test' and password = 'test'

Database
MySQL admin table columns id, username, passcode.
CREATE TABLE admin
(
id INT PRIMARY KEY AUTO_INCREMENT,
username VARCHAR(50) UNIQUE,
passcode VARCHAR(50)
);

Encrypted Password
Here database table admin password:test encrypted and storing like this

registration.php
Contains PHP and HTML code. Just inserting form values into database table admin
<?php
include("db.php");
if($_SERVER["REQUEST_METHOD"] == "POST")
{
// username and password sent from Form
$username=mysqli_real_escape_string($db,$_POST['username']);
$password=mysqli_real_escape_string($db,$_POST['password']);
$password=md5($password); // Encrypted Password
$sql="Insert into admin(username,passcode) values('$username','$password');";
$result=mysqli_query($db,$sql);
echo "Registration Successfully";
}
?>
<form action="registration.php" method="post">
<label>UserName :</label>
<input type="text" name="username"/><br />


<label>Password :</label>
<input type="password" name="password"/><br/>
<input type="submit" value=" Registration "/><br />
</form>

login.php
Login Script accessing the encrypted password.
<?php
include("db.php");
session_start();
if($_SERVER["REQUEST_METHOD"] == "POST")
{
// username and password sent from Form
$username=mysqli_real_escape_string($db,$_POST['username']);
$password=mysqli_real_escape_string($db,$_POST['password']);
$password=md5($password); // Encrypted Password
$sql="SELECT id FROM admin WHERE username='$username' and passcode='$password'";
$result=mysqli_query($db,$sql);
$count=mysqli_num_rows($db,$result);

// If result matched $username and $password, table row must be 1 row
if($count==1)
{
header("location: welcome.php");
}
else
{
$error="Your Login Name or Password is invalid";
}
}
?>
<form action="login.php" method="post">
<label>UserName :</label>
<input type="text" name="username"/><br />
<label>Password :</label>
<input type="password" name="password"/><br/>
<input type="submit" value=" Login "/><br />
</form>

db.php
Database configuration file.
<?php
define('DB_SERVER', 'localhost');
define('DB_USERNAME', 'username');
define('DB_PASSWORD', 'password');
define('DB_DATABASE', 'database');
$db = mysqli_connect(DB_SERVER,DB_USERNAME,DB_PASSWORD,DB_DATABASE);
?>

Digitalindiagov.com

Satish Kumar

Contact Form

Name

Email *

Message *

Powered by Blogger.