Posts

Showing posts with the label Database

Check Traffic Sources

Image
Click to large Currently Working on the stuff: if(isset($_GET['token'])) { $token = sanitize($_GET['token']); $sqlcheck = "select `traficsource_source` from `traficsource` where `traficsource_source`='{$token}'"; $result = $dbLink->query($sqlcheck); if($result->num_rows == 0) { $sql1="INSERT INTO `traficsource` (`traficsource_source`, `traficsource_count`, `traficsource_insert`, `traficsource_update`) VALUES ('{$token}', '1', CURRENT_TIMESTAMP, now())"; $result = $dbLink->query($sql1); } else { $sql1="update `traficsource` set `traficsource_count`=(`traficsource_count`+1),`traficsource_update`=now() where `traficsource_source`='{$token}'"; $result = $dbLink->query($sql1); } }

How to connect to Database using PHP

Image
How to connect to Database: Here we will know about the database connectivity on PHP. Firstly we have to check database credential of the server, Usually They are as following: For Local Server (i.e. XAMPP/ WAMPP etc.) Server: localhost Username: root Password:   (blank) For Server  (i.e. cpanel, window etc) Server: localhost  or domain name of the website Username: can be created by Hosting panel using Database wizard (Cpanel) or Option proided on the same Password:  same as above We have to create a database to connect with a particular database for a particular  website or Program. Now we will define all on a variable: <?php $databaseserver = "localhost";   // can be changed as required $databaseuser =  " dbadmin ";   // as exapmle I have taken it dbadmin $databasepassword = "W3help@123";  // as exapmle,  use password as strong, use Capital, small, Number and special Character. Probability of such password guessing is les

Visitor Count for Website in PHP

Hello, Here I am writing a small program in PHP for  checking how much user have visited our website using COOKIES, MYSQL and IP address of the user. First we have to create cookies for the new user. This the code we will use for that: (I have make a cookies for 30 days) setcookie('ipaddress',$_SERVER['REMOTE_ADDR'],time()+(60*60*24*30)); Secondly we have to create a table on database to store the number of Visitors. I have created a table i.e. usercounter with following attribute:  (Initially Insert value with o and 1 on useripid ) useripid   (INT type - AUTO-INCREMENT) lastaddress   (VARCHAR    -   Last visitor IP) userqua   (INT)   (Counter for visitor)  (Initially 0) lastmodified   (TIMESTAMP)   (Last modified time for database) Now we have to check whether user are coming on website for first time or He has already visited. if(isset($_COOKIE['ipaddress'])) { // check is the same ip if($_COOKIE['ipaddress']==$_SERVER['REMO