Thursday, April 14, 2011

div code for design w/ css

                                                              index.html
<!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>
<link rel="stylesheet" type="text/css" href="main.css" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>


<div align="center">

  <div id="wrapper">
      <div id="header">   
        <div id="logo">
          <img src="../images/logo.png" alt="Logo" />
      </div>
      <div id="contact-number">
          CALL US - 123.1234
      </div>
      <div id="user-control">
          <a href="#">About Us</a> | <a href="#">Register</a> | <a href="#">Login</a>
      </div>
      <div id="get-started">
          <img src="../images/get-started-btn.png" alt="get started" />
      </div>
      <div class="clear"></div>
    </div><!-- .header -->
    <div id="navigation">
        <ul>
          <li><a href="#"><img src="../images/btn-ourservices.jpg" alt="our services" /></a></li>
        <li><a href="#"><img src="../images/btn-why.jpg" alt="why" /></a></li>
        <li><a href="#"><img src="../images/btn-business.jpg" alt="business" /></a></li>
        <li><a href="#"><img src="../images/btn-get.jpg" alt="get" /></a></li>
             <div class="clear"></div>
      </ul>
    </div><!-- #navigation -->
    <div id="banner"><img src="../images/banner.jpg" alt="banner" /></div>
  </div><!-- #wrapper -->

</div>

</body>
</html>






                                                       main.css
@charset "utf-8";
/* CSS Document */

body{
    margin:0px 0px 0px 0px;
    font-family:Verdana, Arial, Helvetica, sans-serif;
    font-size:10px;
    background:#ffffff;
}

div, img, form{
    margin:0px;
    padding:0px;
    border:0px;
}

a{
    color:#000000;
    text-decoration:none;
}   

a:hover{
    text-decoration:underline;
}

#wrapper{
    width:895px;
    text-align:left;

}

#header{
    padding:8px 0px 0px 0px;
}

#header div#logo{
    margin:0px 70px 0px 0px;
    float:left;
}

#header div#contact-number{
    color:#214099;
    font-size:15px;
    font-weight:bold;
    padding-top:16px;
    margin-right:40px;
    float:left;
}

#header div#user-control{
    margin-right:14px;
    padding-top:38px;
    float:left;
}

#header div#user-control a{
    text-decoration:none;
    font-weight:bold;
    color:#0000ff;
}

#header div#user-control a:hover{
    text-decoration:underline;
}

#header div#get-started{
    padding-top:10px;
}


#navigation{
    text-align:left;
    margin-top:5px;
    height:41px;
}


#navigation ul{
    list-style:none;
    padding:0px;
    margin:0px;

}

#navigation ul li{
    float:left;
    height:41px;
}

#banner{
    border: 1px solid #cccccc;
    border-top:0px;
    width:889px;
}

.clear{
    clear:both;
}

insert record(vb.net 2008) in mysql server

Imports System.Data.OleDb
Imports MySql.Data.MySqlClient
Public Class frmRegistration


    Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
        Dim con = New MySqlConnection(conn)



        Dim myCommand As New MySqlCommand
        myCommand.Connection = con
        myCommand.CommandText = "INSERT INTO tbl_students(name)" _
         & "VALUES('" & txtServer.Text & "')"

        Try
            con.Open()
            myCommand.ExecuteNonQuery()
            con.Close()
        Catch myerror As MySqlException
            MsgBox("There was an error updating the database: " & myerror.Message)
        End Try



    End Sub


End Class

module1(vb.net 2008) w/ connections string for mysql server

'Call the pakages
Imports System.Data.OleDb
Imports MySql.Data.MySqlClient

Module Module1
   


    Public conn As String = "server=localhost;User Id=root;password=fatimajoey;database=enrollmentdb"


End Module

Wednesday, April 13, 2011

browse picture(php)

