November 15, 2013
Sometime ago the time() function in PHP seems to confuse me of not knowing how to use it but I was just told it calls up current time and date. Well, my research later gave me something when I was accessing all functions my Dreamweaver suggests for me. I found the getdate() function and saw […]
November 15, 2013
Below is a little snippet of what you are looking for
|
<pre><br /><span style="background: #ffffe8; color: #5f5035;"><?php</span><span style="background: #ffffe8; color: black;"></span><br /><span style="background: #ffffe8; color: dimgrey;">## Define zip file name </span><span style="background: #ffffe8; color: black;"></span><br /><span style="background: #ffffe8; color: #400000;">define</span><span style="background: #ffffe8; color: #808030;">(</span><span style="background: #ffffe8; color: #0000e6;">'FILENAME'</span><span style="background: #ffffe8; color: #808030;">,</span><span style="background: #ffffe8; color: #0000e6;">'vpn.zip'</span><span style="background: #ffffe8; color: #808030;">)</span><span style="background: #ffffe8; color: purple;">;</span><span style="background: #ffffe8; color: dimgrey;">##Zip Archive name</span><span style="background: #ffffe8; color: black;"></span><br /><span style="background: #ffffe8; color: #400000;">define</span><span style="background: #ffffe8; color: #808030;">(</span><span style="background: #ffffe8; color: #0000e6;">'DIR_LOC'</span><span style="background: #ffffe8; color: #808030;">,</span><span style="background: #ffffe8; color: #0000e6;">'zip'</span><span style="background: #ffffe8; color: #808030;">)</span><span style="background: #ffffe8; color: purple;">;</span><span style="background: #ffffe8; color: dimgrey;">## directory to exract the files to</span><span style="background: #ffffe8; color: black;"></span><br /><span style="background: #ffffe8; color: black;"></span><br /><span style="background: #ffffe8; color: dimgrey;">//Start new ZipArchive</span><span style="background: #ffffe8; color: black;"></span><br /><span style="background: #ffffe8; color: #797997;">$zip</span><span style="background: #ffffe8; color: black;"> </span><span style="background: #ffffe8; color: #808030;">=</span><span style="background: #ffffe8; color: black;"> </span><span style="background: #ffffe8; color: maroon; font-weight: bold;">new</span><span style="background: #ffffe8; color: black;"> ZipArchive</span><span style="background: #ffffe8; color: purple;">;</span><span style="background: #ffffe8; color: black;"></span><br /><span style="background: #ffffe8; color: black;"></span><br /><span style="background: #ffffe8; color: dimgrey;">//Opening the file name you defined</span><span style="background: #ffffe8; color: black;"></span><br /><span style="background: #ffffe8; color: #797997;">$zip</span><span style="background: #ffffe8; color: #808030;">-</span><span style="background: #ffffe8; color: #808030;">></span><span style="background: #ffffe8; color: black;">open</span><span style="background: #ffffe8; color: #808030;">(</span><span style="background: #ffffe8; color: black;">FILENAME</span><span style="background: #ffffe8; color: #808030;">)</span><span style="background: #ffffe8; color: purple;">;</span><span style="background: #ffffe8; color: black;"></span><br /><span style="background: #ffffe8; color: black;"></span><br /><span style="background: #ffffe8; color: dimgrey;">//Extrating file</span><span style="background: #ffffe8; color: black;"></span><br /><span style="background: #ffffe8; color: #797997;">$zip</span><span style="background: #ffffe8; color: #808030;">-</span><span style="background: #ffffe8; color: #808030;">></span><span style="background: #ffffe8; color: black;">extractTo</span><span style="background: #ffffe8; color: #808030;">(</span><span style="background: #ffffe8; color: black;">DIR_LOC</span><span style="background: #ffffe8; color: #808030;">)</span><span style="background: #ffffe8; color: purple;">;</span><span style="background: #ffffe8; color: black;"></span><br /><span style="background: #ffffe8; color: black;"></span><br /><span style="background: #ffffe8; color: dimgrey;">//We are done, closing connection...</span><span style="background: #ffffe8; color: black;"></span><br /><span style="background: #ffffe8; color: #797997;">$zip</span><span style="background: #ffffe8; color: #808030;">-</span><span style="background: #ffffe8; color: #808030;">></span><span style="background: #ffffe8; color: #400000;">close</span><span style="background: #ffffe8; color: #808030;">(</span><span style="background: #ffffe8; color: #808030;">)</span><span style="background: #ffffe8; color: purple;">;</span><span style="background: #ffffe8; color: black;"></span><br /><span style="background: #ffffe8; color: #5f5035;">?></span><br /> |
November 3, 2013
Hello, you know its gonna be cool if you have your own sitemap been generated automatically from database, this is also for those who update items to db. How i wrote this code is that, assuming you have an item in the db which details are shown in a page, just generate the links and […]
August 7, 2013
Hi all, Its really true that some are still having problem in localhost PhpMyAdmin, now let me show you some basic ways to handle, create and modify a database and the tables. Open your browser and type localhost/phpmyadmin or 127.0.0.1/phpmyadmin Click on Database as highlighted in the picture below Next Page is the list of […]
August 5, 2013
Hi all, I have come to know that most growing PHP Developers have difficult to write a liking or rating system, yes both of them goes alike with the same codeline. The below code is for rating system, just change some wordings and it becomes of liking system. Now in this code, you are to […]
July 10, 2013
Hi all, To all gurus in PHP, i know this is just a piece of cake….but i confess, during my newbie day it tortured me seriously and i want to make it not to torture newbies of today. Lets Begin: Now you already have your data in the database, all you want is to search […]
July 4, 2013
Hi all, I know seeing this post topic, you will think is a huge of code but looking through it well you recognise its just a pieces of codes integrated to give us what we are looking for. Here every browser has a language its browsing with, now I use PHP to call it out […]
July 4, 2013
Hi all, Why do we do password salting/hashing? Just because we need our admin or user panel be protected even if you break into the database you cant find it, even with md5 decoder it won’t work . Now am going to do this with md5() function in php, when a user registers i mix […]
June 16, 2013
Hi all, Am dropping this coz some are having problem with it, all procedures on how to do it is in the code, read well and edit well! 🙂
|
<?php <br /> //connect to your database, fillup the database details <br /> $dbhost = "";// Your database hostname <br /> $dbuser = "";// your database username <br /> $dbname = "";//Your database name <br /> $dbpwd = "";//Your database password, leave empty if your database don't have password <br /> $connect = mysql_connect($dbhost,$dbuser,$dbpwd); <br /> if(!$connect) <br /> { <br /> die('Could not connect to database due to the following reasons: '.mysql_error()); <br /> } <br /> mysql_select_db($dbname); <br /> ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <br /> <html xmlns="http://www.w3.org/1999/xhtml"> <br /> <head> <br /> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <br /> <title>Untitled Document</title> <br /> </head> <br /> <body> <br /> <?php <br /> //checking if comment has been made <br /> if(isset($_POST['comment'])) <br /> { <br /> $comment = mysql_real_escape_string(trim($_POST['comment'])); <br /> if(!$comment) <br /> { <br /> die('Enter Comment'); <br /> } <br /> /*inserting comment into database, with the following columns in the table <br /> *id = which the comment id which will auto increase when ever comment is made <br /> *topic_id = Every comment must have a topic it is commenting for, so that the topic id from another table you created, you can hold it with a session or hidden form <br /> *reply = this is the main body of the reply message <br /> *uid = It must be a user that should made the comment and so from your users table you get the id column and hold it with a session, cookie or hidden form <br /> *date = Surely, it must have a date*/ <br /> //now inserting into database, using example of topic id = 1 and <br /> $date = date('d/m/Y'); <br /> mysql_query("insert into comment(topic_id,reply,uid,date)values('1','$comment','1','$date')") or die('Could not insert comment into database due to the following reasons: '.mysql_error()); <br /> } <br /> //show comment for a particular topic, assumming the topic id is 1 and user id is also 1 <br /> $query = mysql_query("select * from comment where topic_id='1'"); <br /> if(!$query) <br /> { <br /> die(mysql_error()); <br /> } <br /> while($row = mysql_fetch_array($query)) <br /> { <br /> $topic_id = $row['topic_id']; <br /> $uid = $row['uid']; <br /> $reply = $row['reply']; <br /> $date = $row['date']; <br /> ?><a href="">user<?=$uid?></a>: <?=$reply?><br/><?=$date?><br/> <br /> <?php } <br /> ?> <br /> <form action="" method="post"> <br /> <textarea placeholder="Reply" name="comment"></textarea> <br /> <input type="submit" value="Comment" /> <br /> </form> <br /> Created by <a href="http://2netlodge.com">2netlodge</a> <br /> </body> <br /> </html> <br /> |
Hope it helps!
June 15, 2013
Hi all, You need to get an image height and width in PHP? which normally use in passport or profile pictures…now try this code am going to give you.
|
<head> <br /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <br /> <title>PHP Get Image Dimensions</title> <br /> </head> <br /> <body> <br /> <?php <br /> list($width, $height) = getimagesize("images/banner.png"); <br /> echo "Width: " .$width." Height: " .$height; <br /> ?> <br /> </body> <br /> </html> <br /> |
Hope it works