← Desenvolvimento

Preencher inputs através de um link

Lida 6047 vezes

Offline

João Godinho 
Membro
Mensagens 1755 Gostos 2
Troféus totais: 27
Trófeus: (Ver todos)
Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2 Level 1

O problema é que os meus conhecimentos em PHP são quase nulos, logo não sei como aplicar aquela função de que falas :s

Também tenho de começar a aprender qualquer coisa. Ver e editar as cenas é fácil, mas fazê-las... é que é pior.
Também não sei por onde começar...  :superlol:
Offline

Thomato 
Membro
Mensagens 4125 Gostos 3
Feedback +2

Troféus totais: 28
Trófeus: (Ver todos)
Apple User Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2

Código: [Seleccione]
function limpa($str)
{
 $lmp = strip_tags($str);
 $lmp = htmlspecialchars(mysql_real_escape_string($lmp));
 $lmp = str_replace("%20", "", $lmp);
 return $lmp;
}

<input type="text" value="<?php echo limpa($_GET['idade'];) ?>" />


Bem, tenho andado de volta disto que o escareta me deu, mas não tenho conhecimentos em PHP e não faço a mínima ideia de como aplicar isto.

Alguém com paciência que possa explicar como o fazer? :P Obrigado.
Offline

Diogo Pinto 
Administrador
Mensagens 4400 Gostos 371
Feedback +4

Troféus totais: 37
Trófeus: (Ver todos)
Avatar Search Level 6 Linux User Mobile User Super Combination Combination Topic Starter 50 Poll Votes 10 Poll Votes

Qual é a dúvida? já ta feito, basta pores isso a correr num ficheiro php... ...
Offline

Thomato 
Membro
Mensagens 4125 Gostos 3
Feedback +2

Troféus totais: 28
Trófeus: (Ver todos)
Apple User Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2


Qual é a dúvida? já ta feito, basta pores isso a correr num ficheiro php... ...
O problema é que me dá este erro:
Código: [Seleccione]
Parse error: syntax error, unexpected T_VARIABLE in /home/******/public_html/ficheiro.php on line 150
Sendo a linha 150 isto:
Código: [Seleccione]
$lmp = strip_tags($str);que é a terceira linha do código do escareta.
Offline

Gonçalo Martins 
Membro
Mensagens 229 Gostos 0
Troféus totais: 26
Trófeus: (Ver todos)
Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2 Level 1

Código: [Seleccione]
<input type="text" value="<?php echo limpa($_GET['idade']); ?>" />
Offline

Thomato 
Membro
Mensagens 4125 Gostos 3
Feedback +2

Troféus totais: 28
Trófeus: (Ver todos)
Apple User Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2

Código: [Seleccione]
<input type="text" value="<?php echo limpa($_GET['idade']); ?>" />
Obrigado :)

Agora tenho outra dúvida, existe alguma maneira de quando não for usado o &idade=x aparecer algum texto?
Offline

Gonçalo Martins 
Membro
Mensagens 229 Gostos 0
Troféus totais: 26
Trófeus: (Ver todos)
Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2 Level 1

Código: [Seleccione]
<input type="text" value="<?php  if(limpa($_GET['idade'])==""){echo "TEXTO";}else{echo limpa($_GET['idade']);} ?>" />
Offline

Thomato 
Membro
Mensagens 4125 Gostos 3
Feedback +2

Troféus totais: 28
Trófeus: (Ver todos)
Apple User Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2

Código: [Seleccione]
<input type="text" value="<?php  if(limpa($_GET['idade'])==""){echo "TEXTO";}else{echo limpa($_GET['idade']);} ?>" />
Obrigado :)