Foros del Web » Programando para Internet » PHP »

Boton y Funciones Ocultas?

Estas en el tema de Boton y Funciones Ocultas? en el foro de PHP en Foros del Web. hola, miren tengo este panel de control de unas cuentas: Código PHP: <div align="center"> <?php if ( $UserIsLoged == false ) { include( "core/lk/login_form.php" ); } else ...
  #1 (permalink)  
Antiguo 08/02/2010, 13:59
 
Fecha de Ingreso: julio-2009
Mensajes: 121
Antigüedad: 14 años, 8 meses
Puntos: 1
Exclamación Boton y Funciones Ocultas?

hola, miren tengo este panel de control de unas cuentas:

Código PHP:
<div align="center">
<?php
if ($UserIsLoged==false)
{
include(
"core/lk/login_form.php");
}
else
{

$lk=@$_GET['opt'];

echo 
"<table border=\"0\" id=\"unlogform\">
    <tr>
        <td align=\"center\" width=\"250\" height=\"20\">
            <a href=\"index.php?t=core/lk&f=lk\">.::Panel de Control::.</a><br>
        </td>
    </tr>
    <tr>
        <td  width=\"250\" align=\"center\" height=\"20\">
            <b>Bienvenido, <font color=\"red\">"
.$_SESSION['st_user']."</font>!</b>
            <form action=\"index.php\" method=\"POST\" >
            <input type=\"hidden\" name=\"fexit\" value=\"exit_t\">
            <input type=\"submit\" name=\"exit\" value=\"Salir\" >
            </form><br>
        </td>
   </tr>   
</table>"
;

echo
"<table width=\"400\" style=\"border-bottom:1px dotted #FF0000;\" >
<tr>
    <td align=\"center\">
        <a href=\"index.php?t=core/lk&f=lk&opt=chp\">.::Cambiar Password::.</a>
    </td>
</tr>
</table>"
;

if (
$lk=="chp")
{
?>
<br><h4>Complete los siguientes datos!</h4><br>
<script type="text/javascript">//<![CDATA[
function checkit(v)
{
    if (/^\w{4,15}$/.test(v))
    return true;
    else
    return false;
}
function checP(chf)
{
       if (chf.account.value=='')
    {
        alert("Jus neivedete Prisijungimo");
        chf.account.focus();
        return false
    }
    if (!checkit(chf.account.value))
    {
        alert("Patikrinkite ar ivedete Teisinga Prisijungima");
        chf.account.select();
        return false
    }
    if (chf.oldpassword.value=='')
    {
        alert("Neteisingai ivestas senas slaptazodis");
        chf.oldpassword.focus();
        return false
    }
    if (!checkit(chf.oldpassword.value))
    {
        alert("Neteisingai ivestas senas slaptazodis);
        chf.oldpassword.select();
        return false
    }
    if (chf.newpassword.value=='')
    {
        alert("Neteisingai ivestas naujas slaptazodis");
        chf.newpassword.focus();
        return false
    }
    if (!checkit(chf.newpassword.value))
    {
        alert("Neteisingai ivestas pakartotinas naujas slaptazodis");
        chf.newpassword.select();
        return false
    }
    if (chf.newpassword2.value=='')
    {
        alert("g");
        chf.newpassword2.focus();
        return false
    }
    if (chf.newpassword2.value==chf.newpassword.value)
    {
        return true
    }
alert("Blogai ivestas naujas slaptazodis"); chf.newpassword2.select()
return false
}
//]]></script>
<?php
$form_chp
="<table width=\"250\">
<FORM  method=\"post\" id=\"lkfont\" name=\"chf\" action=\"index.php?t=core/lk&f=lk&opt=chp\" onsubmit=\"return checP(this)\">
 <tr id=\"lkfont\">
  <td>Usuario:</td>
  <td><input maxlength=\"15\" name=\"account\" type=\"text\" size=\"15\"/></td>
 </tr>
 <tr id=\"lkfont\">
  <td>Contraseña Actual:</td>
  <td><input maxlength=\"15\" name=\"oldpassword\" type=\"password\" size=\"15\"/></td>
 </tr>
 <tr id=\"lkfont\">
  <td>Nueva Contraseña:</td>
  <td><input maxlength=\"15\" name=\"newpassword\" type=\"password\" size=\"15\"/></td>
 </tr>
 <tr id=\"lkfont\">
  <td>Nueva Contraseña:</td>
  <td><input maxlength=\"15\" name=\"newpassword2\" type=\"password\" size=\"15\"/></td>
 </tr>
 <tr id=\"lkfont\">
  <td colspan=\"2\" style=\"text-align: center;\"><br />
  <input type=\"submit\" name=\"chpass\" value=\"Cambiar\" /></td>
 </tr>
</form>
</table>"
;

if (!empty(
$_POST['chpass']))
    {
     
$stacc=mysql_real_escape_string($_POST['account']);
     
$stoldpass=$_POST['oldpassword'];
     
$stnewpass=$_POST['newpassword'];
     
$stopass=pass_encode($stoldpass);
     
$stnpass=pass_encode($stnewpass);
     
$stcheck=mysql_query("select * from accounts where login='$stacc'");
     
$stchek=mysql_num_rows($stcheck);
        if(
$stchek==0)
            {
            print 
"$form_chp";
            echo 
"<p ><br><br><b>Ya puede entrar con su nueva contraseña.</b></p>";
            }
            else
                {
                
$stmysql=mysql_fetch_array($stcheck);
                if (
$stmysql['password']==$stopass)
                    {
                    
$st=mysql_query("UPDATE accounts SET password='$stnpass' WHERE login='$stacc'");
                    print 
"<p style=\"color:#0000FF;\">Su contraseña antigua contraseña <font color=\"red\"><b>$stoldpass</b></font> fue cambiada por: <font color=\"red\"><b>$stnewpass</b></font>!</p>";
                    }
                    else
                        {
                        print 
"$form_chp";
                        print 
"<p ><br><br><b>Error al cambiar password.</b></p>";
                        }
                }
    }
    else
        {
        print 
"$form_chp";
        }

}


echo 
"<br><br><br><br><br><br><br><br><br><br><br>";
}
?>
</div>
lo cual hace cambiar la contraseña. ahora yo quiero agregarle otro boton, y que de la misma forma se me agrege el formulario de ese boton.

por ejemplo tmb cuando doy click a cambiar contraseña aparece esto
Código:
http://127.0.0.1/index.php?t=core/lk&f=lk&opt=chp
y ahi carga el formulario de cambiar password.

ahora lo que necesito es implementar ahi mismo es esto:

Código PHP:
<form method="post" action="unstuck.php" onsubmit="return checkform(this)">
<table>
  <tr>
  <td><b class="style5"><font face="Trebuchet MS">Jugador : </font></b></td>
  <td><font face="Trebuchet MS" size="1"><b>
  <input type="text" name="char" maxlength="150" id="char" size="20" /></b></font></td>
 </tr>
 <tr>
  <td colspan="2" style="text-align: center;">
  <font size="1" face="Trebuchet MS"><b><br />
  <input type="submit" name="submit" value="Mover jugador" /></b></font></td>
 </tr>
</table>
</form>
<?php include("data/conf/config.php");?>
<?php 
// connect to database
// unstuck some character using the name
mysql_query("UPDATE characters SET x=83410, y=147964, z=-3405 WHERE char_name = '".$_POST['char']."' ");
?>
ya lo he intentado de mil formas pero no me carga el otro boton ni si quiera con el link...

para que quede algo asi o algo parecido:
Código:
http://127.0.0.1/index.php?t=core/lk&f=lk&opt=unstuck
Les agradeceria si me podrian dar el codigo para ver como quedaria terminado y que le agregaron para que funcione asi aprendo a hacerlo para agregar otras cosas.
Desde ya muchas gracias.

Última edición por sk0rpi0n; 08/02/2010 a las 14:45
  #2 (permalink)  
Antiguo 09/02/2010, 18:54
Avatar de luis010182  
Fecha de Ingreso: julio-2009
Ubicación: Argentina - Capital Federal
Mensajes: 382
Antigüedad: 14 años, 9 meses
Puntos: 27
Respuesta: Boton y Funciones Ocultas?

Proba esto
Código PHP:
<div align="center">
<?php
if ($UserIsLoged==false)
{
include(
"core/lk/login_form.php");
}
else
{

$lk=@$_GET['opt'];

echo 
"<table border=\"0\" id=\"unlogform\">
    <tr>
        <td align=\"center\" width=\"250\" height=\"20\">
            <a href=\"index.php?t=core/lk&f=lk\">.::Panel de Control::.</a><br>
        </td>
    </tr>
    <tr>
        <td  width=\"250\" align=\"center\" height=\"20\">
            <b>Bienvenido, <font color=\"red\">"
.$_SESSION['st_user']."</font>!</b>
            <form action=\"index.php\" method=\"POST\" >
            <input type=\"hidden\" name=\"fexit\" value=\"exit_t\">
            <input type=\"submit\" name=\"exit\" value=\"Salir\" >
            </form><br>
        </td>
   </tr>   
</table>"
;

echo
"<table width=\"400\" style=\"border-bottom:1px dotted #FF0000;\" >
<tr>
    <td align=\"center\">
        <a href=\"index.php?t=core/lk&f=lk&opt=chp\">.::Cambiar Password::.</a><br>
       <a href=\"index.php?t=core/lk&f=lk&opt=unstuck\">.::Cambio 2::.</a>
 
    </td>
</tr>
</table>"
;

if (
$lk=="chp")
{
?>
<br><h4>Complete los siguientes datos!</h4><br>
<script type="text/javascript">//<![CDATA[
function checkit(v)
{
    if (/^\w{4,15}$/.test(v))
    return true;
    else
    return false;
}
function checP(chf)
{
       if (chf.account.value=='')
    {
        alert("Jus neivedete Prisijungimo");
        chf.account.focus();
        return false
    }
    if (!checkit(chf.account.value))
    {
        alert("Patikrinkite ar ivedete Teisinga Prisijungima");
        chf.account.select();
        return false
    }
    if (chf.oldpassword.value=='')
    {
        alert("Neteisingai ivestas senas slaptazodis");
        chf.oldpassword.focus();
        return false
    }
    if (!checkit(chf.oldpassword.value))
    {
        alert("Neteisingai ivestas senas slaptazodis);
        chf.oldpassword.select();
        return false
    }
    if (chf.newpassword.value=='')
    {
        alert("Neteisingai ivestas naujas slaptazodis");
        chf.newpassword.focus();
        return false
    }
    if (!checkit(chf.newpassword.value))
    {
        alert("Neteisingai ivestas pakartotinas naujas slaptazodis");
        chf.newpassword.select();
        return false
    }
    if (chf.newpassword2.value=='')
    {
        alert("g");
        chf.newpassword2.focus();
        return false
    }
    if (chf.newpassword2.value==chf.newpassword.value)
    {
        return true
    }
alert("Blogai ivestas naujas slaptazodis"); chf.newpassword2.select()
return false
}
//]]></script>
<?php
$form_chp
="<table width=\"250\">
<FORM  method=\"post\" id=\"lkfont\" name=\"chf\" action=\"index.php?t=core/lk&f=lk&opt=chp\" onsubmit=\"return checP(this)\">
 <tr id=\"lkfont\">
  <td>Usuario:</td>
  <td><input maxlength=\"15\" name=\"account\" type=\"text\" size=\"15\"/></td>
 </tr>
 <tr id=\"lkfont\">
  <td>Contraseña Actual:</td>
  <td><input maxlength=\"15\" name=\"oldpassword\" type=\"password\" size=\"15\"/></td>
 </tr>
 <tr id=\"lkfont\">
  <td>Nueva Contraseña:</td>
  <td><input maxlength=\"15\" name=\"newpassword\" type=\"password\" size=\"15\"/></td>
 </tr>
 <tr id=\"lkfont\">
  <td>Nueva Contraseña:</td>
  <td><input maxlength=\"15\" name=\"newpassword2\" type=\"password\" size=\"15\"/></td>
 </tr>
 <tr id=\"lkfont\">
  <td colspan=\"2\" style=\"text-align: center;\"><br />
  <input type=\"submit\" name=\"chpass\" value=\"Cambiar\" /></td>
 </tr>
</form>
</table>"
;

if (!empty(
$_POST['chpass']))
    {
     
$stacc=mysql_real_escape_string($_POST['account']);
     
$stoldpass=$_POST['oldpassword'];
     
$stnewpass=$_POST['newpassword'];
     
$stopass=pass_encode($stoldpass);
     
$stnpass=pass_encode($stnewpass);
     
$stcheck=mysql_query("select * from accounts where login='$stacc'");
     
$stchek=mysql_num_rows($stcheck);
        if(
$stchek==0)
            {
            print 
"$form_chp";
            echo 
"<p ><br><br><b>Ya puede entrar con su nueva contraseña.</b></p>";
            }
            else
                {
                
$stmysql=mysql_fetch_array($stcheck);
                if (
$stmysql['password']==$stopass)
                    {
                    
$st=mysql_query("UPDATE accounts SET password='$stnpass' WHERE login='$stacc'");
                    print 
"<p style=\"color:#0000FF;\">Su contraseña antigua contraseña <font color=\"red\"><b>$stoldpass</b></font> fue cambiada por: <font color=\"red\"><b>$stnewpass</b></font>!</p>";
                    }
                    else
                        {
                        print 
"$form_chp";
                        print 
"<p ><br><br><b>Error al cambiar password.</b></p>";
                        }
                }
    }
    else
        {
        print 
"$form_chp";
        }

}
#############
if ($lk=="unstuck"){
     
$formulario '<form method="post" action="index.php?t=core/lk&f=lk&opt=unstuck" onsubmit="return checkform(this)">
<table>
  <tr>
  <td><b class="style5"><font face="Trebuchet MS">Jugador : </font></b></td>
  <td><font face="Trebuchet MS" size="1"><b>
  <input type="text" name="char" maxlength="150" id="char" size="20" /></b></font></td>
 </tr>
 <tr>
  <td colspan="2" style="text-align: center;">
  <font size="1" face="Trebuchet MS"><b><br />
  <input type="submit" name="submit" value="Mover jugador" /></b></font></td>
 </tr>
</table>
</form> '
;
  if (!empty(
$_POST['char'])) {
    
#Aca colocas el codigo php que valida tu form
    #Accion a la base de datos
    
if( $resultadoDeAccionABase){
       
# si esta bien
       
echo "La accion se realizo correctamente";
    } else {
       
# si hay error
       
echo 'Ocurrio un error<br>';
       echo 
$formulario
    
}
  }else{
    echo 
$formulario;
  }

#############
echo "<br><br><br><br><br><br><br><br><br><br><br>";
}
?>
</div>

Espero que te sirva... :)
  #3 (permalink)  
Antiguo 10/02/2010, 05:06
 
Fecha de Ingreso: julio-2009
Mensajes: 121
Antigüedad: 14 años, 8 meses
Puntos: 1
Respuesta: Boton y Funciones Ocultas?

hola, muchisimas gracias por responder :) mira me sale este error :S

Código:
Parse error: syntax error, unexpected '}', expecting ',' or ';' in E:\WebServer\xampp\htdocs\core\lk\lk.php on line 190
ya me salio en varios intentos mios tambien >.<

Etiquetas: funciones, botones
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 13:48.