3º ESO - Tecnología ESO en Ingles https://www.petervaldivia.com Sección Bilingüe de Tecnología en Inglés Wed, 28 Jan 2015 17:21:19 +0000 en-GB hourly 1 https://wordpress.org/?v=6.4.3 Php Delete https://www.petervaldivia.com/delete/ Sun, 25 Jan 2015 10:31:18 +0000 http://www.petervaldivia.com/?p=334 Php Listing Modify Delete     Deleting a record in a Mysql database.   The object we wished to sell has been sold and it’s time to delete the announcement so that people stop calling us. To do this we have to undertake three tasks. 1st Delete the record from the database 2nd Delete the […]

The post Php Delete first appeared on Tecnología ESO en Ingles.

]]>

 

 

Deleting a record in a Mysql database.

 

The object we wished to sell has been sold and it’s time to delete the announcement so that people stop calling us. To do this we have to undertake three tasks.
1st Delete the record from the database
2nd Delete the big photo from the appropriate folder.
3º Delete the small photo that was in the thumbs folder.
To do this you have to use the appropriate php instructions, as always!
Let’s start with

How to delete a record in Mysql

If there is an instruction in PHP for adding records (a collection of data) then there will also be instructions for making changes to and deleting a records. In this case we’re going to see how to delete a record and then how to make changes to one. To delete we use:
The first line is the the entry line used so that a certain piece of code is executed and it tells us that if the variable erasead appears then it should execute what appears in the braces. this instruction is isset..
In the form there is a button whose name receives the erasead value. In the form, there is a button called erasead. If it is pressed then a variable with the value $_POST[‘erasead’] appears. The first instruction simply verifies that this variable exists in the code (because it’s been created when we clicked on the button)

if(isset($_POST[‘erasead’]) ){

The first thing we have to do is delete the photo that has been saved in the appropriate folder. We can’t delete an announcement and leave the photo because we would fill up the server with obsolete photos. We have to delete them and it’s the first thing we should do.
The function we must use is unlink (). This instruction deletes the file that appears in brackets. As the route where the photo is saved has been registered in one of the fields, the field _9, we haveto see what it’s been called. To do this we create the variable $foto like this.

$foto = $row[‘field_9’];

// se borra del la carpeta
unlink ($foto);

Now we can delete the record and to do this we have to do a mysql_query with the following information -> DELETE FROM board WHERE id=$id. This tells us to delete the record with the identifier id given by the variable $id from the board. This last variable $id is taken from a previous consultation that you can see below where we see the full code

// ahora el registro
$sql = “DELETE FROM board WHERE id=$id”;
$result = mysql_query($sql);
echo “Anuncio borrado”;

We’ve now deleted the whole advert. But this always happens whenever we push the delete button. But what happens if we only want to change one value, for example, the price of the object?
To make changes in the announcement we have to follow a similar procedure but, in this case, we have to show the full announcement on the page and write in the field we wish to change, in this case, the object’s price.
When this page opens it shows all the ID fields corresponding to this entry. Then an UPDATE instruction will appear which is what is responsible for actualising all the fields with the information that we change in the form. This is what it looks like in a simplified form.

$sqlUpdate = mysql_query(“UPDATE board SET field_1 = ‘$nombre’, field_2 = ‘$apellidos’, field_3 = ‘$email’,
field_4 = ‘$password’, field_5 = ‘$telephone’, field_6 = ‘$object’,
field_7 = ‘$message’, field_8 = ‘$title’, field_9 = ‘$photo’
, field_10 = ‘$today’, field_11 = ‘$prices’

WHERE field_3 = ‘$email'”, $link) ;

This instruction causes us to look inside the table ‘board’ for a record where field three coincides with email (WHERE field_3 = ‘$email’ ) and once found field 1 is realised with the value $nombre and field 2 with the surname etc, etc.
The complete code can be seen below

<?php

// conectamos a la base de datos
include(“config.inc.php”);
$link = mysql_connect($db_host,$db_user,$db_pass);
if(!$link) {
die(“Error al intentar conectar: “.mysql_error());
}
// seleccionamos la base de datos
$db_link = mysql_select_db(“$db_name”, $link);
if(!$db_link) {
die(“Error al intentar seleccionar la base de datos”. mysql_error());
}
//  ********fin conexion ********
$usuario = “email”;

// hacemos una consulta  para mostrar los datos
//$sql = mysql_query(“SELECT * FROM $db_table WHERE field_3 = ‘$usuario’, $db_link)or die(mysql_error());

$queEmp = “SELECT * FROM $db_table WHERE field_3 = ‘$email’ ORDER BY id DESC LIMIT 10 “;
$resEmp = mysql_query($queEmp, $link) or die(mysql_error());
$row = mysql_fetch_array($resEmp);
echo $row[‘field_4’];
if ( $row[‘field_4’] == “$password”)
{

if(isset($_POST[‘actualizar’]) && $_POST[‘actualizar’] == ‘Update’){
// comprobamos que no lleguen campos vacios
if(!empty($_POST[‘nombre’]) && !empty($_POST[‘apellidos’]) && !empty($_POST[’email’])){
// creamos las variables
// que vamos a usar en la consulta UPDATE
// y le asignamos sus valores
//$usuario_ID = $_POST[‘usuario_ID’];

$nombre = $_POST[‘nombre’];
$apellidos = $_POST[‘apellidos’];
$message = $_POST[‘message’];
$password = $_POST[‘password’];
$telephone = $_POST[‘telephone’];
$object = $_POST[‘object’];
$message = $_POST[‘message’];
$title = $_POST[‘title’];
$prices = $_POST[‘prices’];
$image = $_POST[‘image’];
$_FILES[‘image’][‘name’] = $image;

echo “$image”;
// EN ESTA PARTE ENTRAMOS LA IMAGEN
if($_FILES[‘image’][‘name’]!=”)
{
$image_filename = “file_2_”.date(“sihdmY”).substr($_FILES[‘image’][‘name’],strlen($_FILES[‘image’][‘name’])-4);

if(!move_uploaded_file($_FILES[‘image’][‘tmp_name’], “./files/”.$image_filename)){
die(“File ” . $_FILES[‘image’][‘name’] . ” was not uploaded.”);
}
}
echo “Esto debe aparecer -> $image_filename”;
/*

//File upload handling
// lo dejo por ahora porque no me recarga la nueva foto
if($_FILES[‘field_2’][‘name’]!=”){
$field_2_filename = “file_2_”.date(“sihdmY”).substr($_FILES[‘field_2’][‘name’],strlen($_FILES[‘field_2’][‘name’])-4);
if(!move_uploaded_file($_FILES[‘field_2’][‘tmp_name’], “./files/”.$field_2_filename)){
die(“File ” . $_FILES[‘field_2’][‘name’] . ” was not uploaded.”);
}
}
*/
$photo = $row[‘field_9’];

$today = date(“F j, Y, g:i”);
echo “$image_filename”;
// la consulta UPDATE
$sqlUpdate = mysql_query(“UPDATE board SET field_1 = ‘$nombre’, field_2 = ‘$apellidos’, field_3 = ‘$email’,
field_4 = ‘$password’, field_5 = ‘$telephone’, field_6 = ‘$object’,
field_7 = ‘$message’, field_8 = ‘$title’, field_9 = ‘$photo’
, field_10 = ‘$today’, field_11 = ‘$prices’

WHERE field_3 = ‘$email'”, $link) or die(mysql_error());

echo “Registro actualizado correctamente”;
echo “$image_filename”;
}else{
echo “debe llenar todos los campos”;
}
}else{
// mostramos el mensaje
echo “<p>”.$mensaje.”</p>”;
?>
<!–
el formulario.
los values de los campos
son los valores que optenemos
de la consulta SELECT
–>
<form name=”actualizar-registro” method=”post” action=”<?php $_SERVER[‘PHP_SELF’]; ?>”>
Anuncio numero: <?php echo $row[‘id’];
$id = $row[‘id’];
// vamos a borrar el anuncio

if(isset($_POST[‘erasead’]) ){
// parte donde se borra la foto
//primero borramos la foto de la carpeta
// ya que la informacion de su nombre esta en la base mysql

$foto = $row[‘field_9’];

// se borra del la carpeta
unlink ($foto);

// ahora el registro
$sql = “DELETE FROM board WHERE id=$id”;

$result = mysql_query($sql);

echo “Anuncio borrado”;
}else{
echo “Debe especificar un ‘id’.\n”;
}
// fin de borrado
?>

<input type=”submit” value=”Erase” name=”erasead”><p>Nombre: <input type=”text” name=”nombre” value=”<?php echo $row[‘field_1’]; ?>” />
Apellidos: <input type=”text” name=”apellidos” value=”<?php echo $row[‘field_2’]; ?>” />
e-mail: <input type=”text” name=”email” value=”<?php echo $row[‘field_3’]; ?>” />
password: <input type=”text” name=”password” value=”<?php echo $row[‘field_4’]; ?>” /></p>
<p><br />
telephone: <input type=”text” name=”telephone” value=”<?php echo $row[‘field_5’]; ?>” />
object: <input type=”text” name=”object” value=”<?php echo $row[‘field_6’]; ?>” />&nbsp;&nbsp; Prices:
<input type=”text” name=”prices” value=”<?php echo $row[‘field_11’]; ?>” size=”6″ />
€</p>
<p>title:
<input type=”text” name=”title” value=”<?php echo $row[‘field_8’]; ?>” size=”107″ /> </p>
<p>Message<textarea rows=”8″ name=”message” cols=”56″><?php echo $row[‘field_7’]; ?></textarea></p>
<p>image:
<input type=”text” name=”image” value=”<?php echo $row[‘field_9’]; ?>” size=”26″ />&nbsp;
<?
/*
if(isset($_POST[‘erase’]) ){
// parte donde se borra la foto
$foto = $row[‘field_9’];
$consulta = “DELETE FROM board WHERE field_6=’$foto'”;
$query = mysql_query($consulta) or die (mysql_error());

// se borra del la carpeta
unlink ($foto);

echo “Borrado”; }
else{}
*/
?>
e” name=”erase”> </p>
<font face=”Verdana”>&nbsp;New image <input type=”file” name=”image” value=”<?php echo $row[‘field_9’]; ?>” size=”57″></font><p><br />

<input type=”hidden” name=”usuario_ID” value=”<?php echo $row[‘usuario_ID’]; ?>” />
<input type=”submit” name=”actualizar” value=”Update” />
</p>
<p>&nbsp;</p>
</form>
<?php } }
else
{ echo “Anuncio y usuario dado de baja “;}
?>

The post Php Delete first appeared on Tecnología ESO en Ingles.

]]>
php Modify https://www.petervaldivia.com/modify/ Sun, 25 Jan 2015 10:30:50 +0000 http://www.petervaldivia.com/?p=332 Php Listing Modify Delete     Making changes to data in Mysql. Posted on June  14th, 2009 by Technology Department  We’ve already put out mobile phone number in the announcement but we haven’t heard anything. None has rung and none has sent an email. Perhaps it’s too expensive? I have to lower the price. We’ll […]

The post php Modify first appeared on Tecnología ESO en Ingles.

]]>

 

 

