FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » script php with <img scr...../>
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
script php with <img scr...../> [message #180221] Thu, 31 January 2013 18:11 Go to previous message
sferreira1979 is currently offline  sferreira1979
Messages: 3
Registered: January 2013
Karma:
Junior Member
Hi,

i'm a portuguese's student and i'm trying to learn php by myself (with books and php.net) but i'm experiencing a problem on one of my test:
i have two files: registar_mail.php and captcha.php
captcha.php display an image witch should appear on my file registar_mail.php using
<img src="captcha.php"/> but the image doesn't appear :(
i have been looking for a solution in forums but i don't find anything witch works with me... i'm working with netbeans and xampp

////// script registar_mail.php//////////
!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=iso-8859-1" />
<title>MAILING LIST</title>
<style type="text/css">
@import url("estilo_mailinglist.css");
</style>
</head>
<body>


<?php
// Ligação à base de dados
//phpinfo();
include("ligacao_bd.php");

// verifica se foi clicado o botão de registar
if(isset($_REQUEST['registar'])) {

// verifica se o código captcha está correto
if($_SESSION['codigo'] == $_POST['codigo']){

// verifica se o campo de email está por preencher
if (empty($_POST['email'])) {
echo "<tr>O campo de endereço de correio eletrónico está vazio! </tr>";
echo "<tr><a href='registar_mail.php'>Clique para tentar de novo!</a></tr>";
}
else {

// verifica se endereço de correio eletrónico esta correto
$email = $_POST['email'];
if(filter_var($email, FILTER_VALIDATE_EMAIL)){

// regista o email
$sql = "INSERT INTO emails(endereco_email, data_registo) VALUES ( '$email' , NOW() ) ";
$consulta = mysql_query($sql);

echo "<table>";
echo "<tr>Obrigado por se registar!</tr>";
echo "<tr><a href='registar_mail.php'>Clique para voltar à página principal!</a></tr>";

} else {
echo "<tr>O endereço de correio eletrónico não é válido! </tr>";
echo "<tr><a href='registar_mail.php'>Clique para tentar de novo!</a></tr>";
} } } }
?>
<table width="800 px" border="0" align="center" class="tabela_geral" cellspacing="0">
<form id="form_registo" name="form_registo" action="registar_mail.php" method="POST">
<tr class="tabela_geral">
<td> Introduza o seu endereço de correio eletrónico para se registar na nossa<i> mailing list</i>!
</td>
</tr>
<tr><td class="tabela_geral">
Endereço de correio eletrónico: <input type="text" size=40 name="email">
</td><tr>
<td>
<img scr='captcha.php' alt="imagem ausente"/> <input type="text" name="codigo"/>
<img src="imagens/imagemcaptcha.png" width="230" height="50" alt="imagemcaptcha"/>

</td>
</tr>
<td>
<input type="submit" name="registar" value="Registar">
<input type="reset" name="apagar" value="Apagar"></td>
</form>
</table>
</body>
</html>

/////script captcha.php//////////////////
<?php
//inicia sessão
session_start();

//definição do tipo de imagem a gerar
header("Content-type:image/png");

//geração da chave
$chave=rand(0,500);

//codificação da chave e apresentacao de 8 carateres
$codigo=substr(sha1($chave),0,8);

$_SESSION['codigo']=$codigo;

//definicao imagem e cor
$imagem= imagecreatefrompng("imagens/imagemcaptcha.png");
$cores= imagecolorallocate($imagem, 255, 55, 0);

//centrar código na figura
imagestring($imagem, 5, 75, 20, $codigo, $cores);

//gerar imagem:Outputs or saves a PNG image from the given image.
imagepng($imagem);

//DESTRUIR IMAGEM
imagedestroy($imagem);

?>

could someone help me to understand what is the problem???

thanks :)
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: compatibility between php 5.3.21 and 5.3.15 for pgsql
Next Topic: change a string where have number after a word
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Sep 20 03:51:29 GMT 2024

Total time taken to generate the page: 0.04305 seconds