<input type="hidden" name="MAX_FILE_SIZE" value="90000000"/><input type="file" name="image" size="30"/>&nbsp;
<?php
             include("connect.php");
        $x=1;   
      if(isset($_POST['Submit']))
      {
       
       
       
                $target_path = "images/";
                $target_path = $target_path . basename( $_FILES ['image']['name']);
                    if(move_uploaded_file($_FILES['image']['tmp_name'], $target_path))
                    {
                       
                        $imgdis = $_FILES['image']['name'];
                        $txtq1 = $_POST['txtq1'];               
                         $txtq2 = $_POST['txtq2'];
                        $txtfname = $_POST['txtfname'];
                        $txtmname = $_POST['txtmname'];
                        $txtlname = $_POST['txtlname'];
                        $txtadd1 = $_POST['txtadd1'];
                        $txtadd2 = $_POST['txtadd2'];
                        $txtnat = $_POST['txtnat'];
                        $txtblood = $_POST['txtblood'];
                        $txtdob = $_POST['txtdob'];
                        $txtpob = $_POST['txtpob'];
                        $txtage = $_POST['txtage'];
                        $txtstat = $_POST['txtstat'];
                        $txtrel = $_POST['txtrel'];
                        $txtchurch = $_POST['txtchurch'];
                        $txtpriest = $_POST['txtpriest'];
                        $txtlangauge = $_POST['txtlangauge'];
                        $txttribe = $_POST['txttribe'];
                        $txtspec = $_POST['txtspec'];
                        $txtparents = $_POST['txtparents'];
                        $txtpadd = $_POST['txtpadd'];
                        $txtdep1 = $_POST['txtdep1'];
                        $txtage1 = $_POST['txtage1'];
                        $txtrel1 = $_POST['txtrel1'];
                        $txtdep2 = $_POST['txtdep2'];
                        $txtage2 = $_POST['txtage2'];
                        $txtrel2 = $_POST['txtrel2'];
                        $txtdep3 = $_POST['txtdep3'];
                        $txtage3 = $_POST['txtage3'];
                        $txtrel3 = $_POST['txtrel3'];
                        $txtdep4 = $_POST['txtdep4'];
                        $txtage4 = $_POST['txtage4'];
                        $txtrel4 = $_POST['txtrel4'];
                        $txtdep5 = $_POST['txtdep5'];
                        $txtage5 = $_POST['txtage5'];
                        $txtrel5 = $_POST['txtrel5'];
                        $txtbro = $_POST['txtbro'];
                        $txtwork = $_POST['txtwork'];
                        $txtterm = $_POST['txtterm'];
                        $txtwhy = $_POST['txtwhy'];
                        $txtreceive = $_POST['txtreceive'];
                        $txtexpect = $_POST['txtexpect'];
                        $txtassign = $_POST['txtassign'];
                        $txtexper = $_POST['txtexper'];
                        $txtaccused = $_POST['txtaccused'];
                        $txtresult = $_POST['txtresult'];
                        $txtlabor = $_POST['txtlabor'];
                        $txtunion = $_POST['txtunion'];
                        $txtstrike = $_POST['txtstrike'];
                        $txtcom = $_POST['txtcom'];
                        $txtwhen = $_POST['txtwhen'];
                        $txtsmoke = $_POST['txtsmoke'];
                        $txtdrink = $_POST['txtdrink'];
                        $txtbottles = $_POST['txtbottles'];
                        $txttimes = $_POST['txttimes'];
                        $txthos = $_POST['txthos'];
                        $txtill = $_POST['txtill'];
                        $txtcards = $_POST['txtcards'];
                        $txtgames = $_POST['txtgames'];
                        $txtsport = $_POST['txtsport'];
                        $txthobbies = $_POST['txthobbies'];
                        $txtexam = $_POST['txtexam'];
                        $txtdysme = $_POST['txtdysme'];
                        $txtmens = $_POST['txtmens'];
                           
        $result = "INSERT INTO tbl_apps(`q1`,`q2`,`fname`,`mname`,`lname`,`add1`,`add2`,`nat`,`bld`,`dob`,`pob`,`age`,`stat`,`rel`,`church`,`priest`,`lang`,`tribe`,`spec`,`parents`,`padd`,`dep1`,`age1`,`rel1`,`dep2`,`age2`,`rel2`,`dep3`,`age3`,`rel3`,`dep4`,`age4`,`rel4`,`dep5`,`age5`,`rel5`,`bro`,`work`,`term`,`why`,`receive`,`expect`,`assign`,`exper`,`accused`,`rs`,`labor`,`union`,`strike`,`com`,`when`,`smoke`,`drink`,`bottles`,`times`,`hos`,`ill`,`cards`,`games`,`sport`,`hobbies`,`exam`,`dysme`,`mens`,`pic`,`jobID`,`rd`) VALUES('$txtq1','$txtq2','$txtfname','$txtmname','$txtlname','$txtadd1','$txtadd2','$txtnat','$txtblood','$txtdob','$txtpob','$txtage','$txtstat','$txtrel','$txtchurch','$txtpriest','$txtlangauge','$txttribe','$txtspec','$txtparents','$txtpadd','$txtdep1','$txtage1','$txtrel1','$txtdep2','$txtage2','$txtrel2','$txtdep3','$txtage3','$txtrel3','$txtdep4','$txtage4','$txtrel4','$txtdep5','$txtage5','$txtrel5','$txtbro','$txtwork','$txtterm','$txtwhy','$txtreceive','$txtexpect','$txtassign','$txtexper','$txtaccused','$txtresult','$txtlabor','$txtunion','$txtstrike','$txtcom','$txtwhen','$txtsmoke','$txtdrink','$txtbottles','$txttimes','$txthos','$txtill','$txtcards','$txtgames','$txtsport','$txthobbies','$txtexam','$txtdysme','$txtmens','$imgdis','$id','n')";
                        $rs1 = mysql_query($result) or die("Invalid Query <br>$result");
                        $x++;
           
                   
                }
            }
if($x>1)
echo'<script type="text/javascript">document.location.href="job_app_msg.php";</script>';

            ?>

Update records(vb.net 2008)

Private Sub updatetblitem()
        connection_open()
        ssql = "UPDATE tblitem SET ticketno= '" & txtticket.Text & "', date_t= '" & dtprdate.Value _
        & "',  m_date= '" & TextBox2.Text & "',e_date= '" & TextBox1.Text & "',interest_r= '" & txtinterest.Text _
        & "' ,penalty_r= '" & txtpenalty.Text & "',s_fee= '" & txtservice.Text & "',account_stat= '" & txtstatnew.Text & _
        "',payments= '" & txttotal.Text & "' where ticketno='" & txtticketno1.Text & "'"
        cmd = New OleDbCommand(ssql, olecon)
        cmd.ExecuteNonQuery()
        cmd.Dispose()
        connection_close()
    End Sub

insert record(vb.net 2008)