Making changes to data in Mysql.

Posted on June  14th, 2009 by Technology Department 

We’ve already put out mobile phone number in the announcement but we haven’t heard anything. None has rung and none has sent an email. Perhaps it’s too expensive? I have to lower the price. We’ll see how to make changes to one of the fields of an announcement in this page.
To do this we will have enter some keys, in the case of this programme, my email address and the password that we introduced when we registered the announcement. 

 Mysql Code

 

<?php

$code = “computer”;

include(“config.inc.php”);
$conexion = mysql_connect($db_host,$db_user,$db_pass);
mysql_select_db(“$db_name”, $conexion);

$queEmp = “SELECT * FROM $db_table WHERE field_6 = ‘$code’ ORDER BY id DESC LIMIT 10 “;
$resEmp = mysql_query($queEmp, $conexion) or die(mysql_error());
$totEmp = mysql_num_rows($resEmp);

 

 

while ($rowEmp = mysql_fetch_assoc($resEmp)) {?>

<table border=”1″ width=”92%” bordercolor=”#333399″ style=”border-collapse: collapse”>
<tr>
<td width=”165″ bgcolor=”#E6E0C0″ bordercolorlight=”#FF9933″ bordercolordark=”#FF6600″ bordercolor=”#FF6600″ rowspan=”2″>
<font size=”1″>

<img border=”0″ src=”images/schedule.png” width=”27″ height=”26″ align=”left” hspace=”1″></font><p>
<font size=”1″>

 

<? echo $rowEmp[‘field_10’];?>

</font></p>
<p>
<font size=”1″>
<?
$base = “https://www.petervaldivia.com/technology/php/board/”;

$image1 = $rowEmp[‘field_9’];

$image2 = substr ($image1, 7);
$image3 = “thumbs/”.$image2;

echo “<a href=# onclick= abrirpopup(‘$image1′,500,500)> <img src=’$image3′ border=’1′ class= borde></a>”;
border=’1’ class= borde></a>”;

?></font></p>
<td bgcolor=”#B6E5FF”>
<p style=”margin-top: 0; margin-bottom: 0″><font size=”2″>

</span> </font><b>
<font size=”2″>
<img border=”0″ src=”images/money-bag.png” width=”32″ height=”32″ align=”left”> <? echo $rowEmp[‘field_11’];?> €</font></b><font size=”2″><b><span lang=”es”>
</span></b> </font> </p>
<p style=”margin-top: 0; margin-bottom: 0″><font size=”2″><b>
<font color=”#FF3300″>Title</font></b><font color=”#FF3300″></b></font>:<b><font color=”#333399″> <? echo $rowEmp[‘field_8’];?>
</font></b> </font> </p></td>
</tr>
<tr>

<td bgcolor=”#B6E5FF”>
<p style=”margin-top: 0; margin-bottom: 0″><b>
<font size=”2″ color=”#FF3300″>Description</font></b><font size=”2″>: <?

$string1 = $rowEmp[‘field_7’];

$description = substr($string1,0,400);

echo $description;?>
</font><b>
<font size=”2″>&nbsp;<font color=”#FF3300″>Owner</font>:<? echo $rowEmp[‘field_1’];?> </font>
</b>

<img border=”0″ src=”images/HP-Mobile-2.png” width=”32″ height=”32″ > <? echo $rowEmp[‘field_5’];?>
<img border=”0″ src=”images/address-book-2.png” width=”32″ height=”32″> <? echo $rowEmp[‘field_3’];?>
<b>
<span lang=”es”>
<font size=”2″>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

</font>
</p></td>
</tr>
</table>
<?
}
}
?>

The post php Modify first appeared on Tecnología ESO en Ingles.

]]>
php Listing https://www.petervaldivia.com/listing/ Sun, 25 Jan 2015 10:30:19 +0000 http://www.petervaldivia.com/?p=330 Php Listing Modify Delete     The presentation of lists with the results of the adverts. Posted on June  14th, 2009 by Technology Department  It’s now time to show the results of the announcement placed by our students and by users in general. Let’s suppose that we want to show a list of all the […]

The post php Listing first appeared on Tecnología ESO en Ingles.

]]>

 

 

The presentation of lists with the results of the adverts.

Posted on June  14th, 2009 by Technology Department 

It’s now time to show the results of the announcement placed by our students and by users in general. Let’s suppose that we want to show a list of all the adverts that are classified as computer adverts, for this we need to consult Mysql again to call up all the records (identifiers id) whose ‘type of object’ field is computer.

 

Simplified code to show results Mysql

In the first part of the code we must simply repeat what we did before, that is, we have to open the php, assign a variable $code el valor computer and incluide the file with the data from the database.

<?php

$code = “computer”;

include(“config.inc.php”);
$conexion = mysql_connect($db_host,$db_user,$db_pass);
mysql_select_db(“$db_name”, $conexion);

Next, we’ll take the table and select the last 10 records. The way of saying this is by using the annotation ORDER BY id DESC LIMIT 10. If we want 20 records on the paeg we just have to change it to DESC LIMIT 20.
Remember that we name the variables $queEmp o $resEmp whatever we want. You could call then $cadena1 o $busca-datos, etc. if you liked

$queEmp = “SELECT * FROM $db_table WHERE field_6 = ‘$code’ ORDER BY id DESC LIMIT 10 “;
$resEmp = mysql_query($queEmp, $conexion) or die(mysql_error());
$totEmp = mysql_num_rows($resEmp);

A ‘While’ appears in the next line,this is while what is in brackets is done. This function recuperates a row as an associative matrix. Imagine that, while you were looking in the database, the first indentifier fulfills the condition that field 6 must contain the word computer. This instruction colelcts all the data that there is in this row, from the first field to the last, and presents it in an array of data. Now we have an array with all this identifier’s (id) information ready to be shown on screen. Firstly, we generate a table in html and to do this we close php and add the required html code in accordance with what the student wants. This table can contain however many fields, rows and columns as you like and you can colour the cells, add borders to the table etc, etc. This is a html thing and can be done using a html editor like nvu. As it is not the topic of this chapter, we’re going to move back to the what is essential to the topic.

