For a better experience please change your browser to CHROME, FIREFOX, OPERA or Internet Explorer.

User Login script in PHP

1: Create table “student” we need to create a database school & create table student CREATE TABLE `student` ( `id` int(4) NOT NULL auto_increment, `username` varchar(65) NOT NULL default ”, `password` varchar(65) NOT NULL default ”, PRIMARY KEY (`id`) ) TYPE=MyISAM AUTO_INCREMENT=2 ; — — Dumping data for table `student` — INSERT INTO `members` VALUES […] Read More

Backup Your MySQL Database Using PHP

backup_tables('localhost','username','password','blog'); /* backup the db OR just a table */ function backup_tables($host,$user,$pass,$name,$tables = '*') { $link = mysql_connect($host,$user,$pass); mysql_select_db($name,$link); //get all of the tables if($tables == '*') { $tables = array(); $result = mysql_query('SHOW TABLES'); while($row = mysql_fetch_row($result)) { $tables[] = $row[0]; } } else { $tables = is_array($tables) ? $tables : explode(',',$tables); } //cycle […] Read More

Upload file or image in php

Create The HTML Form <!DOCTYPE html> <html> <body> <form action=”upload.php” method=”post” enctype=”multipart/form-data”> Select image to upload: <input type=”file” name=”fileToUpload” id=”fileToUpload”> <input type=”submit” value=”Upload Image” name=”submit”> </form> </body> </html>   Create The Upload File PHP Script The “upload.php” file contains the code for uploading a file: <?php $target_dir = “uploads/”; $target_file = $target_dir . basename($_FILES[“fileToUpload”][“name”]); $uploadOk […] Read More

How To Connect Database in PHP

How To Connect Database in PHP <?php $host=”localhost”; $user=”root”; $pass=””; $database=”databasename”; $conn=mysql_connect($host,$user,$pass); mysql_select_db($database); $_GET = array_map(‘trim’, $_GET); $_COOKIE = array_map(‘trim’, $_COOKIE); if(get_magic_quotes_gpc()): $_GET = array_map(‘stripslashes’, $_GET); $_POST = array_map(‘stripslashes’, $_POST); $_COOKIE = array_map(‘stripslashes’, $_COOKIE); $_REQUEST = array_map(‘stripslashes’, $_REQUEST); endif; //$sql = ‘SELECT * FROM create_user’; // //$result=mysql_query($sql,$conn); // //    while($row = mysql_fetch_assoc($result)) { // //       […] Read More

Upload Image & Compress Image Size PHP

HTML Code For File Uploading <form action=”upload.php” method=”post” name=”video_upload” enctype=”multipart/form-data”> <input name=”new_image” id=”new_image” size=”30″ type=”file” multiple=”true” /> <input type=”submit” value=”submit” name=”submit” /> </form>   File Name upload.php <?php if (isset ($_FILES[‘new_image’])){ $imagename = $_FILES[‘new_image’][‘name’]; $source = $_FILES[‘new_image’][‘tmp_name’]; $type=$_FILES[‘new_image’][‘type’]; $idate=$_REQUEST[‘idate’]; if(($_FILES[‘new_image’][‘type’]==’image/jpeg’) || ($_FILES[‘new_image’][‘type’]==’image/png’)|| ($_FILES[‘new_image’][‘type’]==’image/bmp’)|| ($_FILES[‘new_image’][‘type’]==’image/tiff’)|| ($_FILES[‘new_image’][‘type’]==’image/gif’)) { $target = “../upload/”.$imagename; move_uploaded_file($source, $target); $imagepath = $imagename; $save […] Read More

Export Exxel File in PHP

1.Make a Class “download_csv” <a href=”#” class=”download_csv” rel=”hide_block”><img src=”excel.png” alt=”edit” width=”24″ height=”24″ class=”tabpimpa” /></a> 2. JQUERY $(‘.download_csv’).click(function(e){ if($(‘#chk_data’).val() > 0){ window.location=”admission_ajax.php?action=getcsvData”; }else{ alert(‘No data to be download’); return false; } });   3. PHP Code for export exxel file if(isset($action) && $action == ‘getcsvData’){ $result = $obj_admissionmanager->getAdmissionData(”, $_SESSION[‘login_userid’]) ; //echo ADMIN_ROOT; exit; if($db->numRows($result)>0){ $datetime=date(‘ymdhis’); //$file=VNT_ROOT.”/includes/download_files/allergy_info_”.$datetime.”.csv”; […] Read More