Private Sub Insert_temptblitemhistory()
        connection_open()
        ssql = "INSERT INTO tblitem_history SELECT * FROM tblitem WHERE ticketno = '" & txtticketno1.Text & "'"
        cmd = New OleDbCommand(ssql, olecon)
        cmd.ExecuteNonQuery()
        cmd.Dispose()
        connection_close()
    End Sub

search records(vb.net 2008)

 Private Sub searchListView()
        connection_open()
        Try
            ssql = "SELECT * FROM tblitem_transaction where ticketno like '" & txtticketno.Text & "%'"
            cmd = New OleDbCommand(ssql, olecon)
            objRead = cmd.ExecuteReader
            While objRead.Read
                lv = Me.ListView2.Items.Add(objRead("item_ID") & "")
                'lv.SubItems.Add(objRead("cus_ID") & "")
                lv.SubItems.Add(objRead("ticketno") & "")
                lv.SubItems.Add(objRead("date_t") & "")
                lv.SubItems.Add(objRead("m_date") & "")
                lv.SubItems.Add(objRead("e_date") & "")
                lv.SubItems.Add(objRead("p_amount") & "")
                lv.SubItems.Add(objRead("interest_r") & "")
                lv.SubItems.Add(objRead("penalty_r") & "")
                lv.SubItems.Add(objRead("s_fee") & "")
                lv.SubItems.Add(objRead("payments") & "")
            End While
            objRead.Close()
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        Finally
            connection_close()
        End Try
    End Sub

pass datbase value to textbox(vb.net 2008)

Private Sub int_pen_serv_rate()
        connection_open()
        Try
            ssql = "SELECT * FROM tblsetting "
            cmd = New OleDbCommand(ssql, olecon)
            objRead = cmd.ExecuteReader
            While objRead.Read
                txtinterest.Text = objRead("interest_r")
                txtpenalty.Text = objRead("penalty_r")
                txtservice.Text = objRead("s_fee")
            End While
            objRead.Close()
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        Finally
            connection_close()
        End Try
    End Sub

delete records(vb.net 2008)

Private Sub mnuDel_Item_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuDel_Item.Click
        Dim x As String
        x = InputBox("Please Input Item ID", "Remove Item")
        If IsNumeric(x) = False Then
            Exit Sub
        End If
        connection_open()
        ssql = "DELETE FROM temp_transaction WHERE item_ID = '" & x & "' "
        cmd = New OleDbCommand(ssql, olecon)
        cmd.ExecuteNonQuery()
        cmd.Dispose()
        connection_close()
        connection_open()
        ssql = "DELETE FROM tblitem WHERE item_ID = '" & x & "' "
        cmd = New OleDbCommand(ssql, olecon)
        cmd.ExecuteNonQuery()
        cmd.Dispose()
        connection_close()
        PopulateListView()
    End Sub

call PopulateListView (vb.net 2008)

Private Sub PopulateListView()
        ListView2.Items.Clear()
        connection_open()
        Try
            ssql = "SELECT * FROM temp_transaction ORDER BY item_ID Asc"
            cmd = New OleDbCommand(ssql, olecon)
            objRead = cmd.ExecuteReader
            While objRead.Read
                lv = Me.ListView2.Items.Add(objRead("item_ID") & "")
                lv.SubItems.Add(objRead("ticketno") & "")
                lv.SubItems.Add(objRead("date_t") & "")
                lv.SubItems.Add(objRead("m_date") & "")
                lv.SubItems.Add(objRead("e_date") & "")
                lv.SubItems.Add(objRead("p_amount") & "")
                lv.SubItems.Add(objRead("interest_r") & "")
                lv.SubItems.Add(objRead("penalty_r") & "")
                lv.SubItems.Add(objRead("s_fee") & "")
                lv.SubItems.Add(objRead("payments") & "")
                lv.SubItems.Add(objRead("account_stat") & "")
            End While
            objRead.Close()
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        Finally
            connection_close()
        End Try
    End Sub

log in form(vb.net 2008)