while ($rowEmp = mysql_fetch_assoc($resEmp)) {?>

<table border=”1″ width=”92%” bordercolor=”#333399″ style=”border-collapse: collapse”>
<tr>
<td width=”165″ bgcolor=”#E6E0C0″ bordercolorlight=”#FF9933″ bordercolordark=”#FF6600″ bordercolor=”#FF6600″ rowspan=”2″>
<font size=”1″>

<img border=”0″ src=”images/schedule.png” width=”27″ height=”26″ align=”left” hspace=”1″></font><p>
<font size=”1″>

The first line that we see where the first datum of the database is generated is the following

<? echo $rowEmp[‘field_10’];?>

It’s very simple. The first thing to do is open php, then we tell it to show the value of the variable $rowEMP, which has been taken from the database, on the screen. But, because this variable is an array varaible (it has many values according to position or value) we select the field_10 that corresponds to the date we have stored.
In this way we can access all the data, like the price, description etc.
I want to make it clear that this array variable has no value like como $dato1 = “344”;but it can contain many values and it is because of this that these variables are called multidimensionals.
The rest of the code is easy to understand because we just have to apply our former criteria.

</font></p>
<p>
<font size=”1″>
<?
$base = “https://www.petervaldivia.com/technology/php/board/”;
//Vamos a quitar el enlace desde donde esta la foto y tomar la foto pequeña
// para ello le quitamos el directorio y le ponemos el nuevo directorio con la foto pequeña
// la imagen 1 dara la ruta de la foto grande
$image1 = $rowEmp[‘field_9’];

$image2 = substr ($image1, 7);
$image3 = “thumbs/”.$image2;

echo “<a href=# onclick= abrirpopup(‘$image1′,500,500)> <img src=’$image3′ border=’1′ class= borde></a>”;
//echo “<a target= _blank href=’$image1′> <img src=’$image3′ border=’1’ class= borde></a>”;

?></font></p>
<td bgcolor=”#B6E5FF”>
<p style=”margin-top: 0; margin-bottom: 0″><font size=”2″>

</span> </font><b>
<font size=”2″>
<img border=”0″ src=”images/money-bag.png” width=”32″ height=”32″ align=”left”> <? echo $rowEmp[‘field_11’];?> €</font></b><font size=”2″><b><span lang=”es”>
</span></b> </font> </p>
<p style=”margin-top: 0; margin-bottom: 0″><font size=”2″><b>
<font color=”#FF3300″>Title</font></b><font color=”#FF3300″></b></font>:<b><font color=”#333399″> <? echo $rowEmp[‘field_8’];?>
</font></b> </font> </p></td>
</tr>
<tr>

<td bgcolor=”#B6E5FF”>
<p style=”margin-top: 0; margin-bottom: 0″><b>
<font size=”2″ color=”#FF3300″>Description</font></b><font size=”2″>: <?
// vamos a reducir el texto a poner a 400 caracteres
$string1 = $rowEmp[‘field_7’];

$description = substr($string1,0,400);

echo $description;?>
</font><b>
<font size=”2″>&nbsp;<font color=”#FF3300″>Owner</font>:<? echo $rowEmp[‘field_1’];?> </font>
</b>

<img border=”0″ src=”images/HP-Mobile-2.png” width=”32″ height=”32″ > <? echo $rowEmp[‘field_5’];?>
<img border=”0″ src=”images/address-book-2.png” width=”32″ height=”32″> <? echo $rowEmp[‘field_3’];?>
<b>
<span lang=”es”>
<font size=”2″>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

</font>
</p></td>
</tr>
</table>
<?

}
}
?>

In the former code substr($string1,0,400);-> takes the first 400 values, counting from the value 0, from the variable ( $string1 ). It does this to limit the number of words that can be shown.

The post php Listing first appeared on Tecnología ESO en Ingles.

]]>
php https://www.petervaldivia.com/php/ Sun, 25 Jan 2015 10:29:49 +0000 http://www.petervaldivia.com/?p=328 Php Listing Modify Delete     Internet, webmail, website and Php y Mysql.   Webmail: Webmail ( Web-based e-mail)  such as Gmail, Yahoo Mail or  Hotmail,  is an e-mail service intended to be primarily accessed via a web browser. A major advantage of web-based e-mail over application-based e-mail is that a user has the ability […]

The post php first appeared on Tecnología ESO en Ingles.

]]>

 

 

Internet, webmail, website and Php y Mysql.

 

Webmail:

Webmail ( Web-based e-mail)  such as Gmail, Yahoo Mail or  Hotmail,  is an e-mail service intended to be primarily accessed via a web browser.

A major advantage of web-based e-mail over application-based e-mail is that a user has the ability to access their inbox from any Internet-connected computer around the world.
Exercise: Create a webmail email account and send a simple message with a attached file to your partner.

Php and html page. The Basics

Php is a programming language which is run by the machine where it is housed, i.e. when a page that has a php code uploads in your navigator, part of the code can be run on the machine where it is housed (where the page comes from) and return information which is different to what is written in the code.
Let’s look at an example.
If we write the famous phrase “Hello World” in html code the only thing that will appear will be this simple phrase and only once. If we want it to appear 5 times, we have to write it 5 times and it’s the same for anything else we want to do.
In the case of php, if we want to write “Hello World” then there is a sentence for it but if we want it to appear 5000 times on the screen we install a counter (which isn’t visible on the page and that runs on the server where the page is housed) When the sentence is printed on the page the counter goes up one unit, checks if the counter has gone up to 5000 and, if this isn’t the case, prints the sentence again.
We can appreciate a big difference, or in other words “We can count on functions that help us to make web pages.”
PHP is continually evolving and there are already several version, each one adding new functions to the last.
The aim of this unit isn’t to become an expert in php but to learn about some of the tasks that can be performed. For this purpose we are going to apply it to a sales portal in our area La Serena and Don Benito; a type of local Second Hand shop.

What is Mysql?

Mysql is a type of database manager, responsible for managing the data stored in a database which is to be shown on the web page.
The basic idea is the following – we create a database that, in its turn, contains a table and this table contains various records. The most appropriate comparison would be to an archive.
Let’s suppose that in this archive we have stored information about all the groups in the school. In this case, 3ºA would be in this archive and would be a table full of data, the same for 3ºB etc.
Each table (group) contains a series of students (identifier) and each student has a number of pieces of personal information, like his name, surnames, street address, telephone, etc. These are stored in records.
In other words, we have database > table > records

1st Create a database

The first thing we’re going to do is create our database, whose job is to store all the data about the users. In order to create something, we must first enter into the system, that is, into the database.
We must create an archive with the information pertinent to the connection which we will call config.php. This archive will contain the following information.
a) The address where the database is to be found. In other words, where I’m going to connect to the database. This piece of data is usually an IP address where the database is found or, if it’s in the same server, the localhost word.
b) The name of the database.
c) A username to be able to enter into the database Databases contain confidential information and we have to protect them with usernames and passwords.
d) The password needed to enter the database
This file is expressed as follows:

<?php
$db_host = “192.125.0.123”;$db_user = “user”;$db_pass = “mypassword”;$db_name = “secondhand”;$db_table = “board”;
?>

The first thing to appear is the <?php sign. This indicates that the page is going to work with php and so the server requires the php language to function for the requests that the page will make.

Secondly we find sentences like $nombre = “dato”; Let’s see what this sign means. Let’s start with the dollar sign, that could have been a euro sign (€) except that the Americans got there before us. When we have a word with $ infront it means that we are generating a variable and assigning it a specific piece of data. In this case, because the piece of data will always be the same because we’re not going to change the connection information for the database, we have to write in some speech marks, indicating that:
$db_host = “192.125.0.123”;
Note that it finishes with the ;. This tells us that the instruction has finished.
Let’s move on to the next value, for this we are going to need the datum username: $db_user = “user”;

We can see that you do it in the same way, that is, you give the variable db_user the value that we have been assigned in the database. If your database has a username called Manolo then it would be $db_user = “manolo”. You do it in the same way for the following two variables.
The last datum refers to the chosen table. You have to remember that once the connection to the database is realised, we have to take the data from a table. In this case we call it a board.
To finish this file we have to show that the php is has finished, so we put ?>.

Creating a table in a database

Once we have the database with the information about where it is, what it’s called, the username and password, we must create a table to store the data of the users. We must show the php code again. 1st – enter in the database, 2nd create a table, 3rd create records in the table. The code, that will form part of the file install.php, is:

<?php

// Incluimos el codigo anterior

include (“config.php”);

mysql_connect($db_host, $db_user, $db_pass);
mysql_select_db($db_name );
mysql_query(“CREATE TABLE `$db_table` (id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id) ,
field_1 TEXT ,
field_2 TEXT ,
field_3 TEXT ,
field_4 TEXT ,
field_5 TEXT ,
field_6 TEXT ,
field_7 TEXT ,
field_8 TEXT ,
field_9 TEXT )”) or die(“Error! Table not be created.”);

echo “Table created. “;  ?>

 

We’re going to see what this piece of code does. The first thing is the instruction ‘include’ that, as the word implies, includes the code config.php in this file because the data it contains is going to prove necessary.

It’s a good idea to use this sentence because it saves us work and orders the code.
we have to note, without respect to the order, that when the codes are very long it is convenient to use the symbol // to make comments. In this way that which appears after the // isn’t valid for php and it allows us to be a bit clearer in the code that we write or that another programmer has written.
mysql_connect (base, username, password) -> This php instruction connects with the name database which has a username and password. In this case, this data is taken from the information in the file config.php
Once we have connected with the database, we have to choose a specific database because our server can contain several databases. To do this we use mysql_select_db($db_name ). $db_name will be replaced by the value that it has in the file config.php. Now we have the connection with the database. Now it’s time to create the table and to do this we use this instruction.
mysql_query ( “create table” `$db_table ` (id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id) ,
field_1 TEXT ,
field_2 TEXT , etc etc
mysqql_query Consults the database which, in this case, is an order, that of creating the table. {“create table” } with the name {$db_table} , which, in our case, will be board and will appear with the characteristics seen in brackets id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id). With respect to this last one, what it shows is that the identifier of each record has to be an integer, that is a whole number, that it shouldn’t be nil, so that it can be differentiated from other records, that each time a record is added the number grows and that the main keyword needed for access is going to be this id identifier. So each new advert is going to have an identifier or identity number. For example, advert 36, that refers to the sale of a mobile phone, could have an id of 55 and identifies it from among the other adverts and its fields, like the price, name of owner etc, will be referred to this id.
Lastly we can see the fields that it should contain. In this case, we’re going to call them field_1, field_2 … specifying that they are text fields. We can also name them telephone, name, surname, price…
At the end of the mysql_query sentence it says die. This means that if this doesn’t produce the creation the table, then it should abandon the task.
The last instruction says: echo “Table created. “;. This means that the phrase Table created will be written on the screen

