Posts

Showing posts from February, 2010

Code to insert check box elements in the database

Code to insert check box elements in the database <?php if(isset($_POST['button'])) { //count-counts varibale in array $num=count($_POST['hobbies']); $errors=array(); $total_hobbies=""; for($i=0;$i<$num;$i++) { $total_hobbies=$total_hobbies.$_POST['hobbies'][$i].","; } $total_hobbies = substr($total_hobbies, 0,-1); // returns "ef" //echo $total_hobbies; if(empty($_POST['name'])) { $errors[]="Your Name field is empty.Please fill it"; } else { $name=$_POST['name']; } if(empty($_POST['address'])) { $errors[]="Your address field is empty.Please fill it"; } else { $address=$_POST['address']; } if(empty($_POST['user_name'])) { $errors[]="Your user_name field is empty.Please fill it"; $user_name=FALSE; } else { $user_name=$_POST['user_name']; } $education=$_POST['education']; $gender=$_POST['gende

Building a CMS with PHP Part 4 - Editing Posts

Building a CMS with PHP Part 4 - Editing Posts video download

Building a CMS with PHP and MYSQL Part 3

Building a CMS with PHP and MYSQL Part 3

Building a CMS with PHP and MYSQL Part 2

Building a CMS with PHP and MYSQL Pat 2 video, php tutorials video, php and mysql to make cms video

Creating a CMS with PHP and MYSQL

Creating a CMS with PHP and MYSQL, php video tutorial for making the Cms with php and mysql, Creating a CMS with PHP and MYSQL video, video to make site to edit, delete and update the contents

php video tutorial

php video, php tutorial video, php simple tutorials video, simple php video tutorials

Php and mysql free book download

Php Mysql

Download free php and mysql books

Php Mysql

definition of php function explode () function

<?php // Example 1 $pizza = "piece1 piece2 piece3 piece4 piece5 piece6"; $pieces = explode(" ", $pizza); echo $pieces[0]; // piece1 echo $pieces[1]; // piece2 // Example 2 $data = "foo:*:1023:1000::/home/foo:/bin/sh"; list($user, $pass, $uid, $gid, $gecos, $home, $shell) = explode(":", $data); echo $user; // foo echo $pass; // * ?> Description array explode ( string $delimiter , string $string [, int $limit ] ) Returns an array of strings, each of which is a substring of string formed by splitting it on boundaries formed by the string delimiter .

DBA example in php

<?php $id = dba_open("/tmp/test.db", "n", "db2"); if (!$id) { echo "dba_open failed\n"; exit; } dba_replace("key", "This is an example!", $id); if (dba_exists("key", $id)) { echo dba_fetch("key", $id); dba_delete("key", $id); } dba_close($id); ?> DBA is binary safe and does not have any arbitrary limits. However, it inherits all limits set by the underlying database implementation. All file-based databases must provide a way of setting the file mode of a new created database, if that is possible at all. The file mode is commonly passed as the fourth argument to dba_open() or dba_popen(). You can access all entries of a database in a linear way by using the dba_firstkey() and dba_nextkey() functions. You may not change the database while traversing it.

Simple login using php

<?php if(isset($_POST['button'])) { $user_name=$_POST['user_name']; $pass=$_POST['pass']; include('connect.php'); //echo md5('pass'); $query1="select user_id from profile where user_name=\"$user_name\" and pass=MD5(\"$pass\")"; //echo $query1; $result1=mysql_query($query1); if(mysql_num_rows($result1)>0) { echo "You are logged in"; //redirect //session start } else { echo "Wrong username and password please try again."; } } ?> <form id="form1" name="form1" method="post" action="login.php"> <p>Username <label> <input type="text" name="user_name" id="textfield" /> </label> </p> <p>Password <label> <input type="password" name="pass" id="textfield2" /> </label> </p> <p>

Upload your photo with php code

<?php if(isset($_POST['button'])) { //count-counts varibale in array $num=count($_POST['hobbies']); $errors=array(); $total_hobbies=""; for($i=0;$i<$num;$i++) { $total_hobbies=$total_hobbies.$_POST['hobbies'][$i].","; } $total_hobbies = substr($total_hobbies, 0,-1); // returns "ef" //echo $total_hobbies; if(empty($_POST['name'])) { $errors[]="Your Name field is empty.Please fill it"; } else { $name=$_POST['name']; } if(empty($_POST['address'])) { $errors[]="Your address field is empty.Please fill it"; } else { $address=$_POST['address']; } if(empty($_POST['user_name'])) { $errors[]="Your user_name field is empty.Please fill it"; $user_name=FALSE; } else { $user_name=$_POST['user_name']; } $education=$_POST['education']; $gender=$_POST['gender']; if(strlen($_POST['pass'])<4)

Declaration, recommendation and acknowledgement for the summer project

Image
POKHARA UNIVERSITY Faculty of Management Nobel College Declaration I hereby declare that the work reported in this project work on “ Everest Bank Ltd. ” submitted to Nobel College, Pokhara University is my original work done in the form of partial requirement for the degree of (BBA) under the supervision of Mr. Rabin Dahal, Principal of Nobel College and Mr. Dipesh Shrestha, coordinator of Nobel College. ……………………………… Rupak Nepali Exam Roll No.:- 73401** Date: May 24th, 2009 Faculty of Management Studies POKHARA UNIVERSITY RECOMMENDATION This is to certify that the Summer Project Report Submitted by: Rupak Nepali Entitled  Financial Analysis Of Everest Bank Limited, Kathmandu has been prepared as approved by this college. This summer project report is forwarded for examination. Supervisors                                     Rabin Dahal(Principal)  Dipesh Shrestha(Coordinator)                                                                                                

Title Page of summer project

Untitled Document A Report On Financial Analysis of EVEREST BANK LIMITED Kathmandu By: Rupak Nepali PU Reg. No.:- 2006-2-03-*** Exam Roll No.:- 734*** A Summer Project Report Submitted to: Nobel College Faculty of Management Pokhara University In partial fulfillment of the requirements for the degree of Bachelor of Computer Information System Kathmandu , Nepal 2009

Search code part 3

<html> <head> <title>Search Test</title> </head> <body topmargin="0" leftmargin="0"> <form action="search.php" method="post"> Search Term <input type="text" name="searchterm"><br /> <input type="submit" value="Search"> </form> </body> </html> <?php /*set varibles from form */ $searchterm = $_POST['searchterm']; trim ($searchterm); /*check if search term was entered*/ if (!$searchterm){ echo 'Please enter a search term.'; } /*add slashes to search term*/ if (!get_magic_quotes_gpc()) { $searchterm = addslashes($searchterm); } /* connects to database */ @ $dbconn = new mysqli('host', 'username', 'password', 'database'); if (mysqli_connect_errno()) { echo 'Error: Could not connect to database. Please try again la

Search code part 2

this code source... <?php /*set varibles from form */ $searchterm = $_POST['searchterm']; Trim ($searchterm); /*check if search term was entered*/ If (!$searchterm){ echo 'Please enter a search term.'; } /*add slashes to search term*/ If (!get_magic_quotes_gpc()) { $searchterm = addslashes($searchterm); } /* connects to database */ @ $dbconn = new mysqli('localhost', 'root', '', 'sample1'); If (mysqli_connect_errno()) { Echo 'Error: Could not connect to database. Please try again later.'; Exit; } /*query the database*/ $query = "select * from sheet1 where IndexNo like '%".$searchterm."%'"; $result = $dbconn->query($query); /*number of rows found*/ $num_results = $result->num_rows; echo '<p>Found: '.$num_results.'</p>'; /*loops through results*/ For ($I=0; $I <$num_results; $I++) { $num_found = $I + 1; $row = $result->fetch_assoc(); Echo "$num_found. &

Search code part 1

1st part CREATE TABLE users (fname VARCHAR(30), lname VARCHAR(30), info BLOB); INSERT INTO users VALUES ( "Jim", "Jones", "In his spare time Jim enjoys biking, eating pizza, and classical music" ), ( "Peggy", "Smith", "Peggy is a water sports enthusiast who also enjoys making soap and selling cheese" ),( "Maggie", "Martin", "Maggie loves to cook itallian food including spagetti and pizza" ),( "Tex", "Moncom", "Tex is the owner and operator of The Pizza Palace, a local hang out joint" ) 2nd part <h2>Search</h2> <form name="search" method="post" action="<?=$PHP_SELF?>"> Seach for: <input type="text" name="find" /> in <Select NAME="field"> <Option VALUE="fname">First Name</option> <Option VALUE="lname">Last Name</option> <

Edit the row from the database

<?php if(isset($_GET['user_id'])) { $user_id=$_GET['user_id']; } else if(isset($_POST['user_id'])) { $user_id=$_POST['user_id']; } else { $user_id=0; } if($user_id!=0) { //echo "$name $address $user_name $pass"; if (mysql_connect("localhost","root","")) { //echo "connected"; mysql_select_db("php_classes"); if(isset($_POST['button'])) { $name=$_POST['name']; $address=$_POST['address']; $user_name=$_POST['user_name']; $query1="select user_id from profile where user_id=$user_id"; $result1=mysql_query($query1); if(mysql_num_rows($result1)==0) { echo "This username is not available"; } else { $query="update profile set name='$name',address='$address',user_name='$user_name' where user_id=$user_id limit 1"; //echo $query; $result=mysql_query($query); if (mysql_affected_r

list the users in the database

<?php if (mysql_connect("localhost","root","")) { mysql_select_db("php_classes"); $query="select * from profile"; $result=mysql_query($query); if (mysql_num_rows($result)>0) { ?> <table width="100%" border="1" cellspacing="0" cellpadding="0"> <tr> <td>Name</td> <td>Address</td> <td>Username</td> <td>Added</td> <td>Delete</td> <td>Edit</td> </tr> <?php while ($rows=mysql_fetch_array($result,MYSQL_ASSOC)) { ?> <tr> <td><?php echo "{$rows['name']}"; ?></td> <td><?php echo "{$rows['address']}"; ?></td> <td><?php echo "{$rows['user_name']}"; ?></td> <td><?php echo "{$rows['added_on']}"; ?&

insert in the database using the php code

<?php if(isset($_POST['button'])) { $name=$_POST['name']; $address=$_POST['address']; $user_name=$_POST['user_name']; $pass=$_POST['pass']; //echo "$name $address $user_name $pass"; if (mysql_connect("localhost","root","")) { //echo "connected"; mysql_select_db("php_classes"); $query1="select user_id from profile where user_name=\"$user_name\""; $result1=mysql_query($query1); if(mysql_num_rows($result1)>0) { echo "This username is not available"; } else { $query="insert into profile(name,address,user_name,pass,added_on) values ('$name','$address','$user_name',MD5('$pass'),NOW())"; //echo $query; $result=mysql_query($query); if (mysql_affected_rows()==1) { echo "You Are registered"; } else { echo "You Are NOT r

delete user from the database

<?php $user_id=$_GET['user_id']; if(isset($_GET['submit'])) { if (mysql_connect("localhost","root","")) { //echo "connected"; mysql_select_db("php_classes"); $confirm=$_GET['confirm']; if ($confirm==1) { $query="delete from profile where user_id=$user_id limit 1"; //echo $query; $result=mysql_query($query); if (mysql_affected_rows()==1) { echo "User of ID $user_id has been deleted "; } else { echo "User of ID $user_id has NOT been deleted"; } } else { echo "The action was not done"; } } else { echo "Could not connect to database"; } } ?> <form method="get" action="delete_user.php"> Deleting user <?php echo $user_id; ?> <input type="hidden" name="us

learn about tables rowspan and colspan

</head> <body> <table border="0" cellpadding="2" cellspacing="2" width="100%"> <tr> <td width="33%">1</td> <td colspan="2"> </td> </tr> <tr> <td rowspan="2">2</td> <td>1</td> <td>1</td> </tr> <tr> <td>1</td> <td>2</td> </tr> </table> </body> </html> learn about tables rowspan and colspan, example of rowspan, example of colspan, example of table in the html, example of table in php

Uses of stripslashes addslashes

<?php echo "This is printed doc"; //printf("This is another print"); $user="Ram"; echo "This is $user<br/>"; echo 'This is $user<br/>'; $user='ram"s'; $user=addslashes($user); echo "$user<br/>"; $user=stripslashes($user); echo "$user<br/>"; //$query="select * from table where username =$user"; //echo $query; $str = "A 'quote' is <b>bold</b>"; // Outputs: A 'quote' is <b>bold</b> echo htmlentities($str, ENT_QUOTES); $test= htmlspecialchars("<a href='test'>Test</a>", ENT_QUOTES); echo $test; echo md5("test"); echo nl2br("foo isn't\n bar"); $pass="ram1"; if($pass=="ram") { echo "Authorized"; } echo "<br/>"; $text = '<p>Test paragraph.</p><!-- Comment --> <a href=\"#fragment\">Other text&

use of explode function and file_get_contents functions

how can we hack the contents of others sites? how can we links others site with ours? how can we show others contents in our sites? <?php /*$data='<table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td>one</td> </tr> <tr> <td>Two</td> </tr> <tr> <td>Three</td> </tr> <tr> <td>Four</td> </tr> <tr> <td>Five</td> </tr> </table>';*/ $test=file_get_contents("http://www.cybernepal.com.np"); echo $test; //$break=explode("</tr>",$data); //print_r($break); ?>

knowledge about rowspan and colspan in our classes

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> <body> <table border="0" cellpadding="2" cellspacing="2" width="100%"> <tr> <td width="33%">1</td> <td colspan="2"> </td> </tr> <tr> <td rowspan="2">2</td> <td>1</td> <td>1</td> </tr> <tr> <td>1</td> <td>2</td> </tr> </table> </body> </html>

Database structures for php classes

-- phpMyAdmin SQL Dump -- version 3.1.3.1 -- http://www.phpmyadmin.net -- -- Host: localhost -- Generation Time: Feb 05, 2010 at 12:47 PM -- Server version: 5.1.33 -- PHP Version: 5.2.9 SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; -- -- Database: `php_classes` -- -- -------------------------------------------------------- -- -- Table structure for table `profile` -- CREATE TABLE IF NOT EXISTS `profile` ( `user_id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(254) NOT NULL, `address` varchar(150) NOT NULL, `user_name` varchar(50) NOT NULL, `pass` varchar(40) NOT NULL, `added_on` datetime NOT NULL, PRIMARY KEY (`user_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ; -- -- Dumping data for table `profile` -- INSERT INTO `profile` (

collection of mysql functions

mysql_affected_rows — Get number of affected rows in previous MySQL operation mysql_client_encoding — Returns the name of the character set mysql_close — Close MySQL connection mysql_connect — Open a connection to a MySQL Server mysql_create_db — Create a MySQL database mysql_data_seek — Move internal result pointer mysql_db_name — Get result data mysql_db_query — Send a MySQL query mysql_drop_db — Drop (delete) a MySQL database mysql_errno — Returns the numerical value of the error message from previous MySQL operation mysql_error — Returns the text of the error message from previous MySQL operation mysql_escape_string — Escapes a string for use in a mysql_query mysql_fetch_array — Fetch a result row as an associative array, a numeric array, or both mysql_fetch_assoc — Fetch a result row as an associative array mysql_fetch_field — Get column information from a result and return as an object mysql_fetch_lengths — Get the length of each output in a result mysql_fetch_object — Fetch a re

Sending mail to many clients

<?php include("connection.php"); if (!isset($_POST['submit'])): ?> <html> <head> <title>Mailing List</title> </head> <body bgcolor="#D6DEE7"> <form method="post" action="<?=$_SERVER['PHP_SELF']?>"> <table width="471" border="0"> <tr> <td colspan="2"><b><h2 align="center">MAILING LIST ADMIN</h2></b></td> </tr> <tr> <td width="143">Send message to:</td> <td width="318"><select name="to" size="1" style="background-color: #F7F7F7"> <option selected value="all">Entire School <OPTION value="primary">primary <OPTION value="lower_secondary">lower secondary <OPTION value="secondary">secondary </select></td> </tr&g

form validation using javascript

<html> <head> <title>Untitled Page</title> <script type="text/javascript"> <!-- function BatchValidation() { var validationMessage=""; if(document.form1.txtFName.value=="") { validationMessage+="\n First Name is the required field!"; } if(document.form1.txtLName.value=="") { validationMessage+="\n Last Name is the required field!"; } if(!IsCorrectEmailFormat(document.form1.txtEmail.value)) { validationMessage+="\n Email address is not valid format!"; } if(isNaN(document.form1.txtPhoneNo.value)) { validationMessage+="\n Phone number is number!"; } if(isNaN(document.form1.txtMobileNo.value)) { validationMessage+="\n Mobile number is number!"; }

create some sophisticated web sites

<? $message = ""; $emailclass = "basictext"; $username = ""; if ($_POST['process'] == 1) { $pattern = '/.*@.*\..*/'; $email = $_POST['email']; $urlname = urlencode($$_POST['username']); if (preg_match($pattern, $_POST['email']) > 0) { // Here's where you would store // the data in a database... header( "location: thankyou.php?&username=$urlname"); } $message = "Please enter a valid email address."; $username = $_POST['name']; $emailclass = "errortext"; } ?> <html> <style> .basictext { font-family: Arial, Helvetica, sans-serif; font-size: 14px; color:#000066; } .errortext { font-family: Arial, Helvetica, sans-serif; font-size: 14px; color:#C00000; font-weight: bold;

Simple retrieve, amend and update MySQL database

PHP Scripts Simple retrieve, amend and update MySQL database 1. 1st page to aquire reference ( display all to make it easy) 2. 2nd page display results and allow viewer to change 3. Update the database amend.php <html><TD WIDTH="29%" HEIGHT="60"><DIV ALIGN="LEFT"><BR>Input the Reference, to make sure we have the right one:<BR><BR><FONT SIZE="1">(quick reference listed below for your convenience)</FONT></DIV> <form method=POST action="amend1.php"> <DIV ALIGN="LEFT"><INPUT TYPE="text" NAME="record" SIZE="50" MAXLENGTH="50"><BR><BR><IMG SRC="search.jpg" WIDTH="51" HEIGHT="46" ALIGN="ABSMIDDLE" BORDER="1"><INPUT TYPE="submit" NAME="go" VALUE="Search on that Input"></DIV></form></TD></TR><TR&g

show time with javascripts code

<html> <head> <script type="text/javascript"> function JSclock() { var time=new Date(); var hour=time.getHours(); var min=time.getMinutes(); var second=time.getSeconds(); var temp=""+((hour>12) ? eval(hour-12) : hour); temp+=((min<10) ? ":0" : " : ") + min; temp+=((second<10) ? ":0" : " :")+second; temp+=((hour>=12) ? "pm" : "am"); document.getElementById("currentTime").innerHTML=temp; setTimeout("JSclock()",1000); } </script> </head> <body onload="JSclock()"> <span id="currentTime"></span> </body> </html> show time with javascripts code, javascript code, time giving javascript code

Calender Code "Javascript code that must be at js/src" named unittest.js

// script.aculo.us unittest.js v1.6.5, Wed Nov 08 14:17:49 CET 2006 // Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) // (c) 2005, 2006 Jon Tirsen (http://www.tirsen.com) // (c) 2005, 2006 Michael Schuerig (http://www.schuerig.de/michael/) // // script.aculo.us is freely distributable under the terms of an MIT-style license. // For details, see the script.aculo.us web site: http://script.aculo.us/ // experimental, Firefox-only Event.simulateMouse = function(element, eventName) { var options = Object.extend({ pointerX: 0, pointerY: 0, buttons: 0, ctrlKey: false, altKey: false, shiftKey: false, metaKey: false }, arguments[2] || {}); var oEvent = document.createEvent("MouseEvents"); oEvent.initMouseEvent(eventName, true, true, document.defaultView, options.buttons, options.pointerX, options.pointerY, options.pointerX, options.pointerY, options.ctrlKey, options.altKey, option