Imports System.Data
Imports System.Data.OleDb
Imports System.Math
Public Class Loginfrm
    Dim objRead As OleDb.OleDbDataReader

    Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
        tempun.Text = ""
        tempPass.Text = ""
        tempType.Text = ""

        If UsernameTextBox.Text = "" And PasswordTextBox.Text = "" Then
            ErrorProvider1.SetError(UsernameTextBox, "connot leave Username blank")
            ErrorProvider1.SetError(PasswordTextBox, "connot leave Password blank")
            MsgBox("Enter Username and Password !", MsgBoxStyle.Critical, "Information System")
            UsernameTextBox.Focus()

            Exit Sub
        ElseIf UsernameTextBox.Text = "" Then
            ErrorProvider1.SetError(UsernameTextBox, "connot leave Username blank")
            MsgBox("Enter Username !", MsgBoxStyle.Critical, "Information System")
            ErrorProvider1.SetError(PasswordTextBox, "")
            UsernameTextBox.Focus()
        ElseIf PasswordTextBox.Text = "" Then
            ErrorProvider1.SetError(PasswordTextBox, "connot leave Password blank")
            MsgBox("Enter Password !", MsgBoxStyle.Critical, "Information System")
            ErrorProvider1.SetError(UsernameTextBox, "")
            PasswordTextBox.Focus()
        End If
        connection_open()
        Dim str As String = "select * from tbllogin where users='" & UsernameTextBox.Text & "'"
        Dim cmd As New OleDb.OleDbCommand(str, olecon)

        objRead = cmd.ExecuteReader()
        While objRead.Read()
            tempun.Text = objRead("users")
            tempPass.Text = objRead("pass")
            tempType.Text = objRead("type")

        End While

        objRead.Close()
        connection_close()
        If tempun.Text = UsernameTextBox.Text And tempPass.Text = PasswordTextBox.Text Then
            trackuser()
            MsgBox("Your log in time is " + TimeOfDay, MsgBoxStyle.Information, "Sales System")
            mainMDIParent.Show()
            Me.Visible = False
            UsernameTextBox.Text = ""
            PasswordTextBox.Text = ""
        Else
            i += 1
            If i >= 3 Then
                MsgBox("Sorry, Application Canceled !", MsgBoxStyle.Critical, "Sales System")

                Application.Exit()

            Else
                MsgBox("Wrong Password !. Try Again !", MsgBoxStyle.Critical, "Sales System")

                PasswordTextBox.Clear()
                PasswordTextBox.Focus()
            End If
        End If
        mainMDIParent.txtuser.Text = tempun.Text
        mainMDIParent.txttype.Text = tempType.Text
    End Sub
    Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click
        Application.Exit()
    End Sub
    Private Sub PasswordTextBox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles PasswordTextBox.KeyPress
        If e.KeyChar = Chr(13) Then
            OK.PerformClick()
        End If
    End Sub
    Private Sub trackuser()
        Dim a As Date = Now
        connection_open()
        Dim sqql As String = "INSERT INTO tbluser_transaction(users,date_timelogin) Values ('" & tempun.Text & "','" & a & "')"
        Dim cmd As New OleDb.OleDbCommand(sqql, olecon)
        cmd.ExecuteNonQuery()
        cmd.Dispose()
        connection_close()

    End Sub

    Private Sub Loginfrm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class

module1(vb.net 2008) w/ connections string and auto number

'Call the pakages
Imports System.Data
Imports System.Data.OleDb

Module modVariables
    'Declare all variables
    Public olecon As OleDbConnection
    Public cmd As OleDbCommand
    Public cmd1 As OleDbCommand
    Public adp As OleDbDataAdapter
    Public dr As OleDbDataReader
    Public ds As New Data.DataSet
    Public i As Integer
    Public ssql As String
    Public con As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Elaine K Pawnshop\databaseko.mdb;Persist Security Info=False"
    Public dt As New DataTable
    Public days As Integer
    Public years As Integer
    Public months As Integer
    Public mint As Integer
    Dim dr3 As OleDbDataReader
    Public Sub connection_open()
        'Setting the database connection
        'You could also put try catch to control your errors
        olecon = New OleDbConnection(con)
        olecon.Open()

    End Sub

    Public Sub connection_close()
        'Closing the connection
        olecon.Close()
        olecon.Dispose()

    End Sub

    Public Function Getid(ByVal tablename As String, ByVal fieldname As String, Optional ByVal cond As String = "") As Double
        Dim cmd2 As New OleDbCommand

        connection_open()
        Try

            cmd2.Connection = olecon
            cmd2.CommandText = "select top 1 " & fieldname & " from " & tablename & IIf(cond <> "", " where " & cond, "") & " order by 1 desc"
            dr = cmd2.ExecuteReader
            If dr3.Read = True Then
                Getid = dr3(0) + 1
            Else
                Getid = 1
            End If
            dr3.Close()
        Catch ex As Exception
            MsgBox(Err.Description)
        End Try
        connection_close()
    End Function
    Function AutoID(ByVal Tablename As String, ByVal Fieldname As String) As Int32
        connection_open()
        Dim cmd1 As New OleDbCommand
        Dim dr1 As OleDbDataReader
        cmd1.Connection = olecon
        cmd1.CommandType = CommandType.Text
        cmd1.CommandText = "select top 1 " & Fieldname & " from " & Tablename & " Order by 1 Desc "
        dr1 = cmd1.ExecuteReader
        If dr1.Read = True Then
            AutoID = Microsoft.VisualBasic.Right(dr1(0), 4) + 1
        Else
            AutoID = 1
        End If
        dr1.Close()
        connection_close()
    End Function
   
End Module

Update records(vb 6)

rs.Open "Update tblSupplier set Supplier_Name='" & Sup_Name & "',Address='" & sAdd & "',Telephone='" & sTel & "'" & _
        "Where Supplier_ID='" & Sup_ID & "'", cn, 3, 3
        i_Disable.Disable_Txt Me
        Set rs = Nothing
        Call grd_Data_Loader
        MsgBox "Supplier with supplier ID " & Sup_ID & " has been updated.", vbInformation, "Inventory System"

mshflexGrid loader(vb 6)

Private Function grd_Data_Loader()
rs.Open "Select*from tblSupplier", cn, 3, 3
Set supGrid.DataSource = rs
Set rs = Nothing
End Function

delete records(vb 6)

Private Sub cmdDelete_Click()
iFind = UCase(InputBox("Enter supplier ID to delete."))
Call sup_Find
If ctr = 0 Then
    rs.Open "Delete*from tblSupplier where Supplier_ID='" & UCase(iFind) & "'", cn, 3, 3
    Set rs = Nothing
    Call grd_Data_Loader
    i_Clear.cLearMe Me
    MsgBox "Supplier with supplier ID " & iFind & " has been deleted.", vbInformation, "Inventory System"
