1061
C, C++, C#, Java, Visual Basic, HTML, PHP, CSS, Javascript, Ajax, Joomla, MySql y más / Re:AYUDA CON PHP URGENTE!!!!!!
« en: 21 de Diciembre 2013, 10:40 »
He borrado el mensaje que indicabas erróneo
Ahora Aprender A Programar está en Facebook. Noticias, novedades y mucho más. Síguenos en Facebook
Esta sección te permite ver todos los posts escritos por este usuario. Ten en cuenta que sólo puedes ver los posts escritos en zonas a las que tienes acceso en este momento.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Maratón</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<label>Edad
<input type="text" name="textedad" />
</label>
<p>
<label>Tiempo Anterior (minutos):
<input type="text" name="textta" />
</label>
</p>
<p>
<label>Sexo:
<select name="Sexo">
<option>Hombre</option>
<option>Mujer</option>
</select>
</label>
</p>
<p>
<label>Evaluar:
<input type="submit" value="Enviar" />
</label>
</p>
</form>
<?php
$edad=$_POST['textedad'];
$tiempo=$_POST['textta'];
$sexo=$_POST['Sexo'];
if ($_POST) {
echo '<br/>';
echo 'Datos: <br/>';
echo 'Sexo: '.$sexo.'<br/>';
echo 'Edad: '.$edad.'<br/>';
echo 'Tiempo anterior: '.$tiempo.' minutos <br/>';
}
if($sexo=="Mujer")
{
if ($tiempo<=180)
{
echo "Esta Seleccionada para el Maraton de La Yaguara";
}
else
{
echo "Lo Sentimos pero No Fue Seleccionada";
}
}
if ($sexo=="Hombre")
{
//Si es menor de 40
if ($edad<=40)
{
if($tiempo<=150)
{
echo "Esta Seleccionado para el Maraton de La Yaguara";
}
else
{
echo "No esta seleccionado";
}
}
//Si es mayor de 40
if ($edad>40)
{
if($tiempo<=175)
{
echo "Esta Seleccionado para el Maraton de La Yaguara";
}
else
{
echo "No esta seleccionado";
}
}
}
?>
</body>
</html>
<?php
// VALOR DE LA VARIABLE QUE DETERMINA EL FONDO
$determinadorFondo = "fondoA";
?>
<html>
<head>
<title>Portal web - aprenderaprogramar.com</title> <meta charset="utf-8">
<style type="text/css">
* {font-family: arial;}
h1 {margin: 0 auto; width: 800px; font-size: 52px; text-align: center; color:yellow;}
</style>
</head>
<body <?php if ($determinadorFondo =="fondoA") { ?>
style =" background-image: url(http://2.bp.blogspot.com/-WLgMgyrl-p0/TyqmaQzwRvI/AAAAAAAAQdA/YUNHPSicp3U/s1600/oldpaperscrolls5+BackgroundFairy.jpg);">
<?php } else if ($determinadorFondo=="fondoB") { ?>
style =" background-image: url(http://4.bp.blogspot.com/-RM_RbP9K90A/TwN9k05TMfI/AAAAAAAAQDM/6T5nDw7V6ss/s1600/magentafloral+BackgroundFairy.jpg);">
<?php } ?>
<h1>Ejemplo</h1>
</body>
</html>
import javax.swing.*;
import javax.swing.JOptionPane;
import javax.swing.JTextArea;
import java.io.*;
public class MenuEscribirLeer {
public static void main(String[] args) throws IOException{
String menu="MENU DE Escribir y Leer\n";
int n1,n2,n3;
int op=0;
menu+="1. Escribir\n";
menu+="2. Leer\n";
menu+="3. Fin\n";
menu+="Escoja Opción:\n";
while (op!=3){
op=Integer.parseInt(JOptionPane.showInputDialog(menu));
switch (op){
case 1:
ObjetoEscribir objeto1 = new ObjetoEscribir();
objeto1.crearCodigoEscribir();
break;
case 2:
ObjetoLeer objeto2 = new ObjetoLeer();
objeto2.crearCodigoLeer();
break;
case 3:
break;
}
}
} // cierre del public static void main Ojo !!!! //------------------
public static void escribir ()throws IOException{
// TODO code application logic here
String archivo="nombre.txt";
FileWriter fw= new FileWriter(archivo,true);
BufferedWriter bw= new BufferedWriter(fw);
PrintWriter pw= new PrintWriter (bw);
String nombre="";
int sueldo,edad;
nombre=JOptionPane.showInputDialog("digite nombre");
sueldo=Integer.parseInt(JOptionPane.showInputDialog("digite sueldo"));
edad=Integer.parseInt(JOptionPane.showInputDialog("digite edad"));
pw.println(nombre+"--__--"+sueldo+"--__--"+edad+"--__--");
JOptionPane.showMessageDialog(null,"los datos se guardaron EXCELENTE");
pw.close();
}
}
import javax.swing.*;
import java.io.*;
public class ObjetoEscribir {
public void crearCodigoEscribir() throws IOException {
// TODO code application logic here (algoritmo que escribe archivo)
String archivo="nombre.txt";
FileWriter fw= new FileWriter(archivo,true);
BufferedWriter bw= new BufferedWriter(fw);
PrintWriter pw= new PrintWriter (bw);
String nombre="";
int sueldo,edad;
nombre=JOptionPane.showInputDialog("digite nombre");
sueldo=Integer.parseInt(JOptionPane.showInputDialog("digite sueldo"));
edad=Integer.parseInt(JOptionPane.showInputDialog("digite edad"));
pw.println(nombre+"--__--"+sueldo+"--__--"+edad+"--__--");
JOptionPane.showMessageDialog(null,"los datos se guardaron EXCELENTE");
pw.close();
}
}
import javax.swing.*;
import java.io.*;
public class ObjetoLeer {
public void crearCodigoLeer() throws IOException {
// TODO code application logic here (algoritmo que lee archivo)
FileReader fr = new FileReader("nombre.txt");
BufferedReader br= new BufferedReader(fr);
String linea="";
linea=br.readLine();
while(linea!=null){
String vector[]= linea.split("--__--");
JOptionPane.showMessageDialog(null,"Nombre"+vector[0]+"\nsueldo1:"+vector[1]+"\nsueldo1:"+vector[2]);
linea=br.readLine();
}
}
}
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class ventanaConMenu extends JFrame {
//Variables de clase
private static Container contents;
/**
* Constructor.
*/
ventanaConMenu(int alto, int ancho) {
setTitle("Ventana");
setLocation(380, 50); //Colocación de la ventana
JPanel panel = new JPanel();
contents = getContentPane();
contents.add(panel, BorderLayout.CENTER); //Espacio central
construirMenu();
//panel.requestFocusInWindow();
pack();
setVisible(true);
}//Cierre del constructor www.aprenderaprogramar.com
/**
* Método que construye el menú e implementa acciones de respuesta
*/
public void construirMenu(){
// CREACION DE LA BARRA DE MENÚ
JMenuBar barraMenu = new JMenuBar();
setJMenuBar (barraMenu);
JMenu menuOpciones = new JMenu ("Opciones Menu");
barraMenu.add (menuOpciones);
// CREACION DE LOS ITEMS DE MENÚ
JMenuItem itemDetener = new JMenuItem("Detener");
menuOpciones.add (itemDetener);
JMenuItem itemContinuarPartida = new JMenuItem("Continuar");
menuOpciones.add (itemContinuarPartida);
JMenuItem itemNuevoJuego = new JMenuItem("Nuevo Juego");
menuOpciones.add (itemNuevoJuego);
JMenuItem itemCerrarPrograma = new JMenuItem("Cerrar Programa");
menuOpciones.add (itemCerrarPrograma);
//ACCIONES DE RESPUESTA A ELECCIÓN DE ITEMS DEL MENÚ IMPLEMENTADOS COMO MÉTODOS INTERNOS ANÓNIMOS
itemDetener.addActionListener(new ActionListener() { public void actionPerformed (ActionEvent evento){
System.out.println ("Invocación 1"); } } );
itemContinuarPartida.addActionListener(new ActionListener() { public void actionPerformed (ActionEvent evento){
System.out.println ("Invocación 2"); } } );
itemNuevoJuego.addActionListener(new ActionListener() { public void actionPerformed (ActionEvent evento){
System.out.println ("Invocación 3"); } } );
itemCerrarPrograma.addActionListener(new ActionListener() { public void actionPerformed (ActionEvent evento){
System.out.println ("Invocación 4"); } } );
}// Cierre del método construirMenu
} //Cierre de la clase
public class TestVentana {
public static void main(String[] Args) {
ventanaConMenu ventana1 = new ventanaConMenu(10,10);
/*www.aprenderaprogramar.com*/
}
}
Sobre la educación, sólo puedo decir que es el tema más importante en el que nosotros, como pueblo, debemos involucrarnos.
Abraham Lincoln (1808-1865) Presidente estadounidense.
aprenderaprogramar.com: Desde 2006 comprometidos con la didáctica y divulgación de la programación