• No results found

Sample Code with Output

N/A
N/A
Protected

Academic year: 2021

Share "Sample Code with Output"

Copied!
7
0
0

Loading.... (view fulltext now)

Full text

(1)

Sample Code with Output

Code :        fileupload.html <html>  <head>  <title>opensofttraining.com</title>  <style type="text/css">  #menu a  {  color:red;  }  #content  {  text­align:left;  color:black;  }  #italictext  {  font­style:italic;  }    </style>  </head>  <body background="body­bg.gif">    <img src="../BookStore.jpg" width="100%" height="40%"></img>    <div id="menu" align="center">  <a href="#">Home</a> |

File Upload :

(2)

      <a href="#">Engineering</a> |  <a href="#">Medicine</a> |  <a href="#">Law</a> |  <a href="#">Management</a> |  <a href="#">Contact</a> |  <a href="#">About Us</a>  </div> <br>  <div id="content"><b>    <form enctype="multipart/form­data" action="add.php" method="POST">    Name: <input type="text" name="name"><br>    E­mail: <input type="text" name = "email"><br>    Phone: <input type="text" name = "phone"><br>    Photo: <input type="file" name="photo"><br> <input type="submit" value="Add">    </form>    </div>  </body>  </html>  add.php  <html>  <head>  <title>opensofttraining.com</title>  <style type="text/css">  #menu a  {  color:red;  }  #content  {  text­align:left;  color:black;  }  #italictext {  font­style:italic;  }  </style>  </head>  <body background="body­bg.gif"> 

(3)

 

    

       Code :        <img src="../BookStore.jpg" width="100%" height="40%"></img>  <div id="menu" align="center">  <a href="#">Home</a> |  <a href="#">Engineering</a> |  <a href="#">Medicine</a> |  <a href="#">Law</a> |  <a href="#">Management</a> |  <a href="#">Contact</a> |  <a href="#">About Us</a>  </div> <br>  <div id="content"><b>  <?php     //This is the directory where images will be saved     $target = "images/";     $target = $target . basename( $_FILES['photo']['name']);     //This gets all the other information from the form     $name=$_POST['name'];     $email=$_POST['email']; $phone=$_POST['phone'];     $pic=($_FILES['photo']['name']);     // Connects to your Database     mysql_connect("localhost", "root", "chennai123") or die(mysql_error()) ;     mysql_select_db("test") or die(mysql_error()) ;  //Writes the information to the database     mysql_query("INSERT INTO employees(name,eamil,phone,path) VALUES ('$name', '$email', '$phone', '$pic')") ;     //Writes the photo to the server     if(move_uploaded_file($_FILES['photo']['tmp_name'], $target))     {    //Tells you if its all ok 

(4)

echo "The file ". basename( $_FILES['uploadedfile']['name']).  " has been uploaded, and your information has been  added to the directory";     }     else     {      //Gives and error if its not     echo "Sorry, there was a problem uploading your file.";     }     ?>  </div>  </body>  </html> view.php <html>  <head>  <title>opensofttraining.com</title>  <style type="text/css">  #menu a  {  color:red;  }  #content  {  text­align:left;  color:black;  }  #italictext  {  font­style:italic;  }  </style>  </head>  <body background="body­bg.gif">  <img src="../BookStore.jpg" width="100%" height="40%"></img>  <div id="menu" align="center"> <img src="../BookStore.jpg" width="100%"

(5)

      Code :         height="40%"></img>  <div id="menu" align="center">  <a href="#">Home</a> |  <a href="#">Engineering</a> |  <a href="#">Medicine</a> |  <a href="#">Law</a> |  <a href="#">Management</a> |  <a href="#">Contact</a> |  <a href="#">About Us</a>  </div> <br>  <div id="content"><b>  <?php     //This is the directory where images will be saved     $target = "images/";     $target = $target . basename( $_FILES['photo']['name']);     //This gets all the other information from the form     $name=$_POST['name'];     $email=$_POST['email']; $phone=$_POST['phone'];     $pic=($_FILES['photo']['name']);     // Connects to your Database     mysql_connect("localhost", "root", "chennai123") or die(mysql_error()) ;     mysql_select_db("test") or die(mysql_error()) ;  //Writes the information to the database     mysql_query("INSERT INTO employees(name,eamil,phone,path)        VALUES ('$name', '$email', '$phone', '$pic')") ;     //Writes the photo to the server     if(move_uploaded_file($_FILES['photo']['tmp_name'], $target))    {    //Tells you if its all ok 

(6)

Code :  echo "The file ". basename( $_FILES['uploadedfile']['name']).  " has been uploaded, and your information has been  added to the directory";     }     else     {   //Gives and error if its not     echo "Sorry, there was a problem uploading your file.";     }     ?>  </div>  </body>  </html> view.php <html>  <head>  <title>opensofttraining.com</title>  <style type="text/css">  #menu a  {  color:red;  }  #content  {  text­align:left;  color:black;  }  #italictext  {  font­style:italic;  }  </style>  </head>  <body background="body­bg.gif">  <img src="../BookStore.jpg" width="100% <a href="#">Home</a> |

(7)

Code :  <a href="#">Engineering</a> |  <a href="#">Medicine</a> |  <a href="#">Law</a> |  <a href="#">Management</a> |  <a href="#">Contact</a> |  <a href="#">About Us</a>  </div>  <br>  <div id="content"><b>  <?php    // Connects to your Database     mysql_connect("localhost", "root", "") or die(mysql_error()) ;    mysql_select_db("test") or die(mysql_error()) ;   //Retrieves data from MySQL    $data = mysql_query("SELECT * FROM employees") or die(mysql_error());  //Puts it into an array  while($info = mysql_fetch_array( $data ))    {  //Outputs the image and other data  echo "<img src=http://localhost/fileupload/images/".$info['photo'] ."> <br>";  echo "<b>Name:</b> ".$info['name'] . "<br> ";  echo "<b>Email:</b> ".$info['email'] . " <br>";  echo "<b>Phone:</b> ".$info['phone'] . " <hr>";  }  ?>  </div>  </body>  </html>

References

Related documents

The Himalayas are the highest mountain range in the world and form a large part of India’s northern border?. Actually, more of the Himalayas lie in the nation

To that end, we compute the RMSE for the pre- and post-1988 subsamples for all four model discussed: univariate (inflation) BAR, bivariate (inflation, money growth), trivariate

I think that, throughout the last week, I have displayed all of the qualities present in the Code of Chivalry. I believe that modern society would benefit if others followed the

This sample code may be also applied on EK-H4 – and with debugging hard and software it may be modified and adapted.. This function polls every 10ms until // measurement

Diagnostic tests or radiology services submitted with a place of service outside of the office setting should be reported using the appropriate professional component

• Passive Sharing--a Facebook app that automatically posts video viewing information to your users’ timelines, without requiring them to click Share..

Analytical Testing Lab Report Number: 21-109-0004 Client Project Description: Allen Middle School Project Number: GCS-001.. Dear Christine Schaefer: Waypoint Analytical, LLC

public void actionPerformed(ActionEvent e) { // if integers is selected and not valid input if( integers.isSelected() &amp;&amp;