Me quedo así:
Código:
<!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 content="es-cr" http-equiv="Content-Language" />
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Test</title>
</head>
<body>
<?php
function escribir($x){
echo $x;
}
function msg($x){
echo '<script> alert("' . $x . '"); </script>';
}
?>
<form method="post">
<input name="Text1" style="width: 139px" type="text" /><br />
<input name="Button1" type="submit" value="Escribir" />
<input name="Button2" type="submit" value="Mensaje" />
</form>
<?php
$texto;
if(isset($_POST['Text1']))
$texto=$_POST['Text1'];
if(isset($_POST["Button1"])){
escribir($texto);
}
if(isset($_POST["Button2"])){
msg($texto);
}
?>
</body>
</html>
La intención era que dos botones ejecutaran funciones diferentes, parece que si esta funcionando, ahora, si recargo la pagina o doy enter, se repite la ultima acción, hay alguna forma de evitarlo? y también, así como lo hice es la forma correcta de hacerlo?