End If
End Sub

insert record(vb 6)

Private Sub cmdSave_Click()
Dim id, fname, mname, lname, add, num, pos, emer As String
Dim rate As Integer
id = txtEmpID.Text
fname = UCase(txtFName.Text)
mname = UCase(txtMName.Text)
lname = UCase(txtLName.Text)
add = UCase(txtAddr.Text)
num = txtCnum.Text
emer = UCase(txtEmer.Text)
rate = Val(txtRate.Text)
pos = txtPosID.Text
If Trim(txtFName.Text) = "" Or Trim(txtMName.Text) = "" Or Trim(txtLName.Text) = "" _
Or Trim(txtAddr.Text) = "" Or Trim(txtCnum.Text) = "" Or Trim(txtEmer.Text) = "" _
Or Trim(txtRate.Text) = "" Or Trim(txtPosID.Text) = "" Then
MsgBox "Required Field/s missing!"

Else
  rs.Open "Insert into EMPFILE(EmpID,FName,MName,LName,Address,ContNum,IncaseEmer,Rate,PosID)" & _
    "values('" & id & "','" & fname & "','" & mname & "','" & lname & "','" & add & "','" & num & "','" & emer & "','" & rate & "','" & pos & "')", cn, 3, 3
    Set rs = Nothing
    MsgBox "New Employee information has been saved.", vbInformation, "Saved!"
    cmdNew.Enabled = True
    cmdSave.Enabled = False
    Call Clearfields
    Call grd_Data_Loader
    Frame1.Enabled = False
 End If


End Sub

module1(vb 6) w/ connections string and auto number

Option Explicit
Public cn As New ADODB.Connection
Public rs As New ADODB.Recordset
Public sql, dBase As String

Public Function connect()
Set cn = New ADODB.Connection
dBase = App.Path & "\MDbase.mdb"
cn.Open "Driver={Microsoft Access Driver (*.mdb)};dbq=" & dBase
End Function

Public Function Pos_AutoNum()
rs.Open "select * from EMPFILE Order By EmpID DESC", cn, 3, 2
If rs.RecordCount = 0 Then
    frmEmp.txtEmpID.Text = Format(Now, "myyyy")
Else
    frmEmp.txtEmpID.Text = Format(Now, "myyyy") & Format(Right(rs!EmpID, 4) + 1, "")
End If
rs.Close
End Function

Update records(php)

<?php
             include("connect.php");
            $id=$_GET['id'];
            $d = date("m/d/y");
            $jname=$_POST['jname1'];
            $loc=$_POST['loc1'];
            $compID=$_POST['compID1'];
            $descri=$_POST['descri'];
$result ="UPDATE tbl_job SET jname = '$jname', loc = '$loc', descri = '$descri', compID = '$compID', m_date='$d' WHERE jobID = '$id' ";                   
            $rs2 = mysql_query($result) or die("Invalid Query <br>$result");
            echo ' <div align="center"><strong>Jobs Successfully Updated</strong></div>';
            echo '<meta http-equiv="refresh" content="3;URL=jobs_cont.php?id='.$id.'"">';
            ?>

attach id variable(php)

<form id="form1" name="form1" method="post" action="save_sms3.php?id='.$id.'">

Destroy user session in php

<?php
session_start();
include("connect.php");
$id=$_SESSION['id'];
$result ="UPDATE tbl_user SET status = 'inactive' WHERE empID = '$id' ";                   
$rs2 = mysql_query($result) or die("Invalid Query <br>$result");
//store to test if they were log in
$old_user=$_SESSION['user'];
unset($_SESSION['user']);
session_destroy();

header('Location: ./index.php');
?>

I used this code to determined the name of the user that login in my page or if its a guest only.


<?php     
if(isset($_SESSION['fname']))

{

echo '<font face="Tahoma" size="1" color="black"><B>Welcome,&nbsp; '.$_SESSION['fname'].'&nbsp;|</B></font>&nbsp; ';
echo'<font face="Tahoma" size="1" color="black"><a href="destroysession.php" ><B>Log out</B></a></font>';
}
else
{
echo'<font face="Tahoma" size="1" color="black"><B>Welcome, Guest</B></font>';
echo'<font face="Tahoma" size="1" color="black">&nbsp;|&nbsp;<a href="reg.php"><B>Register</B></a></font>';

}
?>

delete using checkbox(php)

<?php
if(isset($_POST['delete']))
{
$checkbox = $_POST['checkbox']; //from name="checkbox[]"
$countCheck = count($_POST['checkbox']);

for($i=0;$i<$countCheck;$i++)
{
$del_id = $checkbox[$i];
$sql = "DELETE FROM tbl_absence WHERE absID='$del_id'";
$result = mysql_query($sql);
}

// if successful redirect to delete_multiple.php
if($result)
{
echo "<meta http-equiv=\"refresh\" content=\"0;URL=absent_inbox.php\">";
}

}
mysql_close();
?>

Pagenation(php)

<?php
      session_start();
      $x=0;
      $empID =  $_SESSION['id'];
      include("connect.php");