Form used for data entry

 

To enter the data in the database we first have to have a form and then this will send the data to another file that will manage the data so that it can be incorporated in the database.
The form, written in html, looks something like this:

 

<form enctype=’multipart/form-data’ action=’process.php’ method=’POST’>
<div align=”center”>
<table border=”1″ cellspacing=”1″ style=”border-collapse: collapse” width=”743″ cellpadding=”5″ height=”371″>
<tr><td height=”22″ width=”45″ bordercolor=”#FFFFFF”>
<img src=”../../../image/obj_bbs.gif” width=”45″ height=”45″></td>
<td height=”22″ width=”72″ bordercolor=”#FFFFFF”>
<font face=”Verdana” size=”2″>Name</font></td>
<td height=”22″ width=”617″ bordercolor=”#FFFFFF”>
<font face=”Verdana”><input type=text name=’nombre’ size=25>*</td></tr><tr>

 

 

 

 

<?php
include(“global.inc.php”);
$errors=0;
$error=”Los siguientes errores ocurrieron…The following errors occured while processing your form input.<ul>”;
pt_register(‘POST’,’telephone’);
pt_register(‘POST’,’nombre’);
pt_register(‘POST’,’email’);
pt_register(‘POST’,’apellidos’);
pt_register(‘POST’,’message’);
pt_register(‘POST’,’object’);
pt_register(‘POST’,’password’);
pt_register(‘POST’,’image’);
pt_register(‘POST’,’title’);
pt_register(‘POST’,’prices’);

if($nombre==”” || $email==”” || $apellidos==”” || $message==”” ){
$errors=1;
$error.=”<li>No completo todo el formulario. Por favor vuelva a rellenar todos los campos….You did not enter one or more of the required fields. Please go back and try again.”;
}
if(!eregi(“^[a-z0-9]+([_\\.-][a-z0-9]+)*” .”@”.”([a-z0-9]+([\.-][a-z0-9]+)*)+”.”\\.[a-z]{2,}”.”$”,$email)){
$error.=”<li> Formato de Correo no valido…..Invalid email address entered”;
$errors=1;
}
if($errors==1) echo $error;
else{
include (“photo-validate.php”);
include (“create.php”);

$today = date(“F j, Y, g:i”);
include(“config.inc.php”);
$link = mysql_connect($db_host,$db_user,$db_pass);
if(!$link) die (‘Could not connect to database: ‘.mysql_error());
mysql_select_db($db_name,$link);

$query = “INSERT into `”.$db_table.”` (field_1,field_2,field_3,field_4,field_5,field_6,field_7,field_8,field_9, field_10, field_11) VALUES (‘” . $_POST[‘nombre’] . “‘,'” . $_POST[‘apellidos’] . “‘,'” . $_POST[’email’] . “‘,'” . $_POST[‘password’] . “‘,'” . $_POST[‘telephone’] . “‘,'” . $_POST[‘object’] . “‘,'” . $_POST[‘message’]. “‘,'” . $_POST[‘title’] . “‘,’photos/”.$file_name.”‘,'” . $today . “‘,'” . $_POST[‘prices’] . “‘)”;
mysql_query($query);
mysql_close($link);

}
?>
<html><head><title> Gestion de anuncio </title></head><body>
<p align=”center”><b>
<A HREF=”javascript:history.back()”> <font color=”#000080″ size=”4″>Volver Atrás
</font> </A>
</b>
</body></html>

It’s worth paying attention to the label “form” that starts the form and that will, furthermore, appear again at the end of the form that isn’t written here so as not to make the code overly long. After form we see the way we are going to manage the data and then what we are going to do with this data (action), which, in this case, shows that it is sent to the file process.php through the post method (there’s another method called Get) The rest of the code refers to the width of the fields, the colour of the border, the type of border etc. In the second to last line we can see input type = text name = nombre. This tells us that the first field to be completed is a text field and that it is called nombre. We can download the full code once we have seen this script.

File to enter the data in the database

 

We have an archive called process.php that’s going to take on the job of introducing the data into the database. Let’s see what there is inside it.

 

<?php
include(“global.inc.php”);
$errors=0;
$error=”The following errors occurred while processing your form input.<ul>”;
pt_register(‘POST’,’telephone’);
pt_register(‘POST’,’nombre’);
pt_register(‘POST’,’email’);
pt_register(‘POST’,’apellidos’);
pt_register(‘POST’,’message’);
pt_register(‘POST’,’object’);
pt_register(‘POST’,’password’);
pt_register(‘POST’,’image’);
pt_register(‘POST’,’title’);
pt_register(‘POST’,’prices’);

if($nombre==”” || $email==”” || $apellidos==”” || $message==”” ){
$errors=1;
$error.=”<li>You did not enter one or more of the required fields. Please go back and try again.”;
}
if(!eregi(“^[a-z0-9]+([_\\.-][a-z0-9]+)*” .”@”.”([a-z0-9]+([\.-][a-z0-9]+)*)+”.”\\.[a-z]{2,}”.”$”,$email)){
$error.=”<li> Invalid email address entered”;
$errors=1;
}
if($errors==1) echo $error;
else{
include (“photo-validate.php”);
include (“create.php”);

$today = date(“F j, Y, g:i”);
include(“config.inc.php”);
$link = mysql_connect($db_host,$db_user,$db_pass);
if(!$link) die (‘Could not connect to database: ‘.mysql_error());
mysql_select_db($db_name,$link);

$query = “INSERT into `”.$db_table.”` (field_1,field_2,field_3,field_4,field_5,field_6,field_7,field_8,field_9, field_10, field_11) VALUES (‘” . $_POST[‘nombre’] . “‘,'” . $_POST[‘apellidos’] . “‘,'” . $_POST[’email’] . “‘,'” . $_POST[‘password’] . “‘,'” . $_POST[‘telephone’] . “‘,'” . $_POST[‘object’] . “‘,'” . $_POST[‘message’]. “‘,'” . $_POST[‘title’] . “‘,’photos/”.$file_name.”‘,'” . $today . “‘,'” . $_POST[‘prices’] . “‘)”;
mysql_query($query);
mysql_close($link);

}
?>
<html><head><title> Advertise admin </title></head><body>
<p align=”center”><b>
<A HREF=”javascript:history.back()”> <font color=”#000080″ size=”4″>Volver Atrás
</font> </A>
</b>
</body></html>

Gestion de anuncio

The line include(“global.inc.php”) indicates that the file global.inc is coming into play to add a function that creates the variables of the fields on the form, i.e., if we enter a field with the name ‘lugar’ then through this file and a function that it contains (that we’re not going to look at) the variable “$lugar” is generated.

For simplicity’s sake we are not going to look at this file because, like others, it isn’t essential to this topic. Let’s look at the following lines

 if($nombre==”” || $email==”” || $apellidos==”” || $message==”” ){ $errors=1;

In this case, it doesn’t say ->if ( condicion) then {tarea}. The function ‘if’ looks at what there is inside the brackets and if this has been done then it runs what we see between the braces {}.

 It this case it checks if the mail address, the surname field or the name field are empty. If this is the case it puts $errors=1; and it also assigns the text

You did not enter one or more of the required fields. Please go back and try again

 A little later it does another check to see if the email field is missing the @ or if it contains any other type of error (we won’t see this function). Then, if this happens, another text ->

Invalid email address to the variable $error and then it checks if any error was made in these cases ( if($errors==1) echo $error;. I.e. if you fill in the form incorrectly the error is printed the error on the screen.

 If everything is ok then you go on to ‘else’ and it runs what comes next, in this case it includes two new files photo-validate and create.php The first file is going to check if the type of photo file is valid and the second is going to generate miniatures of the photos sent in.

 Let’s see the next chunk of code

 1º $today = date(“F j, Y, g:i”);

2º include(“config.inc.php”);

3º $link = mysql_connect($db_host,$db_user,$db_pass);

 4º if(!$link) die (‘Could not connect to database: ‘.mysql_error());

5º mysql_select_db($db_name,$link);

 The first line generates the variable $today that allows us to know the date and time. We see that it is done in the same way as the reserved function ‘date’ with some parameters in brackets which indicate how the time should be shown. A reserved function is a function specific to php, stored in its own system that runs itself, in other words, “you don’t have to tell the system what to do because php already knows”.

 There are many ways to show the date and you can look at the php manual to see the different options.

The second line calls config.inc.php, the file that contains the data from the database. It is called up because we are soon going to enter data in the records of the table. The third generates the variable $link that contains the data needed to connect to the database. It contains the instruction mysql_connect for the connection.

The fourth checks if the connection has been successful. It says if(!$link) die. this means that if what is inside the brackets isn’t done (for this reason we add the !symbol at the start of the variable) then the programmes stops running and a message appears on the screen that says No ha podido establecer conexión con la base de datos

The fifth selects the database once you are connected. $db_name is the name of the database.

The next thing is to create a variable that is going to contain the consultation. In this case it is the following

 $query = “INSERT into `”.$db_table.”` (field_1,field_2,field_3,field_4,field_5,field_6,field_7,field_8,field_9, field_10, field_11) VALUES (‘” . $_POST[‘nombre’] . “‘,'” . $_POST[‘apellidos’] . “‘,'” . $_POST[’email’] . “‘,'” . $_POST[‘password’] . “‘,'” . $_POST[‘telephone’] . “‘,'” . $_POST[‘object’] . “‘,'” . $_POST[‘message’]. “‘,'” . $_POST[‘title’] . “‘,’photos/”.$file_name.”‘,'” . $today . “‘,'” . $_POST[‘prices’] . “‘)”;

I.e. insert into ( insert into ) the table ($db_table) dta in the records field_1, field_2 …… taken from the form with value valor $_POST[‘nombre’] ., $_POST[‘apellidos] ., $_POST[’email’] …..

Everything is logical but we must take care to respect the way in which we enter the data, paying attention to the speech marks, brackets, etc. This sentence can be modified with whatever values you want but you have to use the words ‘insert into’ to be able to enter the data.

Then we have mysql_query($query); which consults the database and mysql_close($link); that closes the connection to the database.

Eureka, now we have our first record stored in the database!

The last thing we must do is shut the php and open the html code to insert a javascript that allows us to return to the page before.

The post php first appeared on Tecnología ESO en Ingles.

]]>
Types of Internet Connections https://www.petervaldivia.com/types-of-internet-connections/ Sun, 25 Jan 2015 10:18:56 +0000 http://www.petervaldivia.com/?p=321 Networks Tcp-Ip DNS Internet Conections     Types of Internet Connections.   As technology grows, so does our need for things to go faster. Ten years ago, websites just included images, coloured text and some repetitive melodies. Now Flash websites, animations, high resolution photos, online gaming, videos or streaming ( radio on the internet ), […]

The post Types of Internet Connections first appeared on Tecnología ESO en Ingles.

]]>

 

 

Types of Internet Connections.

 

As technology grows, so does our need for things to go faster. Ten years ago, websites just included images, coloured text and some repetitive melodies. Now Flash websites, animations, high resolution photos, online gaming, videos or streaming ( radio on the internet ), are getting more popular for people who demand faster and faster internet connections.
The connection speeds listed below represent an average speed at the time of publication ( May 2009 ). This will no doubt change over time.56 kbit modem1) PCI modem( see image above ). Analogue up to 56000 bits per second. It means that in a second, 56000 bits ( 0 or 1 ) travel through the copper wire. It is both economical and slow and it is also called dial-up access. If you connect the modem, you get internet but as it uses the analogue telephone line, if you surf on the internet, nobody can call you because the line is busy.
Using a modem connected to your PC which is very cheap ( about 10 €) , users connect to the Internet only if you click on the telephone Access Icon and the computer dials the phone number provided by your ISP ( Internet Service Provider ) and connects to the network. The signal is analogue because data is sent over an analogue telephone network. This modem converts received analogue data to digital ( always analogue on the telephone site and digital on the computer side ).
As dial-up access uses ordinary telephone lines the data rates are limited and the quality of the connection is not always good. Nowadays very few people use this type of connection.
2) DSLDSL or – an ‘always on’ connection- uses the existing 2-wire copper telephone line connected to the internet and won’t tie up  your phone like the old modem does. There is no need to dial-in to your ISP as DSL is always on. DSL is called ADSL ( Short for Asymmetric Digital Subscriber Line) for home subscribers.
As we said before ADSL is short for asymmetric digital subscriber line and supports data rates up to 10Mbits ( May 2009 ) when receiving data ( download ) and from 16 to 640 Kbps when sending data ( upload ). ADSL is called asymmetric because it supports different data rates for upload than for download traffic.
coaxial cable3) CableThere are two type of cable; Coaxial and optic fibre. The first one is used by cable TV and that is common for data communications ( see image on the left ).
The cross-section of the cable shows a single centre solid wire made of copper surrounded by a copper mesh conductor. Between the main wire ( in the centre ) and the mesh conductor is an insulating dialectric. This dialectric ( blue part in the image ) has a large effect on the essential features of the cable. Depending on the material that isulator is made of, the cable has different inductance and capacitance values and these values affect how quickly data travels through the wire. The last layer is an outside insulator to protect the whole wire.
Data is transmitted through the rigid wire, while the outer copper mesh layer serves as a line to ground.
fibre opticOptic Fibre.

