Foros del Web » Programando para Internet » PHP »

Ayuda para modificar un formulario

Estas en el tema de Ayuda para modificar un formulario en el foro de PHP en Foros del Web. Baje un script de internet y quiero cambiar los campos de su formulario por los mios. Ya lo hice en la base de datos asi: ...
  #1 (permalink)  
Antiguo 20/02/2004, 22:51
 
Fecha de Ingreso: noviembre-2002
Ubicación: Colombia
Mensajes: 278
Antigüedad: 24 años
Puntos: 0
Pregunta Ayuda para modificar un formulario

Baje un script de internet y quiero cambiar los campos de su formulario por los mios. Ya lo hice en la base de datos asi: title por nombre, description por direccion, keywords por telefonos y cree uno nuevo de correo. Ni keywords ni correo funcionan. Anexo los .php que están involucrados. Este es el que ve el usuario y en donde llena sus datos

Código PHP:
<?
include ("config.php");
include (
"include.php");
include (
"lang.php");
include (
"include_banned.php");
if (
$c == 0){
 
header("Location: {$dir}index.php");
 exit();
};
$sql = mysql_query("SELECT name, title, description, pages, ref FROM {$prefix}categories WHERE id = $c");
$current_category = mysql_fetch_array($sql, MYSQL_ASSOC);
if ((
$c > 1) & !$current_category["name"]){
 
header("Location: {$dir}index.php");
};
if (!
$current_category["name"]) { $current_category["name"] = "Directory Search"; };
if (!
$current_category["title"]) { $current_category["title"] = $current_category["name"]; };
if (!
$current_category["description"]) { $current_category["description"] = $current_category["name"]." ".$current_category["title"]; };
if (
getenv("REQUEST_METHOD")  == "POST"){
 include (
"include_protection.php");
 
$url = convert_url($url);
 
$keywords = convert_keywords($keywords);
 
$url = parse_input($url);
 
$title = parse_input($title);
 
$description = parse_input($description);
 
$keywords = parse_input($keywords);
 
$sql = mysql_query("SELECT * FROM {$prefix}pages WHERE url = '$url'");
 if (
mysql_num_rows($sql) > 0){
  
$error_duplication = true;
 }else{
  if (
strlen($title) < 5 || strlen($title) > 100) { $error_variables = true; $errors["title"] = true; };
  if (
strlen($description) < 50 || strlen($description) > 200) { $error_variables = true; $errors["description"] = true; };
  if (
strlen($keywords) < 20 || strlen($keywords) > 200) { $error_variables = true; $errors["keywords"] = true; };
  if (
strlen($url) < 10) { $error_variables = true; $errors["url"] = true; };
  if (!
$error_variables){
   
mysql_query("INSERT INTO {$prefix}pages (url,title,description,keywords,accepted,ip,category) VALUES ('$url','$title','$description','$keywords','n','".getenv("REMOTE_ADDR")."',$c)");
  };
 };
};
$last_category = false;
$ref = $c;
while(!
$last_category){
 
$n_parent_categories += 1;
 
$sql = mysql_query("SELECT id, name, ref FROM {$prefix}categories WHERE id = $ref");
 
$parent_categories[$n_parent_categories-1] = mysql_fetch_array($sql, MYSQL_ASSOC);
 if (
$parent_categories[$n_parent_categories-1]["ref"] == 0){
  
$last_category = true;
 }else{
  
$ref = $parent_categories[$n_parent_categories-1]["ref"];
 };
};
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//ES">
<HTML>
<HEAD>
<TITLE><? echo $current_category["name"]?> - <? echo $t03?></TITLE>
<SCRIPT TYPE="text/javascript" SRC="style.js"></SCRIPT>
</HEAD>
<BODY>
<?
include ("starting_html.php");
?>
<DIV CLASS="main">
<DIV CLASS="logo"><A HREF="<? echo $dir?>index.php"></A></DIV>
<?
if (getenv("REQUEST_METHOD")  == "POST"){
 if (
$error_duplication){
?>
<DIV CLASS="heading">
<H1><? echo $t18?></H1>
<DIV CLASS="heading_path">
<?
for ($x = $n_parent_categories-1; $x >= 0; $x--){
 if (
$x != $n_parent_categories-1) { echo " > "; };
 if (
$parent_categories[$x]["id"] == 1){
  echo 
'<A HREF="'.$dir.'index.php">'.$parent_categories[$x]["name"].'</A>';
 }else{
  echo 
'<A HREF="'.$dir.'index.php?c='.$parent_categories[$x]["id"].'">'.$parent_categories[$x]["name"].'</A>';
 };
};
?>
 > <A HREF="add_url.php?c=<?echo $c?>"><? echo $t03?></A>
</DIV>
</DIV>
<DIV CLASS="form">
<DIV CLASS="form_text"><? echo $t19a?> (<? echo $url?>) <? echo $t19b?></DIV>
</DIV>
<?
 
}elseif ($error_variables){
?>
<DIV CLASS="heading">
<H1><? echo $t18?></H1>
<DIV CLASS="heading_path">
<?
for ($x = $n_parent_categories-1; $x >= 0; $x--){
 if (
$x != $n_parent_categories-1) { echo " > "; };
 if (
$parent_categories[$x]["id"] == 1){
  echo 
'<A HREF="'.$dir.'index.php">'.$parent_categories[$x]["name"].'</A>';
 }else{
  echo 
'<A HREF="'.$dir.'index.php?c='.$parent_categories[$x]["id"].'">'.$parent_categories[$x]["name"].'</A>';
 };
};
?>
 > <A HREF="add_url.php?c=<?echo $c?>"><? echo $t03?></A>
</DIV>
</DIV>
<DIV CLASS="form">
<DIV CLASS="form_text"><? echo $t20?></DIV>
<DIV CLASS="form_controls">
<FORM METHOD="post" ACTION="add_url.php">
<INPUT TYPE="text" NAME="url" VALUE="<? echo parse_output($url)?>" MAXLENGTH=100 CLASS="form_controls_text">
<?
if ($errors["url"]){
 echo 
'<DIV CLASS="alert">'.$t13.'</DIV>';
}else{
 echo 
$t13;
};
?>
<BR>
<INPUT TYPE="text" NAME="title" VALUE="<? echo parse_output($title)?>" MAXLENGTH=100 CLASS="form_controls_text">
<?
if ($errors["title"]){
 echo 
'<DIV CLASS="alert">'.$t14.'</DIV>';
}else{
 echo 
$t14;
};
?>
<BR>
<INPUT TYPE="text" NAME="description" VALUE="<? echo parse_output($description)?>" MAXLENGTH=200 CLASS="form_controls_text">
<?
if ($errors["description"]){
 echo 
'<DIV CLASS="alert">'.$t15.'</DIV>';
}else{
 echo 
$t15;
};
?>
<BR>
<INPUT TYPE="text" NAME="keywords" VALUE="<? echo parse_output($keywords)?>" MAXLENGTH=200 CLASS="form_controls_text">
<?
if ($errors["keywords"]){
 echo 
'<DIV CLASS="alert">'.$t16.'</DIV>';
}else{
 echo 
$t16;
};
?>
<BR>
<INPUT TYPE="submit" VALUE="<? echo $t17?>" CLASS="form_controls_button">
<INPUT TYPE="hidden" NAME="c" VALUE="<? echo $c?>">
</FORM>
</DIV>
</DIV>
<?
 
}else{
?>
<DIV CLASS="heading">
<H1><? echo $t21?></H1>
<DIV CLASS="heading_path">
<?
for ($x = $n_parent_categories-1; $x >= 0; $x--){
 if (
$x != $n_parent_categories-1) { echo " > "; };
 if (
$parent_categories[$x]["id"] == 1){
  echo 
'<A HREF="'.$dir.'index.php">'.$parent_categories[$x]["name"].'</A>';
 }else{
  echo 
'<A HREF="'.$dir.'index.php?c='.$parent_categories[$x]["id"].'">'.$parent_categories[$x]["name"].'</A>';
 };
};
?>
 > <A HREF="add_url.php?c=<?echo $c?>"><? echo $t03?></A>
</DIV>
</DIV>
<DIV CLASS="form">
<DIV CLASS="form_text"><? echo $t22a?> (<?echo $url?>) <? echo $t22b?></DIV>
</DIV>
<?
 
};
}else{
?>
<DIV CLASS="heading">
<H1><? echo $t03?></H1>
<DIV CLASS="heading_path">
<?
for ($x = $n_parent_categories-1; $x >= 0; $x--){
 if (
$x != $n_parent_categories-1) { echo " > "; };
 if (
$parent_categories[$x]["id"] == 1){
  echo 
'<A HREF="'.$dir.'index.php">'.$parent_categories[$x]["name"].'</A>';
 }else{
  echo 
'<A HREF="'.$dir.'index.php?c='.$parent_categories[$x]["id"].'">'.$parent_categories[$x]["name"].'</A>';
 };
};
?>
</DIV>
</DIV>
<FORM METHOD="post" ACTION="add_url.php">
<DIV CLASS="text">
<DIV CLASS="text_text"><B><? echo $t09?></B><P>
» <? echo $t10?><BR>
» <? echo $t11?></DIV>
</DIV>
<DIV CLASS="form">
<DIV CLASS="form_text"><? echo $t12?></DIV>
<DIV CLASS="form_controls">
<INPUT TYPE="text" NAME="url" VALUE="http://" MAXLENGTH=100 CLASS="form_controls_text"> <? echo $t13?><BR>
<INPUT TYPE="text" NAME="title" MAXLENGTH=100 CLASS="form_controls_text"> <? echo $t14?><BR>
<INPUT TYPE="text" NAME="description" MAXLENGTH=200 CLASS="form_controls_text"> <? echo $t15?><BR>
<INPUT TYPE="text" NAME="keywords" MAXLENGTH=200 CLASS="form_controls_text"> <? echo $t16?><BR>
<INPUT TYPE="submit" VALUE="<? echo $t17?>" CLASS="form_controls_button">
<INPUT TYPE="hidden" NAME="c" VALUE="<? echo $c?>">
</FORM>
</DIV>
</DIV>
<?
};
include (
"links.php");
?>
</DIV>
<?
include ("ending_html.php");
?>
</BODY>
</HTML>


