chapta foutmelding word altijd weergegeven ipv alleen na een foute captcha

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Senior, Medior and Junior SAP HANA Developer

Vacature details Vakgebied: Software/IT Opleiding: Medior Werklocatie: Veldhoven Vacature ID: 12696 Introductie Our client is the world's leading provider of lithography systems for the semiconductor industry, manufacturing complex machines that are critical to the production of integrated circuits or chips. Our purpose is “unlocking the potential of people and society by pushing technology to new limits”. We do this guided by the principles “Challenge”, “Collaborate” and “Care”. Wat verwachten we van jou? SAP Certified Application Associate - SAP HANA Cloud Modeling (training and/or certification) Bachelor degree or higher Excellent understanding of SAP HANA (2.0 / Cloud), Data Modelling and writing

Bekijk vacature »

16/05/2012 19:20:02
Quote Anchor link
Hallo,

Ik heb een (simpel) upload systeem gemaakt met PHP en HTML. Om spam te voorkomen heb ik er een captcha op gezet. Alleen, de foutmelding die ik heb ingesteld (Je hebt een verkeerde code ingevoerd, probeer het opnieuw o.i.d.) word altijd weergegeven, in plaats van alleen als er een foute captcha ingevult is. Zou iemand mij kunnen vertellen wat ik verkeerd heb gedaan?

Hier gaat het fout:

if (md5($_POST['captcha_code']) != $_SESSION['captcha']) {

print "Vergeet niet de Captcha correct in te vullen";

} else {

//het upload gedeelte


Dit is mijn hele code:

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php

      
//zoeken naar map uploads // nog naar kijken want kan niet naar 777 toestemming zetten
    $dir = "up/";
    if (!is_dir($dir)) {
        mkdir ($dir, 0777);
    }


if (md5($_POST['captcha_code']) != $_SESSION['captcha']) {

print "Vergeet niet de Captcha correct in te vullen";


}
else {
      

 
    //na op upload klikken
if (isset($_POST['submit'])) {
    //uppen
    $uploaddir = "up/";
    $uploadfile = $uploaddir . basename($_FILES['file']['name']);
    //naam enzo
    if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile)) {
//zeggen dat t is gelukt
        print "<u><p style='color:red'>Het bestand ".$_FILES['file']['name']." is succesvol geupload. Je link:</u></p><textarea cols='50' rows='
 1' name='Obj'>http://up.boobytrapmedia.nl/"
.$_FILES['file']['name']."</textarea>  ";
    }
else {
    //error // moet nog echo met uitleg maken: if $error == ERROR_[error] dan uitleg printen
        print "Er is een fout opgetreden:<br>";
        print $_FILES['file']['error'];
        }
        }
        }
        
        //voor de debug
//debugging info:
//echo "info<br />";
//print_r ($_FILES);



        ?>


<html>
<head>
<title>Upload Host :: Boobytrap Media</title>
<link rel="stylesheet" type="text/css" href="up.css">
<script type="text/javascript">
function timeMsg()
{ var t=setTimeout("alertMsg()",3000);
} function alertMsg()
{ echo "Hello";
} </script>
</head>
<body onLoad="timeMsg()">
<FORM METHOD="LINK" ACTION="http://boobytrapmedia.nl/">
<INPUT TYPE="submit" VALUE="<- Back to home">
</FORM>

<div align="center"><div id="all">
<p>Kies een bestand om te uploaden.</p>
<form enctype="multipart/form-data" action="
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
<?php echo $_SERVER['PHP_SELF'];?>
" method="post">
<input type="hidden" name="1" value="9999999999999999" />
<input type="file" name="file" /><br /><br>
<hr width="180px"><br><BR>
<img name="captcha" src="captcha.php" alt="captcha" /><br>
<p>Neem de bovenstaande tekens correct over. <br>(alleen kleine letters en getallen)<br><br>
<input type="text" name="captcha_code" /><br /><br>
<input type="submit" name="submit" value="Upload"/>

</form>
</div></div>
</body>
</html>


alvast heel erg bedankt!
Art
 
PHP hulp

PHP hulp

29/03/2024 00:11:59
 
Toine vd P

Toine vd P

16/05/2012 19:27:18
Quote Anchor link
Je mist een isset() check, want als captcha_code niet geset is, is deze tenslotte ook niet gelijk aan de sessie-variant;

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
<?php
if (isset($_POST['captcha_code']) && md5(' // ...
?>
 

16/05/2012 22:54:05
Quote Anchor link
Dus als ik dat doe werkt het? dan zal ik het even proberen.
 
Obelix Idefix

Obelix Idefix

16/05/2012 22:56:15
Quote Anchor link
je mist volgens mij (ook) session_start(); boven aan je script.

Waarom md5 over een captcha code?

$_SERVER['PHP_SELF'] zou onveilig zijn. Laat dan liever leeg.
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.