Fibre-optic cables are strands of a special optical material as thin as a human hair that carry data ( files, videos .. ) over long distances. Now, there is not electrical signal. In Optical fibres data are carried as light signals

How Does an Optical Fiber Transmit Light?

light moving in a optical fibre

 

 

 

What is the secret of optical Fibre? Why doesn’t the light ray escape from the strand?
Suppose you want to shine a torch beam down a long, straight corridor. Just point the beam straight down the corridor. — light moves in straight lines so the light will reach to the end of the corridor.
What if the corridor has a bend in it? . Just place a mirror at the bend to reflect the light beam towards the other side of the corridor.
What if the corridor has multiple bends? You might places as many mirrors as bends so that it bounces from side-to-side all along the corridor. This is what happens in an optical fibre.
4) Wireless Internet Connections

Wireless broadband (Wireless Internet Connections ). Instead of using cable networks for your Internet connection, WIC uses radio frequency .Wireless Internet can be accessed from anywhere as long as your WIFI adaptor is located  within a network coverage area. It also provides an always-on connection and  it is still considered to be relatively new.

5) Satellite
satellite internet IoS short for  Internet over Satellite allows a user to access the Internet via a geostationary  satellite that orbits the earth. A geostationary satellite is a type of satellite placed at a fixed position above the earth’s surface. Because of the large distances between home and satellite,  signals must travel from the earth up to the satellite and back again. It causes  a slight delay between the request and the answer.

 

 

 

 

Dictionary:

Tie up . A temporary stoppage or slowing of business, traffic, telephone service, etc., due to such incidents as a strike, storm, or accident

Strand: A single filament, such as a fiber or thread, of a woven or braided material

The post Types of Internet Connections first appeared on Tecnología ESO en Ingles.

]]>
DNS https://www.petervaldivia.com/dns/ Sun, 25 Jan 2015 10:17:23 +0000 http://www.petervaldivia.com/?p=319 Networks Tcp-Ip DNS Internet Conections     DNS and Data Security.   A big problem with the Internet is that data is transmitted using telephone technology, which means unauthorised users can intercept the data relatively easily. Which is a bit of a pain, really. On-Line Shopping uses Encryption Software 1) On-line shopping or e-commerce has […]

The post DNS first appeared on Tecnología ESO en Ingles.

]]>

 

 

DNS and Data Security.

 

A big problem with the Internet is that data is transmitted using telephone technology, which means unauthorised users can intercept the data relatively easily. Which is a bit of a pain, really.

On-Line Shopping uses Encryption Software

encryption key1) On-line shopping or e-commerce has got much more popular recently. 2) The basic idea is that the retailer puts details of their products on a web site. Customers can put the stuff they want into an electronic basket (by clicking on a button). They then pay using a credit card, and the goods are delivered soon after. 3) Some people don’t like on-line shopping because they’re worried that their credit card details might be intercepted and used to make unauthorised purchases. Encryption software can reduce this risk. 4) Sensitive information — like credit card details — is encrypted by the web site into a code which can only be decoded with the right software and a special password called a key. In theory, only the retailer’s web site can access the information, so even if someone intercepts the transmission, they won’t be able to use the data.

Passwords give Restricted Access to some Web Sites

Some web sites restrict access to authorised users only. Schools allowing pupils and parents to access material on their intranet might do this to prevent other people accessing the information. On-line magazines also do this, so they can charge people for access.

The usual way to restrict access is to issue user names and passwords.

Get Protection from Hackers and Viruses

  • Hacking means accessing a computer system and its files without permission. It’s totally illegal, and once inside a system, the hacker might be able to view, edit copy or delete important files or plant a virus. Organisations can protect themselves by using passwords, encrypting files and using hacking-detection software.
  • computer virusA virus is a program deliberately written to infect a computer, and make copies of itself. They often corrupt other files — and even operating systems. They move between computer systems by attaching themselves to harmless computer files and e-mails.
  • The main way to reduce the risk of viruses is to use anti-virus software — but it’s important to use an up-to-date version because new viruses are detected practically every day.

 

DNS Poisoning

Pharming - DNS Poisoning

Pharming is a derivate from phishing. Phishing mean fishing ( the act of catching fish). In computer slang, fish means user name and password. Both word use “ph” instead of an “f” in this slang.

