Skip to main content

Posts

How to Check the Ubuntu Version

How to Check the Ubuntu Version.         Command used : more /etc/issue      This will return something like this:      Output  : Ubuntu 14.04.5 LTS \n \l

Send Email via SMTP server using PHPMailer

Email sending is the most useful feature for web application. mail() function in PHP is used to send mail from PHP script.While sending email using mail() ,the mail will be sent from web server. Sometimes it may cause issues on sending an email and fails to deliver. With SMTP you can overcome this issue,when you send an email through SMTP server email will be sent through mail server  rather than web server.       The easiest way to send email in PHP with SMTP is to use PHPMailer library. PHPMailer provides an ability to send email via SMTP server in PHP. In this tutorial, you’ll show how you can send HTML email with SMTP in PHP using PHPMailer. Send Email via SMTP server: PHPMailer library: The script uses PHPMailer to send the email via SMTP server, so PHPMailer library needs to be included first. Include the PHPMailerAutoload.php file and create a new PHPMailer instance. <?php require ( "phpmailer/PHPMailerAutoload.php" ); $mail = new ...

POPULATE DROPDOWN MENU FROM MYSQL

Populate  drop down menu from MYSQL: 1 2 3 4 5 6 7 8 <select name="user"> <?php $sql = mysqli_query ( $connect , "SELECT name FROM users" ); while ( $row = $sql -> fetch_assoc () ) { echo '<option value = "' . $row [ 'name' ] . '">' . $row [ 'name' ] . "</option>" ; } ?> </select> Show a drop down selected value coming from database: 1 2 3 4 5 6 7 8 9 10 11 <select name="user"> <?php $name = $users [ 'name' ]; $sql = mysqli_query ( $connect , "SELECT name FROM users" ); while ( $row = $sql -> fetch_assoc () ) { $selected = ( $row [ 'name' ] == $name ) ? 'selected="selected"' : '' ; echo '<option value="' . $row [ 'name' ] . '" ' . $selected . '>' . $row [ 'name...

SIMPLE PAGINATION USING PHP AND BOOTSTRAP

Hello guys, today we will learn how to create a simple pagination using PHP and Bootstrap. What is pagination? If you have a form which allows the user to browse through the rows in a database table, what do you do if that table has hundreds or even thousands of rows? It would not be a good idea to show all those rows in a single form, instead you should split the database output into more manageable chunks or 'pages'. There are two things you must do: Decide on the maximum number of database rows that can be included in each page. You may hard code this value, or (my preferred method) you can define it in a variable so that the value may be changed at runtime. You then need to inform the user that other 'pages' are available and provide a mechanism whereby the user is able to select a different 'page' of details. This is nothing but pagination area.                                 This area tells the ...

MYSQL CONNECTION USING PDO WITH PHP

Hello guys, In the previous tutorial we have seen how to connect to MySQL database with PHP using MySQLi. Today we will learn how to connect with PDO. As a PHP programmer we have learned how to access database by using either MySQL and MySQLi. As of PHP 5.1, there's a better way. PHP Data Objects(PDO) provide methods for prepared statements and working with objects that will make you far more productive! PDO Introduction :        PDO provides a data-access abstraction layer, which means that, regardless of which database you're using, you use the same functions to issue queries and fetch data. PDO does not provide a database abstraction; it doesn't rewrite SQL or emulate missing features. Database Support:       The extension can support any database that a PDO driver has been written for. The following drivers currently implement the PDO interface: PDO_CUBRID Cubrid PDO_DBLIB FreeTDS / Microsoft SQL Server / Sybase PDO_FIREBIRD Firebird PDO_I...

MYSQL DATABASE CONNECTION WITH PHP

Hello friends, today we will learn how to connect to  MySQL  database with PHP. This tutorial will require a MySQL database and a web development environment using mysql, apache and php and a simple text editor. The tutorial takes you through establishing a  MySQL  connection using php on a web page, connecting to a  MySQL  table and retrieving the results and displaying them back on the web page. Earlier versions of PHP used the  MySQL  extension.However, this extension was depreciated in 2012. Later can work with  MySQL  database using MySQLi extension (the "i" stands for improved) PDO (PHP Data Objects)        The main difference between these two are if you want to switch your project to another database PDO makes it easy(since it can connect 12 different databases). You only have to change the connection string and a few queries. With MySQLi, you will need to rewrite the entire code - queries included.In this t...

PHP FROM COMMAND LINE

Hello guys, today we will learn how to write PHP programs through command line. Generally, PHP is use for web applications but  there are occasions where we can use command line such as automatic mail sending, log tracking, cron jobs etc. PHP supports CLI SAPI(Command Line Interface Server API) for executing the script from command line. This SAPI will differ from other interfaces based on the IO practices, configuration defaults, buffering and more. For example, IO practices – it will not support PHP request method (GET, POST). Instead, it uses IO streams. Command line execution time –  In the command line, the execution time limit is unlimited by default. Buffering – implicit_flush is enabled to display output. It also supports output buffering. Some of the PHP CLI SAPI commands: Command Description -i To display command line PHP info. -v To show version details. -r To execute PHP script without delimiters -f To execute PHP file. -l To check the syntax of the...