//Obtain the required page number
if (isset($_GET['pageno']))
{
   $pageno = $_GET['pageno'];
}
else
{
   $pageno = 1;
} // if
//Identify how many database rows are available
$query = "SELECT count(*) FROM tbl_absence";
$result = mysql_query($query) or trigger_error("SQL", E_USER_ERROR);
$query_data = mysql_fetch_row($result);
$numrows = $query_data[0];
//Calculate number of $lastpage
$rows_per_page = 10;
$lastpage      = ceil($numrows/$rows_per_page);
//Ensure that $pageno is within range
$pageno = (int)$pageno;
if ($pageno > $lastpage) {
   $pageno = $lastpage;
} // if
if ($pageno < 1) {
   $pageno = 1;
} // if
//Construct LIMIT clause
$limit = 'LIMIT ' .($pageno - 1) * $rows_per_page .',' .$rows_per_page;
//Issue the database query
$query = "SELECT * FROM tbl_absence where empID='$empID' ORDER BY absID DESC $limit";
$result = mysql_query($query) or trigger_error("SQL", E_USER_ERROR);

        $rs = mysql_query($query) or die("Invalid Query <br>$sql");
        $count=mysql_num_rows($rs);
        if($count==0)
        {
        echo'<br/><center><font style="font-family:Tahoma;font-size:11px;color:#990000">&nbsp;&nbsp;No Leave of Absence in your Inbox</font></center><br/>';
        }
       
       
        while($row = mysql_fetch_array($result))
        {
        $user_read=$row['user_read'];
        $reply_date=$row['reply_date'];   
        echo'<form name="form1" method="post" action="">';
        if($user_read=='y' and $reply_date!='')
        {
        echo'<table>';
        echo'<tr>';
        echo'<td width="6">&nbsp;</td>';
        echo'<td width="60" ><input name="checkbox[]" type="checkbox" id="checkbox[]" value="'.$row['absID'].'"> </td>';                       
        echo'<td width="160"><font face="Tahoma" size="1" color="black"><b><a href="absent_repcont.php?id='.$row['absID'].'"><b>'.$row['subject'].'</b></a></font></td>';
        echo'<td width="116"><font face="Tahoma" size="1" color="black"><b>'.$row['n_leave'].'</font></b></td>';   
        echo'<td width="120"><font face="Tahoma" size="1" color="black"><b>'.'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.''.$row['act'].'</font></b></td>';   
        echo'<td width="116"><font face="Tahoma" size="1" color="black"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$row['reply_date'].'</font></b></td>';   
        echo'</tr>';
        echo'</table>';
        echo'<hr align="center" width="100%"></hr>';
        }
        elseif($user_read=='n' and $reply_date!='')
        {
        echo'<table>';
        echo'<tr>';
        echo'<td width="6">&nbsp;</td>';
        echo'<td width="60" ><input name="checkbox[]" type="checkbox" id="checkbox[]" value="'.$row['absID'].'"> </td>';                       
        echo'<td width="160"><font face="Tahoma" size="1" color="black"><a href="absent_repcont.php?id='.$row['absID'].'">'.$row['subject'].'</a></font></td>';
        echo'<td width="116"><font face="Tahoma" size="1" color="black">'.$row['n_leave'].'</font></b></td>';   
        echo'<td width="120"><font face="Tahoma" size="1" color="black">'.'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.''.$row['act'].'</font></td>';   
        echo'<td width="116"><font face="Tahoma" size="1" color="black"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$row['reply_date'].'</font></td>';   
        echo'</tr>';
        echo'</table>';
        echo'<hr align="center" width="100%"></hr>';
        }
        }
        echo'<br/>';
//Construct pagination hyperlinks
if ($pageno == 1) {
   echo "  ";
} else {
   echo " <a href='{$_SERVER['PHP_SELF']}?pageno=1'><img border='0' src='images/start.jpg' height='25' width='25'/></a> ";
   $prevpage = $pageno-1;
   echo "<a href='{$_SERVER["PHP_SELF"]}?pageno=$prevpage'><img border='0' src='images/arrow_left.jpg' height='25' width='25'/></a>";
} // if
echo "  &nbsp;( Page $pageno of $lastpage ) ";
if ($pageno == $lastpage) {
   echo "";
} else {
   $nextpage = $pageno+1;
   echo "<a href='{$_SERVER['PHP_SELF']}?pageno=$nextpage'><img border='0' src='images/arrow_right.jpg' height='25' width='25'/></a>" ;
   echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$lastpage'><img border='0' src='images/end.jpg' height='25' width='25'/></a>";
} // if


?>

echo self(php)

 <form name="form6" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">

Message box(java script)

\\msgbox
if ($txtLname=='')
{
    echo'<script type="text/javascript">';
    echo'alert("Error: Last Name empty, Please fill up.")';
    echo '</script>';
}

\\clear\focus

function exist()
{
    alert("Company Description already exist");
    document.form1.txtCName.value='';
        document.form1.txtCName.focus();
}

Insert records(php)

<?php
          include("connect.php");
      if(isset($_POST['save']))
      {
            include("connect.php");
             $to=$_POST['to'];
             $from=$_POST['from'];
             $subject=$_POST['subject'];
               $ref=$_POST['ref'];
              $cont1=$_POST['cont1'];
            if($to=="" || $from=="" || $subject=="" || $ref==""|| $cont1=="" )
                   
            {
                    echo'<font style="font-family:Tahoma;font-size:11px;color:#990000">&nbsp;&nbsp;Please input all fields</font>';
                    //echo '<meta http-equiv=Refresh content=1;url=SCat.php>';
            }
            else
            {       
                               
$result = "INSERT INTO `tbl_memo` (`to`, `from`, `subject`, `date`, `refNum`, `cont1`,`rd`) VALUES ('$to', '$from', '$subject', '$d',$ref, '$cont1','n')" ;
$rs2 = mysql_query($result) or die("Invalid Query <br>$result");
                           
  echo "<meta http-equiv=\"refresh\" content=\"0;URL=memo_msg.php\">";
            }
                           
                       
                               
    }
       