Pharming’s purpose is to obtain personal information through domain  spoofingas is illustrated above. In phishing ( stealing passwords ) you are spammed with malicious e-mail requests for you to visit a malicious computer – spoof Web sites- which appear “nice and friendly sites”. Pharming on the other hand attacks a DNS server and introduces false information into the DNS server. So if you ask the server what ip matches the nicebank domain, it will send you to n1cebank.com. ( introduce your personal bank details and you are lost ).

Dictionary:

Encryption . To alter a file using a secret code so as to be unintelligible to unauthorized parties.

Intranet: An intranet is like a private mini-Internet that can only be viewed by people connected to a particular organisation. e g a hospital might use an intranet to circulate information to its employees.

Pharming: is a hacker’s attack aiming to redirect a website’s traffic to another site.

Phishing: is the criminally fraudulent process of attempting to acquire sensitive information such as usernames, passwords and credit card details

Spoofing: A gentle satirical imitation

The post DNS first appeared on Tecnología ESO en Ingles.

]]>
TCP/IP Protocol https://www.petervaldivia.com/tcp-ip-protocol/ Sun, 25 Jan 2015 10:16:28 +0000 http://www.petervaldivia.com/?p=317 Networks Tcp-Ip DNS Internet Conections     TCP/IP Protocol .   Internet basics. Divide and win. That is the philosophy of the internet. If you need to send some information from one place in the world to another one far away, what is the best way? If you send all information along just one path, […]

The post TCP/IP Protocol first appeared on Tecnología ESO en Ingles.

]]>

 

 

TCP/IP Protocol .

 

Internet basics.

Divide and win. That is the philosophy of the internet. If you need to send some information from one place in the world to another one far away, what is the best way?
If you send all information along just one path, what will happen if a part goes missing? We’ll have to start again…
We can solve the problem using the TCP/IP protocol or (Transmission Control Protocol/Internet Protocol).
If you are at home in front of your computer, that computer is called a client. Then you start the browser ( a client program ) and request some information, for example, your favourite sports webpage that is located on client-servera remote computer ( a server ), so we have a client-server interaction. So, the browser searches for the remote computer on the internet and passes the request to the server (located maybe in the UK, USA or in another country ). The server then checks up your request and tries to locate the HTML file on its hard disk. On finding it, the server sends this file to your computer. To make this possible, it is necessary to “speak the same language”, that is the TCP/IP. Server can be located thousands of miles from your workplace. TCP/IP are used to transfer files or data from one computer to the other. Typically, the client is your browser (firefox, opera, explore ) and the server is a program running on a remote computer.

The computer that holds the client program is called  the client machine and the computer that holds the serve program is called the  server machine

A program without TCP/IP program can communicate with other computers, so it is not possible surfing on the internet.

puzlle comparasion

 

-> Let’s think again about the first phrase ( divide and win ) and let’s make a comparison with a puzzle. If I have a 10000 piece puzzle and I want to send it to Tokyo, my TCP friend will pack it all up in several envelopes, so I will probably need about 325 stamps. Now my friend IP will carry all of them and will visit some transport agencies such as UPS, SEUR, the post-office, etc. Every firm has its own routes so every envelope will take a different path from my house to Tokyo. カルロス ( my friend in Tokyo) has another IP friend who will pick up all the envelopes, then give them to its Japanese friend TCP who will do the puzzle so カルロス can see the puzzle.

 

  • • TCP/IP is a two-layer program. TCP (the higher layer) , manages the arranging of a file into smaller packets ( pieces of the puzzle) that are transmitted over the net and received by a TCP layer ( in the server) that reassembles the packets into the primary file. The lower layer, IP, handles the address part of each packet ( transport agencies ) so that it gets to the right destination. Each gateway computer ( situated all round the network) checks this address to see where to forward the file ( a message, photo, video, mp3, etc ) to. Even though some packets from the same file are routed a different way to other packets, they will be reassembled at the destination ( the server computer ).
  • • Oh, I forgot to mention something. I have a postal address in Villanueva and my friend in Japan has a postal address in Tokyo, so we are identified in the postal network. As in the comparison, every machine on the Internet¬ has a unique identifying number. It is called Ip or Logical address and looks like this:215.56.55.154
    • IP-> protocol is not the same as ip->address
    • We all know that machines work with 0 and 1 ( Do you remember the MATRIX ?). So ip is in binary code:
    • 215.56.55.154 == 11010111.00111000.00110111.10011010
    • If you add all the positions together, you get 32, which is why IP is considered a 32-bit number. Uauuu, it means that it if calculate the value of 232 it equals 4294967296 values. More than 4 billion (eso no entiendo nada.
    internal and externa IP• A bit more about Ip. Do you think 4.3 billion IPs are enough?
    • If you add together all machines connected to the internet, users, websites, fax, control systems, telecommunication systems, wifi mobiles, etc probably, 4.3 billion is not much, but trying to work it out this way is a mistake.
    • Our Secondary School has about 300 computers but not 300 Ip. If a pupil surfs on the internet, his request is sent to the modem-router which changes that IP for another External IP. Then, once the modem receives the information, it changes the external Ip for an internal IP and the information is sent to the pupil.
    .
  • Saving money on telephone calls.- VoIP

• VoIP or Voice over Internet Protocol phones work by sending data via the Internet in tiny binary packets. Itrj45 cable works like this:

1 Your voice signal, which is analogue, is converted in an IP Phone from analogue into digital data. You can also use your PC, a special software and a microphone which substitutes a telephone.

2 The sending computer ( your VoIP software ) compresses the digital data, much like MP4 files.

3 The data ( your voice ) is divided into packets of about 30 milliseconds long.

4 All packets are sent to a modem-router which decides the best way through the Internet for each packet. They will travel by many different paths ( some will go to Africa, others to Finland, etc ) and consequently, they will arrive at different times. Some of them may even be lost. Because the packets are so small ( 30 milliseconds ), you won’t hear the difference if some are lost.

5 The receiving computer uses another VoIP software to put them in the right order.

6 The data is converted back from digital to analogue ( voice ) and played through your standard phone ( the phone you have at home ), PC headphones or IP phone.
• Companies such as JustVoIP allow you to telephone to the UK absolutely free or send SMS for 5 cents. ( 2009 rates )

DNS

Every computer has its own IP address and a website is held by a computer, so if you want to visit  www.petervaldivia.com you should know the IP and type it into the browser bar, that is 87.98.255.2.

– How to know the IP-> Go to cmd and write ping and then the domain name-

It is really difficult to remember that number rather than petervaldivia . DNS server will sort it out.

Say you type www.petervaldivia.com into your browser’s address bar and hit return. Your computer will connect to your DNS server and it  just returns the IP for petervaldivia.

Dictionary:

Gateway. A gateway is a network point that acts as an entrance to another network.

The post TCP/IP Protocol first appeared on Tecnología ESO en Ingles.

]]>
Networks https://www.petervaldivia.com/networks/ Sun, 25 Jan 2015 10:15:11 +0000 http://www.petervaldivia.com/?p=315 Networks Tcp-Ip DNS Internet Conections  Networks.   Internet basics. The internet, is known and loved by everyone ( except those who are still waiting for something to download!) and it is the biggest growth area in Technology at the moment. The Internet is an international Network of Computers The Internet is basically a very big […]

The post Networks first appeared on Tecnología ESO en Ingles.

]]>

Networks.

 

Internet basics.

The internet, is known and loved by everyone ( except those who are still waiting for something to download!) and it is the biggest growth area in Technology at the moment.

The Internet is an international Network of Computers

The Internet is basically a very big Wide Area Network (WAN).  It was originally developed by the USthe internet Government to improve communication between its military computers.  If a cable is cut down, the information will take another path . It has  since grown into what we all know today.

To Connect you need Special Hardware and Software

1.- Most people access the Internet using a PC connected to a normal telephone line. Computers are attached to a telephone line via another piece of kit called a ADSL modem or DSL modem or usually called router.

2.- To connect to the Internet, you use your modem-router ( router ) to connect to an Internet Service Provider (ISP) — these companies have computers permanently connected to the Internet. All the information sent from your PC goes via the ISP. 3.- The two most important pieces of software you need are a web browser to display web pages, and an e-mail client, which transmits and receives e-mail from a PC. 4.- Web browsers sometimes need plug-ins — small programs — before they can play certain types of multimedia files, like videos for example.

Speed of access depends on three things

The speed of an Internet connection is measured in Megabits per second – Mbps ( i.e how much data is transferred per second). Three things determine the speed of access: Fiber optic.

1) Modem-Router Speed: Modern domestic modem-routers are able to work to 6Mb. There is a technology that make modems run at 100Mbits per second
2) The telephone line: In some cases, the line between home and the ISP server is an old copper cable with slow electronic controllers, so data goes very slow. In big cities like Madrid or Barcelona, they use optic fibres so the line allows data to “move faster”
3) The volume of traffic: The more people using the Internet, the slower the speed of access. In the UK the Internet is slower in the afternoon because that’s when it’s morning in the USA.
In Spain, Mondays are horrible for internet traffic!

 Networks. LAN and WAN

