Tuesday, February 5, 2013

CSS


<link rel="stylesheet" type="text/css" href="css/Add.css" />

@charset "utf-8";
/* CSS Document */
body{
    background-color:#000;
    font-size:large;
    color:#FFF;   
}
#main{
    width:1000px;
    height:750px;
    margin:auto;
    background-color:#FFF;
}
#top_banner{
    width:1000px;
    height:155px;
}
#wrapper{
    width:1000px;
    height:560px;
    background-color: #CCC;
    text-align: left;
}
#legen{
    font-size:large;
    color:#006;s
}
#fd_set{
    border-color:#003;
    margin-left:255px;
    border-width:thick;
    }
#other{
    width:1000px;
    height:75px;
    font-size:large;
    color:#006;
   }
#bottom{
    width:1000px;
    height:35px   
    }
   

Sunday, November 11, 2012

select data

<?php
echo $_GET['id'];
?>
<?php
$start = $_GET['date'];
$end = $_GET['date1'];
$sec = $_GET['sec'];
?>
<html>
<head><title>Untitled Document</title>
</head>
<body>
<?php
$connect = mysql_connect("localhost", "root", "") or
die ("check your server connection.");
mysql_select_db("jobs");
$quey1="select * from job WHERE sec='$sec' AND date BETWEEN '$start' AND '$end' AND base='S L N S Rangala'ORDER BY date";
;
$result=mysql_query($quey1) or die(mysql_error());
?>
<table border=1 style="background-color:#FFFF;" >
<tr>
    <th>Date</th>
    <th>Base</th>
    <th>Section</th>
    <th>Received Job No</th>
    <th>Job Reg No</th>
    <th>Equipment</th>
    <th>Deffect</th>
    <th>Status</th>
    <th>Refference</th>
</tr>
<?php
    while($row=mysql_fetch_array($result)){
        //print_r($row);
?>
<tr>
    <td><?php echo $row['date']; ?></td>
    <td><?php echo $row['base']; ?></td>
    <td><?php echo $row['sec']; ?></td>
    <td><?php echo $row['rejno']; ?></td>
    <td><?php echo $row['jreno']; ?></td>
    <td><?php echo $row['equ']; ?></td>
    <td><?php echo $row['deff']; ?></td>
    <td><?php echo $row['sta']; ?></td>
    <td><?php echo $row['ee']; ?></td>           
</tr>
<?php
    }
?>
</table>
</body>
</html>





<html>
<head>
<title>Untitled Document</title>
</head>
<body>
<form action="rangala.php" method="get">


<table>
                <tr>
          <td>Section </td>
          <td>        
            <select name="sec">
              <option> </option>
              <option>R/W/S/(A/V)</option>
              <option>R/W/S/(Radio)</option>                   
            </select>         
          </td>
           </tr>
        <tr>
          <td>&nbsp;</td>
          <td><input type="submit" value="View Prograss" /><input type="reset" value="Cancel" /></td>
        </tr>
</table>
</form>
</body>
</html>

update php form

category.php
<html>
<head>
<title>Untitled Document</title>
</head>
<body>
<ul>
<li><a href="update.php" float:right>Job Entry Form</a></li><li><a href="enter.php" float:right>Job Progress Update Form</a></li>
</ul>
</body>
</html> 



 config.php
<?php
$host = "localhost"; //database location
$user = "root"; //database username
$pass = ""; //database password
$db_name = "jobs"; //database name
//database connection
$link = mysql_connect($host, $user, $pass);
mysql_select_db($db_name);
//sets encoding to utf8
mysql_query("SET NAMES utf8");
?>


update.php
<html>
<head>
<title>Untitled Document</title>
</head>
<body>
<a href="category.php">category>></a><a href="update.php">enter>></a>
<?php
$id=$_GET['id'];
if(is_null($id))
$id=-1;
$_SESSION['id']=$id;
?>

<form action= "dbupdate.php" method="post" >
<center>
    <h2> Job Entry Form</h2><?php
    if($id==-1)
    {
   print "<table width=\"381\" border=\"0\">
     
      <tr>
        <td>Equipment</td>
        <td><input type=\"text\" name=\"equ\" id=\"equ\" /></td>
      </tr>
      <tr>
        <td>Deffect</td>
        <td><textarea name=\"deff\" id=\"deff\" cols=\"45\" rows=\"2\"></textarea></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td><input type=\"submit\" value=\"Enter\" />
        <input type=\"reset\" value=\"Cancel\" /></td>
      </tr>
    </table>
    ";
    }
    else {
$connect = mysql_connect("localhost", "root", "") or
die ("check your server connection.");
mysql_select_db("jobs");
    $result=mysql_query("select * from job where id=".$id);
    while($row=mysql_fetch_array($result)){
        print "<table width=\"381\" border=\"1\">
     
      <tr>
        <td>Equipment</td>
        <td><input type=\"text\" name=\"equ\" id=\"equ\"  value=\""; echo $row['equ']; print "\"/></td>
      </tr>
      <tr>
        <td>Deffect</td>
        <td><textarea name=\"deff\" id=\"deff\" cols=\"45\" rows=\"2\">"; echo $row['deff']; print "</textarea></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td><input type=\"submit\" value=\"Save\" />
        <input type=\"reset\" value=\"Cancel\" /></td>
      </tr>
    </table>
    ";
    }
    }
    ?>
