Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Master #4

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions arreglos.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

?>
36 changes: 36 additions & 0 deletions ej1.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

$msg = "";
$txt1 = "";

if(isset($_POST["btn1"])){ //revisa si se preciono el botom
$txt1 = $_POST["txt1"];
$msg = "buenos dias $txt1";
}


?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Ejercicio 1 PHP</title>

</head>
<body>
<h1> Ejercicio 1 PHP </h1>
<form action="ej1.php" method="post">
<label for="txt1">Nombre</label>
<input type="text" id="txt1" name="txt1" value="<?php echo $txt1 ?> /">
</br>
<input type="submit" id="btn1" name="btn1" value= "procesar"/>
</form>
<div class="msg">
<?php echo $msg;?>
</div>

</body>



</html>
81 changes: 81 additions & 0 deletions ej2.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php
$numero1 = 0;
$numero2 = 0;
$iteraciones = 10;
$msg = "";


if(isset($_POST["btnPrc"])){ // elevar el numero 1 elevado al numero 2
$numero1 = intval($_POST["numero1"]);
$numero2 = intval($_POST["Numero2"]);
$newValue = $numero1;

for($i = 0; $i<$numero2; $i++){
$newValue *=$numero1;
}
$msg = "El valor: $numero1 a la potencia $numero2 es igual a $newValue";
}

if(isset($_POST["btnRev"])){ //escribir el numero 1 * iteracion a la inversa
$numero1 = intval($_POST["numero1"]);
$iteraciones = intval($_POST["iteraciones"]);
$contador = 1;

while($iteraciones > 0){
$msg .= "$contador ). producto" .($numero1 * $iteraciones) . "<br/>";
$contador ++;
$iteraciones --;

}
}
if(isset($_POST["btnFoc"])){ //factorial del numero 2
$numero1 = intval($_POST["numero1"]);
$factorial = 1;

for($i= $numero1;$i>=1;$i--){
$factorial*=$i;
}
$msg = "el factorial de $numero1 es $factorial";

}

//tarea no perder la iteracion seleccionada


?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title> formulario</title>
</head>
<body>
<h1> formulario</h1>
<form action="ej2.php" method="POST">
<!--<form action="ej1.php" method="GET">-->
<label for="txt1">Numero 1</label>
<input type="text" id="numero1" name="numero1" value="<?php echo $numero1; ?>"/>
<br/>
<label for="txt1">Numero 2</label>
<input type="text" id="Numero2" name="Numero2" value="<?php echo $numero2; ?>"/>

<br/>
<label for="txt1">Numero de iteraciones</label>
<select name="iteraciones" id="iteraciones">
<option value="10">10 </option>
<option value="20">20 </option>
<option value="50">50 </option>

</select>
<br/>
<input type="submit" name="btnPrc" value="btnPrc" id="btnPrc">
<input type="submit" name="btnRev" value="btnRev" id="btnRev">
<input type="submit" name="btnFoc" value="btnFac" id="btnFac">
</form>

<div>
<?php echo $msg; ?>
</div>

</body>
</html>
58 changes: 58 additions & 0 deletions ej5.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

session_start();
$_SESSION["username"]= "usuario";
//$_SESSION["click"] ++;



$contenidoSession = "";
function agregarSession($dato){
global $contenidoSession;
$contenidoSession = "gean";
return "AS contenido:" . $dato;
}

function eliminarSession($dato){
return "Es contenido: ". $dato;
}


if(isset($_SESSION["click"])){
if(isset($_POST["btnAdd"])){
$contenidoSession .= agregarSession($_POST["txtData"]);
$_SESSION["click"] ++;
}


if(isset($_POST["btnSubs"])){
$contenidoSession = eliminarSession($_POST["txtData"]);
$_SESSION["click"] ++;
}
}


?>

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title> Funciones y Session</title>
</head>
<body>
<h1>Funciones y el arreglo Session</h1>
<form action="ej5.php" method="POST">
<label for="txtData">Data</label>
<input type="text" id="txtData" name="txtData"/>
<br/>

<input type="submit" name="btnAdd" value="Agregar a la sesion" id="btnAdd">
<input type="submit" name="btnSubs" value="Eliminar de la sesion" id="btnSubs">

</form>
<div>
<?php echo $contenidoSession; ?>
</div>
</body>
</html>
71 changes: 71 additions & 0 deletions eje3.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php
//ejemplo de arreglo en PHP


$arreglo = array(1,2,3,4,"texto",true);
print_r($arreglo);

echo "<br/>";

$arreglo2 = array("nombre" => "Fulano",
"apellido" => "De Tal",
"edad" => 20);

print_r($arreglo2);


echo "<br/>";

$arreglo2[]="Esto no tiene llave";
$arreglo2["titulo"]="Sr.";

print_r($arreglo2);
echo"<br/>";

$personas = array();
$personas[] = $arreglo2;
$personas[]= $arreglo;

print_r($personas);


echo "<br/><hr/>";

foreach($personas as $key => $value){
echo "$key ->";
if(is_array($value)){
foreach($value as $key2=>$value2){
echo"<br/>.......$key2 -> $value2";
}

}else {
echo $value;
}

echo"</br>";

}



?>













<!--//arreglo = array();
FORMAS DE DECLARAR UN ARREGLO
$arreglo = array(1,2,3,4,5);
$arreglo = array("Nombre"=>"fulano","apellido"=>"DeTal");
$arreglo[]="14";
$arreglo["titulo"]="Sr.";
-->
Empty file added test.html
Empty file.
Empty file added testhtml.html
Empty file.