?>

Start session code and include(php)

<?php
        session_start();
        include("connect.php");
        include("header.php");
        ?>  

log in code (php)

 if(isset($_POST['submit']))
{

// username and password sent from form
$user=$_POST['user'];
$pass=$_POST['pass'];
$sql="SELECT * FROM tbl_user WHERE user='$user' and pass='$pass' and type='user' ";
$result=mysql_query($sql);
// Mysql_num_row is counting table row

$count=mysql_num_rows($result);
if($count > 0)
{
 $row=mysql_fetch_object($result);
 $id = $row->empID;
 $user = $row->user;
 $pass = $row->pass;
 $type = $row->type;
 $status = $row->status;
 $_SESSION['id']=$id;
 $_SESSION['user']=$user;
 $_SESSION['pass']=$pass;
 $_SESSION['type']=$type;
 if( $status=='inactive')
 {
 $result ="UPDATE tbl_user SET status = 'active' WHERE empID = '$id' ";                   
$rs2 = mysql_query($result) or die("Invalid Query <br>$result");
 echo'<script type="text/javascript">document.location.href="login.php";</script>';
 }
 else
 {
 echo'<script type="text/javascript">';
    echo'alert("Error: Account is currently Active, Log in Faild.")';
    echo '</script>';
}
 }
 elseif(isset($_POST['reg']))
 {
 echo'<script type="text/javascript">document.location.href="reg.php";</script>';
 }
else {
echo'<font style="font-family:Tahoma;font-size:11px;color:#990000">&nbsp;&nbsp;Wrong Username or Password</font>';
}
}
?>

List records 4 records(php)

 <?php
            include("connect.php");
            $x=1;
            $sql = "SELECT * FROM tbl_memo ORDER BY id DESC";
            $rs = mysql_query($sql) or die("Invalid Query <br>$sql");
            // Mysql_num_row is counting table row
            while($row = mysql_fetch_array($rs))
            {
                if($x <= 4)
                {
                echo'<font style="font-family:Arial;font-size:12px;color:#000000">'.'<br/>To:'.' '.$row['to'].'</font><br/>';
                echo'<font style="font-family:Arial;font-size:12px;color:#000000">'.'From:'.' '.$row['from'].'</font><br/>';
                echo'<font style="font-family:Arial;font-size:12px;color:#000000">'.'Subject:'.' '.$row['subject'].'</font><br/>';
                echo'<font style="font-family:Arial;font-size:12px;color:#000000">'.'Date:'.' '.$row['date'].'</font><br/>';
                echo'<font style="font-family:Arial;font-size:12px;color:#000000">'.'Ref#:'.' '.$row['refNum'].'</font><br/>';
                echo'<font face="Tahoma" size="1" color="black"><a href="allcont1.php?id='.$row['id'].'" <B>Read more</B></a></font><br/><br/>';
                }
                $x=$x+1;
            }
        ?>

Start session and include code(php)

<?php
        session_start();
        include("connect.php");
        include("header.php");
        ?> 

Connection string to database(php,mysql)

<?php
$dbServer="localhost";
$dbUser="root";
$dbUserPwd="";
$dbName="humanresource";

$dbLink =mysql_connect($dbServer,$dbUser,$dbUserPwd) or die(mysql_error());
mysql_select_db($dbName,$dbLink);
?>

Search records(vb.net 2003)

 Public Sub search_Engine()

        Dim objRead As OleDb.OleDbDataReader
        Dim cnSQL = New OleDbConnection(con)
        cnSQL.Open()
        Try
            Dim cmd = New OleDb.OleDbCommand("SELECT * FROM tblitem WHERE itemno = '" & txtino.Text & "'", cnSQL)
            objRead = cmd.ExecuteReader
            While objRead.Read

                txtino.Text = objRead(0)
                txtdes.Text = objRead(1)
                txtunit.Text = objRead(2)
                txtUP.Text = objRead(3)

                cnSQL.Close()
                Exit Sub
            End While

Delete records(vb.net 2003)

Public Sub Delete_Item()

        oledbcon.Open()
        strSQL = "delete from tblitem where Itemno='" & txtino.Text & "'"
        Dim cmd As OleDb.OleDbCommand = oledbcon.CreateCommand
        cmd.CommandText = strSQL
        cmd.ExecuteNonQuery()
        MsgBox("1 Item Delete Successfully !", MsgBoxStyle.Information, "Delete Item")
        oledbcon.Close()

    End Sub

Update records(vb.net 2003)

Public Sub Update_Item()

        oledbcon.Open()
        strSQL = "UPDATE tblitem SET description= '" & txtdes.Text & "', Unit= '" & txtunit.Text & "',  UnitPrice= " & txtUP.Text & "  where Itemno='" & txtino.Text & "'"
        Dim cmd As OleDb.OleDbCommand = oledbcon.CreateCommand
        cmd.CommandText = strSQL

        cmd.ExecuteNonQuery()
        MsgBox("DataItem Update Successfully !", MsgBoxStyle.Information, "Update Item")
        oledbcon.Close()

    End Sub