network cardA network is two or more computers connected together. Computers in a network can communicate with each other. The Internet is also a type of network. A computer needs a network interface card to connect to a network. ( see on the left. RJ45 Card ) There are two types of Network according to how big it is

LANS are small, local Networks

LANs (Local Area Networks) are the networks that you see in most offices, schools and some homes. They usually need the following hardware in order to operate: 1) A Network File Server is a dedicated computer that runs the software needed by the network and stores the files that users have created. 2) Terminals are individual workstations that give access to the network. Using a terminal gives access to the network’s software and files. 3) If a group of terminals share use of a printer then the system needs a Print Server. If two or more documents are sent to the printer at the same time the print server will put them into a queue. Users can then carry on with other work whilst waiting for the document to be printed. 4) For the network to operate data needs to be sent to and from all parts of the network. This can be done using wire cables or fibre optic cables, or via radio signals.

Note — a LAN doesn’t have to include a server. LANs can be as simple as two or three computers linked together for the sharing of files or software.

WANs are long  range Networks

Wan network

1) WAN is short for Wide Area Network. They are used when the computers that need to be connected together are in different places. 2) Like LANs, WANs need servers to operate the network, but users connect up to the network using modems, usually connected to the telephone system. Wireless technology such as microwaves or satellite can also be used. 3) WANs are used by companies who have employees working away from the firm’s main sites. A good example would be oil exploration engineers who work in remote parts of the world. They’re also used by firms who have a lot of teleworkers.

Advantage of using networks: 1) Peripherals such as printers can be shared amongst many different users.

2) Terminals are cheapper than stand-alone PCs

3) Software can be shared amongst different users

4) Communication across the network is cheaper and fast

Disadvantages of using networks

1) Cabling can be expensive to  install and replace

2) A fault with the server will prevent the whole network from working.

3) Security measures are needed to restrict access to the network.

4) WANs are vulnerable to hackers and virures.

 WLAN – Wiretess network

wireless network

Wireless (WIFI) networks are just like fixed LANs but instead of using cables, devices are linked by radio waves. Each computer in a wireless network requires a wireless network interface card (MC). These can be built in or  you can use plug-in adaptors. These allow each component in the network to communicate with a wireless access point (AP) to create a wireless local area network (WLAN).

APThe AP ( image on the left ) operates like a router in a fixed LAN. It also provides a bridge which plugs into the  hub of a fixed LAN allowing both fixed and wireless users to talk to each other. If your LAN is connected to the Internet, the WLAN can also use it. If not, you can connect the WLAN to the Internet via an ADSL or cable  modem. Nowadays, The Ap and the modem are integrated into a single modem-router like the one shown in the next imagewifi modem router

What are the advantages of a wireless network?

You don’t need cabling. In older buildings, it can be expensive to install cables and access points. With WiFi, one access point can cover an entire floor or even a building. You can work anywhere within range of the access point. On a sunny day, you could work outside. You can make any room in the house your study. There are now WiFi hotspots in hotels, libraries and airports so you can link to a network away from home or your office.

There are disadvantages.

Fixed LANs can run at 1000 Mbps. Wireless networks are much slower and the further you are from an access point, the slower the rate. Although there are savings on the cost of cabling, wireless NiCs are  a bit more expensive than the wired versions. Then there is the problem of interference, if a neighbour is using the same channel, and security. Other users may be able to intercept your data. Encryption programs like Wired Equivalent Privacy (WEP) can help.

Dictionary:

ADSL modem or DSL modem. Like other modems it is a type of transceiver and it is used to connect a single computer to a DSL phone line, in order to use an ADSL service.

The post Networks first appeared on Tecnología ESO en Ingles.

]]>
Calc The spreadsheet of Openoffice https://www.petervaldivia.com/openoffice-spreadsheet/ Sun, 25 Jan 2015 10:07:42 +0000 http://www.petervaldivia.com/?p=311 Calc. The spreadsheet of Openoffice   The spreadsheet component of OpenOffice is called Calc. With this program you can enter numerical data and then run the program to produce certain results, for example, you can calculate how much you spend on your mobile in a month if you have the data: The number of calls, […]

The post Calc The spreadsheet of Openoffice first appeared on Tecnología ESO en Ingles.

]]>

Calc. The spreadsheet of Openoffice

 

The spreadsheet component of OpenOffice is called Calc. With this program you can enter numerical data and then run the program to produce certain results, for example, you can calculate how much you spend on your mobile in a month if you have the data: The number of calls, the time of each call and the rate per minute. A major advantage of spreadsheets is that the data is easier to alter. If the mobile company changes the rate per minute, changing just one item of data in your spreadsheet means all the work is done! We’ll see it now in some exercises.

Sheets and cells

A Spreadsheet is made up of a number of sheets ( we will work with just one sheet ) and every sheet contains a block of cells arranged in columns and rows. These cells contain the individual elements, that is, numbers, formulas, text, etc— which make up the data to be displayed and later manipulated. In the example of the mobile, cell1 contains the minutes you have spent talking to your friend, cell2 the
hang up rate  and cell3 the rate per minute. The sheet manipulates the data to display the total cost in cell4, that is:

Total cost =  cell2 + ( cell1* cell4
)

This formula should be placed in cell5

Each spreadsheet can have several sheets and each sheet can contain many cells. In Calc, every sheet can have 65,536 rows and 245 columns, this gives us more that 16 million individual cells per sheet. I have the feeling that we won’t need 2 or 3 million cells in our project !

What does a Sheet look like?

When a spreadsheet is started, the window looks like the next image
main calc windows

Let’s put in plain words  those concepts:

  • The Title bar shows the name of the current spreadsheet.  When you save a new file, you are prompted
    to enter a name for your spreadsheet.
  • The Menu bar. When you choose one of the menus, a submenu appears with other options.
  • The Standard toolbar.  It provides a wide range of common commands and functions
  • The Formatting toolbar. Two rectangular areas: Font Name and Font Size The Formula bar.  Rectangular area in which mathematical formulas can be added

Cells are the intersections of columns and rows. They hold the data. Column and row headers. Every cell is identified by a column and row reference.

Starting new spreadsheets and saving spreadsheets.

Steps to open a new spreadsheet:

1. From the menu bar—Click File and then go for New -> Spreadsheet.

2. After the work is done, it  can be saved. Click File and then go to  Save. A new window will ask you for a name
to identify your file.

 Inserting columns and rows

A single column can be added using: Insert-> Columns. Do the same if you want to add a row.

We said that there are lots of columns and rows on a spreadsheet. Adding row and columns is important when you
need to add information to a sheet once it is finished.

Multiple rows or columns can be inserted at the same time rather than inserting them one at a time. For example, to
add three rows, go to the columns header and highlight three of them by holding down the left mouse button. Then, click
on the right mouse button and click on Insert rows.

If you need to delete a single column or row, follow these steps :

1. Select the  row or column.

2. Right-click on the  row or column.

3. Select Delete Row or Delete Columns from the pop-up (
small window )  menu.

Calc Formulas Tutorial

Let’s make a basic formula in a simple spreadsheet. The formula will calculate how much you pay just for dialing a
number on your mobile ( if the person you want to speak to answers your call ) It is necessary to multiply the date of two cells. In our case, these cells are A4 and B4

What you have to do is:

1. click in the cell you want to insert the formula into

2. Go to formula and select this command

3. Choose in Category -> Mathematical and later Product

The window  will look like this:

calc formula

Now, click on Next, click on Number 1 and select cell A4, then click on Number 2 and select CellB4. Now, once you have
clicked on OK, the formula bar will show PRODUCT(A4;B4).
Now, try to insert some data intoeither cell and the data in cellC4 will change when you change either A4 or B4.

Great, we have done our first Spreadsheet! Important.
Calc formulas always begin in the cell where you want the answer to appear. If you want to create a new formula
without using the formula menu, you ALWAYS start by typing the equals sign. In this case, you may use the following
mathematical operator:

The mathematical operators used in Calc formulas are similar to the ones used in maths class.

  • Plus sign ( + )  for
    Addition
  • Minus sign ()  for
    Subtraction
  • Asterisk (* )  for
    Multiplication
  • Forward slash ( / )  for
    Division
  • Exponentiation -> caret (^
    )

If you have a long formula with various type of operators, apply the same techniques as you do in your maths class, so:

Any operation contained in brackets ( () )
will be carried out first. The next priority Operator is the exponents.After that, multiplication  or division  operations (
equal importance ) . The same goes for the subtraction and  addition operations.

Example of Office If you need to create  graphs for class  presentations, OpenOffice Calc  has several graph
templates available.

Let’s see it in a budget example. Create a new spreadsheet to generate a personal budget by entering data
descriptions such as electricity, telephone bill, water supply, groceries,

mortgage
, holidays, restaurantscar insurance , car Loan,  etc  into column A and then the money spent into
Column B. Once you have finished run a formula on column B to Sum all this data. When you click into the simbol SUM (
in the formula bar ) a rectangular area will be highlighted and you will be able to modify the data and sum it. See next
image:

home budget with calc

Now, Highlight the areas you would like to include in the chart ( both column A and Column B ) and then click Insert
-> Chart. In the new window, choose a chart type and the graphic will appear on the right. You can move it anywhere
on the screen. We should have something like this:

