Monday, September 26, 2016

php Demo

Config code
==========
<?php
mysql_connect("localhost","root","");
mysql_select_db("studentreg");
?>


===============================================
Index
============


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Student Info.</title>
</head>

<body>
<?php
if(isset($_REQUEST['demo'])=="insret")
{
echo "Record Insert Successfully";
}

?>

<form method="post" action="insert.php" enctype="multipart/form-data">
<h1 style="color:#990000" align="center">Student Registration Form<h1>

<table align="center">
<tr>
<td width="150px" style="font-size:24px; color:#333333" align="right">Name:</td>
<td><input type="text" size="40px" name="name" style="border-color:#9999FF"/></td>
</tr>

<tr>
<td width="150px" style="font-size:24px; color:#333333" align="right">Address:</td>
<td><input type="text" size="40px" name="address" style="border-color:#9999FF"/></td>
</tr>

<tr>
<td width="150px" style="font-size:24px; color:#333333" align="right">Roll No:</td>
<td><input type="text" size="40px" name="number" style="border-color:#9999FF"/></td>
</tr>

<tr>
<td width="150px" style="font-size:24px; color:#333333" align="right">E-mail Id:</td>
<td><input type="text" size="40px" name="EmailId" style="border-color:#9999FF"/></td>
</tr>

<tr>
<td width="150px" style="font-size:24px; color:#333333" align="right">Mo. No:</td>
<td><input type="text" size="40px" name="monumber" style="border-color:#9999FF"/></td>
</tr>

<tr>
        <td width="150px" style="align:right; font-size:24px; color:#333333; text-align:right">State:</td>
            <td width="300px"><select name="state" id="state" title="state">
            <option name="Plz select" value="0">Plz Select State</option>
                                <option>Gujarat</option>
                                <option>Delhi</option>
                                <option>Mumbai</option>
                                </select></td>
         
                </tr>



<tr>
      <td width="150px" style="text-align:right; font-size:24px; color:#333333">Gender:</td>
        <td width="100px" style="text-align:left; font-size:14px">
        <input type="radio" name="radiobtn"  value="male" checked="checked" style="font-size:12px"/>Male
        <input type="radio" name="radiobtn"  value="female"  />Female
   </td>
</tr>

<tr>
        <td width="150px" style="text-align:right; font-size:24px; color:#333333">Hobbies:</td>
            <td width="100px" style="text-align:left; font-size:14px">
            Reading:<input type="checkbox" name="chkbox[]"  value="reading"/>
            Writing: <input type="checkbox" name="chkbox[]"  value="writing"  />
            </td>
         
</tr>

<tr>
        <td width="150px" style="text-align:right;font-size:24px;color:#333333">Photo:</td>
            <td width="100px"><input type="file" name="file"/></td>
         
</tr>

<tr>
<td colspan="2" align="center"><input type="submit" value="submit" name="btnsubmit"/>
</td>
</tr>
</table>

</form>
<br /><br />


<?php
include 'config.php';
$sql=mysql_query("select * from data");
?>

<table align="center" border="1">
<tr>
    <th style="color:#666666; font-size:15px">Id</th>
    <th style="color:#666666; font-size:15px">Name</th>
    <th style="color:#666666; font-size:15px">Address</th>
    <th style="color:#666666; font-size:15px">Roll No.</th>
     <th style="color:#666666; font-size:15px">E-mail ID</th>
    <th style="color:#666666; font-size:15px">Mobile No.</th>
    <th style="color:#666666; font-size:15px">State</th>
    <th style="color:#666666; font-size:15px">Gender</th>
    <th style="color:#666666; font-size:15px">Hobby</th>
    <th style="color:#666666; font-size:15px">Photo</th>
    <th style="color:#666666; font-size:15px">Edit</th>
    <th style="color:#666666; font-size:15px">Delete</th>
 
 
</tr>

<?php
while($row=mysql_fetch_array($sql))
{
?>

<tr align="left" style="font-size:14px; color:#006699">

<td><?php echo $row[0]; ?></td>
<td><?php echo $row[1]; ?></td>
<td><?php echo $row[2]; ?></td>
<td><?php echo $row[3]; ?></td>
<td><?php echo $row[4]; ?></td>
<td><?php echo $row[5]; ?></td>
<td><?php echo $row[6]; ?></td>
<td><?php echo $row[7]; ?></td>
<td><?php echo $row[8]; ?></td>

<td><img src="upload/<?php echo $row[9];?>" width="50" height="50" /></td>
<td><a href="edit.php?id=<?php echo $row[0]; ?>">Edit</a></td>
<td><a href="delete.php?id=<?php echo $row[0]; ?>">delete</a></td>

</tr>

<?Php
}
?>


</body>
</html>

========================================================================

Insert
==========
<?php
include 'config.php';

