How to check if a button is pressed.

How to check if a button is pressed using php .. 🙂 if (isset($_POST[‘button’])){ echo “button pressed”; } else { echo “button not pressed” ; } <form class=”form-horizontal” action=”check_button_pressed.php” method=”post”> <div class=”form-group”> <div class=”col-sm-offset-2 col-sm-10″><button class=”btn btn-default” name=”button” type=”submit”>Test</button></div> &nbsp; </div> &nbsp; </form>&nbsp; Will on button click display button pressed .. 🙂

Use PHP to zip (archive) a folder

Here is a very simple way to use PHP to zip up (archive) a folder.

How to get address URL

How to get the full address URL using PHP .. /**** * Get the url address */ function getAddress() { // check for https $protocol = (isset( $_SERVER[‘https’]) == ‘on’ ? ‘https’ : ‘http’); //return address return $protocol.’://’.$_SERVER[‘HTTP_HOST’].$_SERVER[‘REQUEST_URI’]; } //usage echo getAddress(); Will output the full URL 🙂

How to create a new database with PHP & PDO

Creating a new databse with PHP and PDO : <?php // Hosting details $host=”localhost”; $root=”root”; $root_password=”rootpass”; // New database user, password & database name $user=’newuser’; $pass=’newpass’; $db=”newdb”; // Create database connnection try { $dbh = new PDO(“mysql:host=$host”, $root, $root_password); // Exectute $dbh->exec(“CREATE DATABASE `$db`; CREATE USER ‘$user’@’localhost’ IDENTIFIED BY ‘$pass’; GRANT ALL ON `$db`.* TO

PDO code to show all databases

Showing a list of all the databases using PHP and PDO. <?php $user = ‘root’; $pass = ‘password’; $server = ‘localhost’; $dbh = new PDO( “mysql:host=$server”, $user, $pass ); $dbs = $dbh->query( ‘SHOW DATABASES’ ); while( ( $db = $dbs->fetchColumn( 0 ) ) !== false ) { echo $db.’ ‘; } ?> Will out a