Splash form(vb.net 2003)

 Private Sub Splash_timer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Splash_timer.Tick

        ProgressBar1.Value += 2

        If ProgressBar1.Value <= 30 Then

            Label3.Text = "Initialized Application ....."

        ElseIf ProgressBar1.Value <= 50 Then

            Label3.Text = "Loading Data Component ....."

        ElseIf ProgressBar1.Value <= 70 Then

            Label3.Text = "Integration Database ...."

        ElseIf ProgressBar1.Value <= 100 Then

            Label3.Text = "Please Wait ...."

        End If

        If ProgressBar1.Value = 100 Then

            Splash_timer.Dispose()

            Me.Visible = False

            cur = New Login

            cur.Show()

        End If
    End Sub

call PopulateListView (vb.net 2003)

Private Sub PopulateListView()
        Dim oledbcon = New OleDbConnection(con)
        Dim strSQL As String

        Dim objRead As OleDbDataReader
        Dim lv As ListViewItem

        oledbcon.Open()
        Try
            ListView1.Items.Clear()
            strSQL = "SELECT * FROM tempBilling"
            Dim cmd As New OleDbCommand(strSQL, oledbcon)
            objRead = cmd.ExecuteReader

            While objRead.Read

                lv = Me.ListView1.Items.Add(objRead("ItemID") & "")
                lv.SubItems.Add(objRead("Description") & "")
                lv.SubItems.Add(objRead("Quantity") & "")
                lv.SubItems.Add(objRead("Unit") & "")
                lv.SubItems.Add(objRead("UnitPrice") & "")
                lv.SubItems.Add(objRead("Total") & "")


            End While

            objRead.Close()

        Catch ex As Exception
            MessageBox.Show(ex.Message)
        Finally
            oledbcon.Dispose()
            oledbcon.Close()

        End Try

    End Sub

refresh listview

Private Sub RefreshForm()
        ListView1.Items.Clear()
        Call PopulateListView()
End Sub

insert record(vb.net 2003)

Private Sub AddEntry()
        Dim cnSQL = New OleDbConnection(con)
        Try
            cnSQL.Open()

strSQL = "insert into tblbilling(InvoiceNo,[Sold to],Address,tin,date,itemid,description,quantity,unit,unitprice,total,Gross,vat,[total invoice]) Values('" & txtInvoiceNo.Text & "','" & txtsold.Text & "','" & txtaddress.Text & "','" & txttin.Text & "','" & txtdate.Text & "' ,'" & txtItemID.Text & "' ,'" & txtparticulars.Text & "'," & txtquantity.Text & ",'" & txtunit.Text & "'," & txtunitcost.Text & "," & txtTa.Text & "," & txtgsp.Text & "," & txtvat.Text & "," & txttia.Text & ")"
            Dim cmSQL As New OleDbCommand(strSQL, cnSQL)
            cmSQL.ExecuteNonQuery()

Dim strSQL1 As String = "insert into tempBilling(InvoiceNo,[Sold to],Address,tin,date,itemid,description,quantity,unit,unitprice,total,Gross,vat,[total invoice]) Values('" & txtInvoiceNo.Text & "','" & txtsold.Text & "','" & txtaddress.Text & "','" & txttin.Text & "','" & txtdate.Text & "' ,'" & txtItemID.Text & "' ,'" & txtparticulars.Text & "'," & txtquantity.Text & ",'" & txtunit.Text & "'," & txtunitcost.Text & "," & txtTa.Text & "," & txtgsp.Text & "," & txtvat.Text & "," & txttia.Text & ")"

Dim cmSQL1 As New OleDbCommand(strSQL1, cnSQL)
cmSQL1.ExecuteNonQuery()
cmSQL1.Dispose()
cnSQL.Close()

 Catch Exp As OleDbException
MsgBox(Exp.Message, MsgBoxStyle.Critical, "SQL Error") ''
Catch Exp As Exception
MsgBox(Exp.Message, MsgBoxStyle.Critical, "General Error")
End Try
End Sub

This is sample codes in vb.net connecting to MS Access


1. First we create new new project then name it test



2. Add -> New Item -> Module -> Click ADD


3. In the module1 Add this code below
'import this before Module Module1
Imports System.Data.OleDb


'Add this codes below after Module Module1
'Connection String
Public con As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & "/db1.mdb;"
Public cnSQL As New OleDb.OleDbConnection

'function to open the connection
Public Sub connection_open()
       Try
            cnSQL = New OleDbConnection(con)
            cnSQL.Open()

            MsgBox("Seccesfully connected")
        Catch Exp As OleDbException
            MsgBox(Exp.Message, MsgBoxStyle.Critical, "SQL Error")

        Catch Exp As Exception
            MsgBox(Exp.Message, MsgBoxStyle.Critical, "General Error")
        End Try
    End Sub


'function to close the connection
Public Sub connection_close()
        cnSQL.Close()
        cnSQL.Dispose()
    End Sub


4.Save the project ->File - > Save all

location: D:\test then click save


5. Create new database
 
-first open MS access 2003 -> click file -> new -> click blank database in the right side bar.



 -File path->D:\test\Test\bin\Debug 
-name it db1.mdb then click create button then after creating close the database

 5. Add button to the Form1

double click the button then add the code below

 connection_open()


6. Run the Project

-Click the button. if it will pop up successfully connected means that you are now connected to the databes.