if(isset($_POST['btnsubmit']))
{
$name=$_POST['name'];
$address=$_POST['address'];
$number=$_POST['number'];
$EmailId=$_POST['EmailId'];
$monumber=$_POST['monumber'];
$state=$_POST['state'];
$radiobtn=$_POST['radiobtn'];
$hobby=implode(",",$_POST['chkbox']);
$fname=$_FILES['file']['name'];
$ftmpname=$_FILES['file']['tmp_name'];
move_uploaded_file($ftmpname,'upload/' .$fname);
$sql=("insert into data (name,address,rollno,emailid,mobno,state,gender,hobby,photo)values('$name','$address','$number','$EmailId','$monumber','$state','$radiobtn','$hobby','$fname')");
mysql_query($sql);
echo "<script>alert('added successfully')</script>";
header('location:index.php?demo=insert');


}
?>


===========================================================

delete
============
<?php
include 'config.php';
$id=$_REQUEST['id'];
mysql_query("delete from data where id='$id'");
header('location:index.php');
?>

=======================================================
edit
====
<!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" />
<title>Untitled Document</title>
</head>

<body>
<?php
include 'config.php';
$id=$_REQUEST['id'];
$sql=mysql_query("select * from data where id='$id'");

while($row=mysql_fetch_array($sql))
{
$id=$row[0];
        $name=$row[1];
        $address=$row[2];
        $rollno=$row[3];
        $emailid=$row[4];
$mobileno=$row[5];
        $state=$row[6];
        $gender=$row[7];
        $hobby=explode(",",$row[8]);
        $photo=$row[9];
        
}
if(isset($_POST['btnsubmit']))
{
$name1=$_POST['name'];
$address1=$_POST['address'];
$rollno1=$_POST['number'];
$emailid1=$_POST['EmailId'];
$mobileno1=$_POST['monumber'];
$state1=$_POST['state'];
$gender1=$_POST['rbt'];
$hobby1=implode(",",$_POST['chkbox']);
if($_FILES['file']['name'] !=""){
$filename1=$_FILES['file']['name'];
}
$filetmpname1=$_FILES['file']['tmp_name'];
move_uploaded_file($filetmpname1,"upload/".$filename1);
mysql_query("update data set name='$name1',address='$address1',rollno='$rollno1',emailid='$emailid1',mobno='$mobileno1',state='$state1',gender='$gender1',hobby='$hobby1',photo='$filename1'
where id='$id'");
header('location:index.php');
}
?>
<form method="post" action="" enctype="multipart/form-data">
<h1 style="color:#990000" align="center">Student Registration Form<h1>

<table align="center">
<tr>
<td width="150px" style="font-size:24px; color:#333333" align="right">Name:</td>
<td><input type="text" size="40px" name="name" style="border-color:#9999FF" value="<?php echo $name; ?>"/></td>
</tr>

<tr>
<td width="150px" style="font-size:24px; color:#333333" align="right">Address:</td>
<td><input type="text" size="40px" name="address" style="border-color:#9999FF" value="<?php echo $address; ?>"/></td>
</tr>

<tr>
<td width="150px" style="font-size:24px; color:#333333" align="right">Roll No:</td>
<td><input type="text" size="40px" name="number" style="border-color:#9999FF" value="<?php echo $rollno; ?>"/></td>
</tr>
<tr>
<td width="150px" style="font-size:24px; color:#333333" align="right">E-mail Id:</td>
<td><input type="text" size="40px" name="EmailId" style="border-color:#9999FF" value="<?php echo $emailid; ?>"/></td>
</tr>

<tr>
<td width="150px" style="font-size:24px; color:#333333" align="right">Mo. No:</td>
<td><input type="text" size="40px" name="monumber" style="border-color:#9999FF" value="<?php echo $mobileno; ?>"/></td>
</tr>

<tr>
<td width="150px" style="align:right; font-size:24px; color:#333333; text-align:right">State:</td>
<td width="300px"><select name="state" id="state" title="state">
            <option name="Plz select" value="0">Plz Select State</option>
                                <option <?php if($state=="Gujarat"){echo 'selected';}?>>Gujarat</option>
                                <option <?php if($state=="Delhi"){echo 'selected';}?>>Delhi</option>
                                <option <?php if($state=="Mumbai"){echo 'selected';}?>>Mumbai</option>
                                </select></td>
</tr>



<tr>
<td width="150px" style="text-align:right; font-size:24px; color:#333333">Gender:</td>
<td width="100px" style="text-align:left; font-size:14px">
<input type="radio" name="rbt"  value="male" style="font-size:12px" <?php if($gender=="male"){ echo 'checked'; }?>/>Male
<input type="radio" name="rbt"  value="female"  <?php if($gender=="female"){ echo 'checked'; }?>/>Female
</td>
</tr>

<tr>
        <td width="150px" style="text-align:right; font-size:24px; color:#333333">Hobbies:</td>
            <td width="100px" style="text-align:left; font-size:14px">
            Reading:<input type="checkbox" name="chkbox[]"  value="reading" <?php if(in_array("reading",$hobby)){echo 'checked';}?>/>
            Writing: <input type="checkbox" name="chkbox[]"  value="writing" <?php if(in_array("writing",$hobby)){echo 'checked';}?> />
            </td>
            
</tr>

<tr>
        <td width="150px" style="text-align:right;font-size:24px;color:#333333">Photo:</td>
            <td width="100px"><input type="file" name="file"/></td>
            
<td><img src="upload/<?php echo $photo;?>" width="50" height="50" /></td>
</tr>

<tr>
<td colspan="2" align="center"><input type="submit" value="submit" name="btnsubmit"/>
</td>
</tr>
</table>

</form>
</body>
</html>

Wednesday, February 24, 2016

What Is Tokens


   >>> The Smallest individual units in a program are known as tokens. Tokens ate usually separated by "white space."

   C++ has the following tokens:

    >>> Keywords.
    >>> Identifiers.
    >>> Constants.
    >>> Strings.
    >>> Operators.

  A C++ program is written using tokens, white spaces and the syntax of the language.


    Example:

                  a = i + + + j;

                 The Programmer who wrote the code might have intended either of these two statements:


                a = i + (+ + j)

                a = (i + +) + j

     



Saturday, January 9, 2016

What Is Object Oriented System In CPP


Please Friends Watch This Video And Subscribe My You Tube Channel...

Tuesday, December 29, 2015

Example 5 : Demo Of Cin And Cout.


   >>> Example 5 : Demo Of Cin And Cout.

           #include<iostream.h>
           #include<conio.h>

           void main()

                   {

                     int a=0,b=0,c=0;

                     clrscr();

                     cout << "Enter a and b ->";
                     cind >> a >> b;

                     c = a + b;
                     cout << "\n Ans = "<<c;

                     getch();

                    }

   >>> Output :

           Enter a and b -> 5 6
           Ans = 11

Standard Input ( cin )



   >>> The standard input device is usually the keyboard.

   >>> Cout is used in conjunction with the >>. The operator  >> is known as extraction or get-from operator. The operator must be followed by the variable that will store the data that is going to be extracted from the stream.

   >>> Cin is an object, predefined in C++ to correspond to the standard input stream. This stream represents data coming from the keyboard.

   >>> The >> takes the value from the stream object on its left $ places in the variable on its right.

   >>> For example :

                                int age;
                                cind >> age;

   >>> The first statement declares a variable of type int called age and the second one waits for an input from cin ( the keyboard) in order to store it in this integer variable.

   >>> Cin is an object, predefined in C++ to correspond to the standard input stream. This stream represents data coming from the keyboard.

   >>> The >> takes the value from the stream object on its left $ places in the variable on its right.

   >>> For example:

                              int age;
                              cin >> age;

   >>> The first statement declares a variable of type int called age, and the second one waits for an inputs from cin (the keyboard) in order to store it in this integer variable.

   >>> Cin can only process the input from the keyboard once the RETURN key has been pressed. Therefore, even if you request a single character the extraction from cin will not process the input until the used presses RETURN after the character has been introduced.

   >>> You must always consider the type of the variable that you are using as a container with cin  extractions. If you request an integer you will get an integer, if you request a character you will get a character and if you request a string of characters you will get a string of characters.

   >>> You can also use cin to request more than one datum input from the user:

                           cin >> a >> b;

                     is equivalent to :

                            cin >> a;
                            cin >> b;

   >>> In both cases the user must give two data, one for variable a and another one for variable b that may be separated by any valid blank separator: a space, a tab character or a newline.

                                 

                  

Example 4 : Print Simple Number With It's Square.


   >>> Example 4 : Print Simple Number With It's Square.

           #include<iostream.h>

            int main(void)
                 
                  {

                      double x = 0.0;

                       // it's good practice to initialize all variables by assigning a value.

                       cout << " Please enter a number: ";
                       cin >> x;

                        cout << " You Entered " << x <<', whose square is " << x*x << endl;

                         return 0;
               
                     }

   

Example 3 : Print Table Of 5.


   >>> Example 3 : Print Table Of 5.

           #inlcude<iostream.h>
           #inlcude<conio.h>
           #define N 10

            void main()
                     
                     {
                       int i,a=5;

                       clrscr();
         
                        for(i=1;i<=n;i++)
                           
                               {
 
                                  cout<<a<<" X "<<i<<" = "<<a*i<<'\n";
                 
                               }
                   
                       getch();

                      }

      >>> Output:

                           5 * 1 = 5
                           5 * 2 = 10
                           5 * 3 = 15
                           5 * 4 = 20
                           5 * 5 = 25
                           5 * 6 = 30
                           5 * 7 = 35
                           5 * 8 = 40
                           5 * 9 = 45
                           5 * 10 = 50