bugbet chart

Exercise 1.

A serial circuit has 4 resistors of 50Ω , 70Ω , 80Ω and 100 Ω. If those are
connected to a 4,5 battery, make a Spreadsheet to calculate voltage across  All resistors, that is, V1, V1, V3 and V4 ,
the current through the resistors and the power in every resistor.

Be careful. In the format cell, if you select ( in Options ) decimal places to 2 you should have o.o2 for the
current (4.5/300), so, if you get a higher number, like 3, you have got it wrong. See the next two images:

decimal places in cell 1

decimal places in cells 2

The final screen …

serial circuit spreadsheet

 

Dictionary:

Mortgage: A temporary,
conditional pledge of property to a creditor as security
for performance of an obligation or repayment of a debt.
! This word should be said if
yours parents are around

The post Calc The spreadsheet of Openoffice first appeared on Tecnología ESO en Ingles.

]]>
Inkscape https://www.petervaldivia.com/inkscape/ Sun, 25 Jan 2015 09:43:10 +0000 http://www.petervaldivia.com/?p=302 Computer Grafics Gimp Inkscape   Inkscape. Vectorial graphics program   This is the other big graphics program using mathematical formulas. The first example is to create a toothed wheel or gear to make a simple mechanical transmission. Let’s star with a small manual 1st Path Operations There are a number of commands which we can use to […]

The post Inkscape first appeared on Tecnología ESO en Ingles.

]]>

Inkscape. Vectorial graphics program

 

inkscape

This is the other big graphics program using mathematical formulas. The first example is to create a toothed wheel or gear to make a simple mechanical transmission. Let’s star with a small manual

1st Path Operations

There are a number of commands which we can use to form new forms from two or more forms. The idea is: You have a rectangle and a circle and if you, for example, add or mix them together, you can create something like a “Chupachus”. Do you get the idea?

1stUnion:union (Ctrl++):  A new path (form) is created, containing all the interior areas of the original paths. The path Union

2nd Difference: ->path->Difference or (Ctrl+-): The difference of two paths. The area of the top path ( red area ) is removed from the bottom path ( blue area).

The path Difference operation.

3rd  Intersection: The new path encloses the common area of the original paths.

The path Intersection operation.

4th   Exclusion:  The new path is created containing both areas except  the non-overlapping area.

The path Exclusion operation.

A bit of practice:

Drawing a Gear

step 11st  Step: Go to File->new->Default. Then go to Effects->Render->Gear. Have a look at  image at the image on the left.

2nd  Step: In the Gear menu, set the following values:

Number of teeth: 25:

Circular pitch: 20

Pressure angle: 20

3rd  Draw a rectangle and adjust it in the middle of the wheel. Use ->Object->Align  and distribute ( see figure 1 ). Red marks. Duplicate that rectangle and rotate it 90º. Then align all the objects (except the wheel )

4th

Step 5: Now select a rectangle and the circle ( Use letter cap + the object ). Later go to Path->Difference.

Difference. Repeat with the other rectangle and the circle. The next image shows how that piece should be.

step 5

another cycle in the wheel

Step 6: Align all the objects and create a small circle in the middle of the wheel,( be sure X and Y have the same value ). Then align it in the centre and make another union.

Step 7: A last circle for the axle to go into and colour the wheel

Moving gears

First of all go to the inkscape program and open a new file.

Step 1: Go to ->File->New_> Default

Step 2: Create the fist toothed wheel. Go to ->Effects->Render->Gear, as shown in the next image

wheel teeth

Step 3: A menu will be opened to set the gear parametres. We are going to draw three gears with 6, 20 and 10 teeth. Select the number of wheel teeth as 20, circular pitch and pressure angle to 10. Repeat for the rest of the gears.

Step 4: Now that you have three gears, move them around in order to adjust themin relation to each other. Later decorate the circles with different colours.

Step 5: The wheels will be moving all the time. So if you don’t centre the cycles, when the gear starts to turn the gear will be moving to the left or to the right, so it is very important to centre the axles. Once you have added the circle, select both by clicking on the Capital letter key + the object, so press that Key and with the mouse select the objects you want to connect.

Later Go to ->Object->Align and distribute. In the next image, the alignment of the vertical axis and the alignment of the horizontal axis are marked by a red rectangle. Now we click on ‘Group selected objects’ to “glue ” all of them together ( this is highlighted in green on the image below)

Figure 1 

Step 6: You can eliminate the outer line by selecting the nodes. Click on the lefthand menu on “Edit path by nodes”. Then cut out the nodes you want to eliminate

Step 8: Go to Object-> Transform -> Rotate and put in a value to turn the gear clockwise. The question is what value? The appearance of movement we have to give to the gear is produced by a number of images, one after another, enough to move the teeth from one position to the next. Once the teeth reach their starting point again, the first image is repeated and so on. Let’s divide the path between the first position and the last position in 8 frames, so:

• Gear with 10 teeth ——————> 360: 10 = 36º-> 36/ 8 frames = 4.5 ( positive rotation )

• Gear with 20 teeth ——————> 360: 20 = 18º -> 18/ 8 frames = 2.25 ( negative rotation )

• Gear with 6 teeth ——————> 360: 6 = 60º -> 60/ 8 frames = 27.5 ( positive rotation )

Step 9: Select the 10 toothed wheel and rotate it 4.5. Then do the same with the rest of the gears. Save as a bit map with extension png . It is very important to save it as png because png allows transparency and we have to make a gif animation. So the first frame will be saved as frame1.png

Step 10: Repeat step 9 adding another rotation to every gear. Save as frame2.png

Step 11: Open Gimp and open file frame1.png. Then open as layer frame2.png and frame3.png…

Step 12: Now you should have 8 layers. Save as wheel-teeth.gif ( animation image ) and set the delay between frame to 50 milliseconds and the frame disposal to ” One frame per layer( replace )” Finally we have:

wheelteeth

Pacman or “Come-coco”

pacman

Have you ever played the Come cocos game. Probably, if you are a teenage the answer is no, but it was the most popular video game in the 80s This exercise is very good for learning how to manage paths, so go ahead and design your favourite pacman. Step1: Open a new file in inkscape and draw the PacMan body. The process starts with some node editing, which is the hardest part. For this, draw a circle using the ellipse tool ( For a perfect cycle, select the object and take a good look at width and height above, in the principal menu. Both values should be equal ), then go to Path-> Object to Path to convert the circle into a path. We are going to work with the outer line. The upper half of the circle is ok but the other half has to be modified. To do this place the mouse near the left and right node and add (by double-clicking) two nodes near the extreme left and right nodes ( see next figure)  pacman 1º step Step 2:Select one of the newly created nodes and drag it to the bottom in order to create a vertical line. Repeat for the other node. Now add two nodes at the bottom of pacman. Move them upwards as shown.

pacman 2

Step 3: Select the newly created right node and the bottom node and add two more nodes at both sides of those nodes. Play with those nodes to create soft lines ( Before we had lines and with this process we have curves) Do the same for the left node at the bottom. Now we have the Legs of our pacman Step 4:The eyes: to do this, draw a white and a black circle and duplicate. Do not align the cycles, just move the black one down and to the right.  

Step 5: A touch of reality. Duplicate the ghost shape ( select the body and click control + C, later click on Control + V ) Go to the copy layer and change the colour to black. Give a radial gradient to that layer. Select Fill and Stroke -> Fill->Radial gradient On the menu on the left, select the gradient icon. Select the centre point and set it to white ( at the bottom there is a colour selection sample. Then go to the opposite point and do it again, but this time, select the colour as black. Now, go to the Fill and Stroke menu and set the opacity to 45%. Align both layers ->Object->Align and distribute. The pacman is now as shown in the next image. Step 6: Creating a shadow. Now, for increased realism, add a black ellipse at the bottom of the pacman, give it a black background and use a radial gradient going from solid black at the centre to white the margins. Set the opacity to 40 %.

Here is our blue pacman.blue pac man

Now, an English Pacman friend

Step 1: Download a Union Jack (British) flag . Open the pacman in the same file. The flag is a bitmap file and to convert it to a vector image go to ->Path->trace bitmap.

Step 2: Select just the body of the pacman and separate from the Pacman. Now change the fill to transparency. In Stroke Style increase the thickness of the outer line and duplicate. Have a look at the next image

Step 3: Select the flag and the outline and go to ->Path->Intersection. Doing it we generate an english Pacman. The problem is that that image has lost the outline line so use the copy, and selecting both, align as usual. Add the shadow and eyes.

Our English Pacman. But something is missing

Now, a real English Pacman and its Spanish friend

Note. In the case of the Spanish pac man we have to use a Object->Pattern->Object to pattern. Doing that we can create a pattern to fill the pac man form. The process is identical to that described before but in this case we have chosen the Spanish flag and used it to create a pattern to fill the Pacman Exercise: Create an “Extremeño Pacman” and for those who want to improve their inkscape skills, give him a hat or something similar.

Dictionary::

Paths : Paths are arbitrary shaped objects.

Wander: move about without any destination

Collide: Crash together with violent impact; eg. “Two meteors collide

The post Inkscape first appeared on Tecnología ESO en Ingles.

]]>