</form>
</body>
</html>



dbupdate.php
<?php
session_start();

$equ = $_POST['equ'];
$deff = $_POST['deff'];

include 'config.php';
$id=$_SESSION['id'];
if($id==-1)
{
mysql_query("INSERT INTO `jobs`.`job`( equ, deff) VALUES ( '$equ','$deff')");
$job_id = mysql_insert_id();
}
else{
mysql_query("UPDATE `jobs`.`job` SET equ='$equ',deff='$deff' WHERE id=$id");   
}
echo "ok";
?>


enter.php
<?php
echo $_GET['id'];
?>
<html>
<head>
<title>Update</title>
</head>
<body>
<a href="category.php">category>></a><a href="enter.php">update>></a>
<?php
$connect = mysql_connect("localhost", "root", "") or
die ("check your server connection.");
mysql_select_db("jobs");
$quey1="select * from job ORDER BY id";
$result=mysql_query($quey1) or die(mysql_error());
?>
<table border=1 style="background-color:#FFFF;" >
<tr>   
    <th>Equipment</th>
    <th>Deffect</th>
    <th>Edit</th>
    <th>Delete</th>
</tr>
<?php
    while($row=mysql_fetch_array($result)){
        //print_r($row);
?>
<tr>   
    <td><?php echo $row['equ']; ?></td>
    <td><?php echo $row['deff']; ?></td>
    <td><a href="update.php?id=<?php echo $row['id']; echo $row['edit']; ?>">Edit</a></td>       
    <td><a href="edit.php?id=<?php echo $row['id']; echo $row['delete']; ?>">Delete</a></td>       
</tr>
<?php
    }
?>
</table>
</body>
</html>




edit.php

<html>
<head>
<title>Delete a Record from MySQL Database</title>
</head>
<body>
<?php
include 'config.php';
$id = $_GET['id'];
mysql_select_db('jobs');
mysql_query("DELETE `jobs`.`job` SET equ='$equ',deff='$deff' WHERE id=$id");

$retval = mysql_query( $sql, $link );
if(! $retval )
{
  die('Could not delete data: ' . mysql_error());
}
echo "Deleted data successfully";
mysql_close($link);

?>
</body>
</html>

Saturday, November 10, 2012

php form action

config.php
<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$dbname = 'Persons';
?>


opendb.php
<?php
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if (!$conn)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db($dbname);
?>



closedb.php
<?php
mysql_close($conn);
?>



insert.php
 <?php
$firstname=$_POST['firstname'];
$lastname=$_POST['lastname'];
$age=$_POST['age'];
$phpto=$_POST['photo'];

include 'config.php';
include 'opendb.php';

$sql="INSERT INTO Persons (FirstName, LastName, Age, Photo)
VALUES('$firstname','$lastname','$age','$photo')";

if (!mysql_query($sql,$conn))
  {
  die('Error: ' . mysql_error());
  }
echo "1 record added";

include 'closedb.php';
?>




person.php
<html>
<body>

<form action="insert.php" method="post">
Firstname: <input type="text" name="firstname" /><br/>
Lastname: <input type="text" name="lastname" /><br/>
Age: <input type="text" name="age" /><br/>
photo : <input type="file" name="photo"><br/>
<input type="submit" />
</form>

</body>
</html> 

upload immage using php

upload.php

<?php
if(isset($_POST['upload']) && $_FILES['userfile']['size'] > 0)
{
$fileName = $_FILES['userfile']['name'];
$tmpName  = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];

$fp      = fopen($tmpName, 'r');
$content = fread($fp, filesize($tmpName));
$content = addslashes($content);
fclose($fp);

if(!get_magic_quotes_gpc())
{
    $fileName = addslashes($fileName);
}

include 'config.php';
include 'opendb.php';

$query = "INSERT INTO upload (name, size, type, content ) ".
"VALUES ('$fileName', '$fileSize', '$fileType', '$content')";

mysql_query($query) or die('Error, query failed');
include 'closedb.php';

echo "File $fileName uploaded";
}
?>
<form method="post" enctype="multipart/form-data">
<table width="350" border="0" cellpadding="1" cellspacing="1" class="box">
<tr>
<td width="246">
<input type="hidden" name="MAX_FILE_SIZE" value="2000000">
<input name="userfile" type="file" id="userfile">
</td>
<td width="80"><input name="upload" type="submit" class="box" id="upload" value=" Upload "></td>
</tr>
</table>
</form>




config.php
<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$dbname = 'image_db';
?>



opendb.php
<?php
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to mysql');
mysql_select_db($dbname);
?>