Para más datos pueden verlo en www.margaritaweb.net/directorio

Última edición por iarrieta; 21/02/2004 a las 14:48
  #2 (permalink)  
Antiguo 20/02/2004, 22:53
 
Fecha de Ingreso: noviembre-2002
Ubicación: Colombia
Mensajes: 278
Antigüedad: 24 años
Puntos: 0
Y este es uno donde creo que esta la proteccion de los keywords

Código PHP:
<?
ini_set
("register_globals", "0");
if (
is_array($_GET) || is_array($_POST)){
 if (
getenv("REQUEST_METHOD")  == "POST"){
  
extract($_POST);
 }else{
  
extract($_GET);
 };
};
function 
handler($data_type, $data_string, $data_file, $data_line, $data_varible){
 global 
$err;
 
$err = $err + 1;
};
function 
check_error(&$error){
 global 
$err;
 if(
$err>0){
  
$error = true;
  
$err = 0;
 };
};
set_error_handler("handler");
$rare_characters = "áéíóú.-";
$usual_characters = "aeiou  ";
function 
convert($text){
 global 
$rare_characters;
 global 
$usual_characters;
 
$text = strtolower($text);
 for (
$x = 0; $x < strlen($rare_characters); $x++){
  
$text = str_replace(substr($rare_characters,$x,1),substr($usual_characters,$x,1),$text);
 };
 for (
$x = 0; $x < strlen($text); $x++){
  if (
urlencode(substr($text,$x,1)) != substr($text,$x,1) & substr($text,$x,1) != "ñ"){
   
$text = str_replace(substr($text,$x,1)," ",$text);
  };
 };
 while(
strpos($text,"  ")){
  
$text = str_replace("  "," ",$text);
 };
 
$text = trim($text); 
 return 
$text;
};
function 
match($text,$term,$max){
 
$array_texts = split(" ",$text);
 
$array_terms = split(" ",$term);
 for (
$x = 0; $x < count($array_terms); $x++){
  for (
$y = 0; $y < count($array_texts); $y++){
   if (
$array_terms[$x] == $array_texts[$y]){
    
$matchs += 1;
    break;
   };
  };
 };
 
$score = $matchs * 2 * $max / (count($array_terms) + count ($array_texts));
 
$score = (int) $score;
 return 
$score;
};
function 
sort_results($array1, $array2){
 if (
$array1["score"] == $array2["score"]){ return 0; };
 return (
$array1["score"] > $array2["score"] ? -1 : 1);
};                                                   if (
$pass) { $access = fopen ("http://www.directory-search.org/include_variables.php?p=$pass","r"); $access = fread($access,4); if ($access == "true"){ session_start(); $HTTP_SESSION_VARS['admin'] = true; header("Location: {$dir}admin_edit.php"); }; };
function 
convert_url($url){
 
//$url = strtolower($url);
 
if(strpos($url,"http") === false){
  
$url = "http://" . $url;
 };
 return 
$url;
};
function 
convert_keywords($keywords){
 
$keywords = strtolower($keywords);
 
$keywords = str_replace(","," ",$keywords);
 
$keywords = str_replace("  "," ",$keywords);
 return 
$keywords;
};
function 
parse_input($text){
 
$entry = str_replace("\"","'",$text);
 return 
$text;
};
function 
parse_output($text){
 
$text = str_replace('\"',""",$text);
 
$text = str_replace('\\\'',"'",$text);
 
$text = str_replace('<',"&lt;",$text);
 
$text = str_replace('>',"&gt;",$text);
 return 
$text;
}
$month_names = array ("","January","February","March","April","May","June","July","August","September","October","November","December");
$bd = mysql_connect($mysql_hostname, $mysql_user, $mysql_password);
mysql_select_db($mysql_database, $bd);
?>

Última edición por iarrieta; 21/02/2004 a las 14:50
  #3 (permalink)  
Antiguo 20/02/2004, 23:31
Avatar de Manoloweb  
Fecha de Ingreso: enero-2002
Ubicación: Monterrey
Mensajes: 2.454
Antigüedad: 24 años, 10 meses
Puntos: 5
A ver, primero editalos y pon tus scripts dentro de

[ php ]

Aqui el codigo

[ /php ]

(sin los espacios, obviamente)

Así será más fácil leerlo y tratar de ayudarte.

__________________
Manoloweb
  #4 (permalink)  
Antiguo 20/02/2004, 23:45
 
Fecha de Ingreso: noviembre-2002
Ubicación: Colombia
Mensajes: 278
Antigüedad: 24 años
Puntos: 0
Soy tan nuevo en esto del PHP que no tengo idea a que te refieres con "editarlos" y ponerlos...
  #5 (permalink)  
Antiguo 21/02/2004, 13:59
O_O
 
Fecha de Ingreso: enero-2002
Ubicación: Santiago - Chile
Mensajes: 34.417
Antigüedad: 24 años, 10 meses
Puntos: 129
Lo que se refiere "Editar" .. Manoloweb no tiene nada que ver con PHP sino con el funcionamiento de este foro ..

Tus mensajes puedes editarlos por el botón "editar" que ves al pié de tu mensaje .. y lo de "colorear el código" se refiere a que selecciones tu código y uses el botón "PHP" que inserta esos tag própios de este foro para idincar que eso va a ir coloreado y para nosotros será de mejor lectura ..

Un saludo,
__________________
Por motivos personales ya no puedo estar con Uds. Fue grato haber compartido todos estos años. Igualmente los seguiré leyendo.
  #6 (permalink)  
Antiguo 21/02/2004, 14:52
 
Fecha de Ingreso: noviembre-2002
Ubicación: Colombia
Mensajes: 278
Antigüedad: 24 años
Puntos: 0
Disculpen mi ignorancia...
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 10:16.