Ver Mensaje Individual
  #4 (permalink)  
Antiguo 01/07/2011, 21:32
Avatar de Fergusbra
Fergusbra
 
Fecha de Ingreso: mayo-2010
Ubicación: San Andrés Cholula, Puebla, Mexico, Mexico
Mensajes: 6
Antigüedad: 14 años
Puntos: 0
Respuesta: consultas y modificacion de regisros dreamweaver

ok. muchas gracias por los consejos!.
Tengo el código de mi botón buscar de la siguiente manera:
Código HTML:
<body>
<table width="100%" height="154" border="0">
  <tr>
    <td height="150">&nbsp;</td>
    <td><div align="center">MODIFICAR DATOS DE UN AMIGO</div></td>
    <td>&nbsp;</td>
  </tr>
</table>
<form name="input" action="amigosmodif1.php" method="get">
Introducrir la clave del amigo:
<input type="text" name="clave" />
<input type="submit" value="Buscar" />
</form>

</body> 
y en mi siguiente pagina llamada amigosmodif1.php tengo lo siguiente:
Código PHP:
<?php require_once('Connections/pruevamigo.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  if (
PHP_VERSION 6) {
    
$theValue get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  
$theValue function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch (
$theType) {
    case 
"text":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;    
    case 
"long":
    case 
"int":
      
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case 
"double":
      
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case 
"date":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;
    case 
"defined":
      
$theValue = ($theValue != "") ? $theDefinedValue $theNotDefinedValue;
      break;
  }
  return 
$theValue;
}
}

$editFormAction $_SERVER['PHP_SELF'];
if (isset(
$_SERVER['QUERY_STRING'])) {
  
$editFormAction .= "?" htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset(
$_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
  
$updateSQL sprintf("UPDATE amigos SET nombre=%s, apellidop=%s, apellidom=%s, direccion=%s, correo=%s WHERE clave=%s",
                       
GetSQLValueString($_POST['nombre'], "text"),
                       
GetSQLValueString($_POST['apellidop'], "text"),
                       
GetSQLValueString($_POST['apellidom'], "text"),
                       
GetSQLValueString($_POST['direccion'], "text"),
                       
GetSQLValueString($_POST['correo'], "text"),
                       
GetSQLValueString($_POST['clave'], "text"));

  
mysql_select_db($database_pruevamigo$pruevamigo);
  
$Result1 mysql_query($updateSQL$pruevamigo) or die(mysql_error());

  
$updateGoTo "amigomodif2.php";
  if (isset(
$_SERVER['QUERY_STRING'])) {
    
$updateGoTo .= (strpos($updateGoTo'?')) ? "&" "?";
    
$updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  
header(sprintf("Location: %s"$updateGoTo));
}

mysql_select_db($database_pruevamigo$pruevamigo);
$query_Recordset1 "SELECT * FROM amigos";
$Recordset1 mysql_query($query_Recordset1$pruevamigo) or die(mysql_error());
$row_Recordset1 mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 mysql_num_rows($Recordset1);
?>
<!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=utf-8" />
<title>Documento sin título</title>
</head>

<body>
<table width="100%" height="214" border="0">
  <tr>
    <td height="210">&nbsp;</td>
    <td><div align="center">MODIFICAR DATOS DE UN AMIGO</div></td>
    <td>&nbsp;</td>
  </tr>
</table>

<p>&nbsp;</p>
<form action="<?php echo $editFormAction?>" method="post" name="form1" id="form1">
  <table align="center">
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Clave:</td>
      <td><?php echo $row_Recordset1['clave']; ?></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Nombre:</td>
      <td><input type="text" name="nombre" value="<?php echo htmlentities($row_Recordset1['nombre'], ENT_COMPAT'utf-8'); ?>" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Apellido paterno:</td>
      <td><input type="text" name="apellidop" value="<?php echo htmlentities($row_Recordset1['apellidop'], ENT_COMPAT'utf-8'); ?>" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Apellido materno:</td>
      <td><input type="text" name="apellidom" value="<?php echo htmlentities($row_Recordset1['apellidom'], ENT_COMPAT'utf-8'); ?>" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Direccion:</td>
      <td><input type="text" name="direccion" value="<?php echo htmlentities($row_Recordset1['direccion'], ENT_COMPAT'utf-8'); ?>" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Correo:</td>
      <td><input type="text" name="correo" value="<?php echo htmlentities($row_Recordset1['correo'], ENT_COMPAT'utf-8'); ?>" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">&nbsp;</td>
      <td><input type="submit" value="Actualizar registro" /></td>
    </tr>
  </table>
  <input type="hidden" name="MM_update" value="form1" />
  <input type="hidden" name="clave" value="<?php echo $row_Recordset1['clave']; ?>" />
</form>

</body>
</html>
<?php
mysql_free_result
($Recordset1);

mysql_free_result($Recordset1);
?>
No se como hacer para que la clave que escribo en amigosmodif sirva para buscar la clave en la tabla y me lo muestre a la pagina amigosmodif1.php y por ende me muestre los datos de ese amigo para modificaros...
gracias espero haberme explicado bien.
Estuve leyendo un poco y encontré algo de registrar la variable que me manda el formulario pero no estoy seguro de como hacerlo.