closedb.php
<?php
mysql_close($conn);
?>

php Login

login.php

<?php
session_start();
if($_SESSION['user']=="Please Enter a Valid User Name"){
echo $_SESSION['user'];
}
else if($_SESSION['status']=="admin"){
    header('Location:login.php');       
}

?>
<html>
<head>
<title>Login</title>
</head>
<body>
User Login
<form method="post" action="logindb.php">
Username : <input type="text" name="uname"/>
Password : <input type="password" name="pword"/>
<input type="submit" value="Login" /><br/>
</form>
</body>
</html>   



Login database

<?php
$uname=$_POST['uname'];
$pword=$_POST['pword'];

mysql_connect("localhost","root","");
    mysql_select_db("test1");

    $query = "SELECT * FROM user WHERE username = '$uname' AND password = '$pword'";
    $result = mysql_query($query);

    if(mysql_num_rows($result)==1){
        $row = mysql_fetch_array($result);
        $name=$row['username'];
        $status=$row['status'];
   
    if($status=="admin"){
    session_start();
    $_SESSION['user']=$name;
    $_SESSION['status']=$status;
    header('Location:cat.php');   
    }
    }
    else{
    session_start();
    $_SESSION['user']="Please Enter a Valid User Name";
    header('Location:login.php');   
    }
?>




cat.php
<?php
session_start();
if($_SESSION['user']==''){
header("Location:login.php");   
}
?>
<html>
<head>
<title>cat</title>
</head>
<body>
<a href="cat.php">cat>></a>
<?php
echo "Welcome ".$_SESSION['user'];
?>
<a href="logout.php">Logout</a>
<ul>
<li><a href="update.php" float:right>update</a></li>
<li><a href="enter.php" float:right>Enter</a></li>
</ul>
</body>
</html>   



logout.php
<?php
session_start();
session_destroy();
header ('Location:login.php');
?>

Tuesday, November 6, 2012

ubuntu basic

Installing Apache, PHP, MySQL and phpMyAdmin on Ubuntu 8.10

[Note: In this post I'll be showing how to install Apache, php, MySQL and phpMyAdmin (one by one) on Ubuntu 8.10 using Terminal. If you want to install them all at the same time with minimal fuss, I recommend you to read my post on installing LAMP.]
Installing Apache
1. Open Terminal (Application -> Accessories -> Terminal) and execute the following command:
sudo apt-get install apache2
2. When the setup is complete you can check if the Apache is working properly by pointing your browser to http://localhost. If you see the text “It works!”, it means Apache is working just fine.
3. Towards the end of the installation if you see a message like this inside Terminal, “Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName“, you can fix this by executing the following command. It will open Gedit (text editor).
gksu gedit /etc/apache2/conf.d/fqdn
4. When Gedit opens, type “ServerName localhost” inside the file and click Save. Then close the file.
Installing php5
1. Inside Terminal, execute the following command:
sudo apt-get install php5 libapache2-mod-php5
2. When setup is complete, you have to restart Apache so that php5 will work on Apache. Execute the following command in Terminal:
sudo /etc/init.d/apache2 restart
3. You can now test to see if php5 works with Apache. To do this you can create a new php file inside your /var/www/ folder. (The text in red is the filename. You can put any name.)
sudo gedit /var/www/nass.php
4. The command above will open Gedit. Just type in the following php code, save and close the file:
<? phpInfo(); ?>
5. Now point your browser to “http://localhost/nass.php” and see if you can see the text “yoo hooo!” and a lot of information about your php5 installation. If you see that, it means your have successfully installed php5.
Installing MySQL
1. Inside Terminal, execute the following command:
sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql
2. Towards the end of the installation you will be prompted to set your root or admin password (see pic below)
set root password
Installing phpMyAdmin
1. Inside Terminal, execute the following command:
sudo apt-get install phpmyadmin
2 During the installation you will be asked to select the webserver that would be used to run phpMyAdmin. Select Apache2 (see pic below).
choosing webserver
3. After the installation is over execute the following command to copy the phpmyadmin folder into the /var/www/ directory. (By default it is installed in /usr/share/phpmyadmin/ directory.)
sudo ln -s /usr/share/phpmyadmin/ /var/www/phpmyadmin
4. Now you can go to the phpMyAdmin login page by pointing your browser to: http://localhost/phpmyadmin/index.php
The username for MySQL and phpMyAdmin is “root”. The password will be what you set in step 2 (under installing MySQL).
That’s it! Now you’ve successfully installed Apache 2 webserver, php5, MySQL and phpMyAdmin on Ubuntu.


finding apache(PHP) errors code in linux
tail -f /var/log/apache2/error.lo


finding mysql errors

sudo vi /etc/mysql/my.cnf

uncomment
      general_log_file        = /var/log/mysql/mysql.log
      general_log             = 1
      log_error                = /var/log/mysql/error.log

restart mysql
      sudo service mysql restart

tail -f /var/log/mysql/mysql.log to voew the mysql errors