Poll voegt niet toe in database...

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Roderik

Roderik

13/02/2005 00:12:00
Quote Anchor link
ik heb een poll van een website af alleen hij werkt niet tenminste hij word niet toegevoegt aan mijn database...:

script is beetje groot zijn 2 bestanden als het teveel overlast heeft snap ik dat dat word weggehaalt..
BTW: kheb database gegevens wel ingevuld maar hier zijn ze * ;)

adminpoll.php

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
<?php

?>

<html>
<head>
<title>Poll</title>

<style type="text/css">
body, code, table, td, pre { font-size: 8pt; color: #5D5D5D; font-family: Verdana, Arial, Helvetica, sans-serif; }
</style>
</head>
<body bgcolor="#F2F2F2">
<h1>
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
$mysql
= mysql_connect("localhost", "***", "***");
$database = mysql_select_db("***", $mysql);

include("admin.inc.php");
$admin = new wmadmin();
if(isset($HTTP_GET_VARS['a'])) {
    $a = $HTTP_GET_VARS['a'];
}
else {
    $a = "";
}



/**** TOEVOEGEN ****/
if($a == "toevoegen") {
    if(isset($HTTP_POST_VARS['submit'])) {
        $vraag = $admin->formdata($HTTP_POST_VARS['vraag']);
        for($x=1; $x<=10; $x++) {
            $keuze[$x] = $admin->formdata($HTTP_POST_VARS["keuze".$x]);
        }

        $actief = $admin->formdata($HTTP_POST_VARS['actief']);
        if(empty($vraag) || empty($keuze[1]) || empty($keuze[2])) {
            $admin->error(1, "toevoegen");
        }
else {
            $datum = time();
            @
mysql_query("INSERT INTO poll (vraag, actief, datum, keuze1, keuze2, keuze3, keuze4, keuze5, keuze6, keuze7, keuze8, keuze9, keuze10) VALUES ('$vraag', '$actief', '$datum', '".$keuze[1]."', '".$keuze[2]."', '".$keuze[3]."', '".$keuze[4]."', '".$keuze[5]."', '".$keuze[6]."', '".$keuze[7]."', '".$keuze[8]."', '".$keuze[9]."', '".$keuze[10]."')");
            $admin->bericht("Poll is toegevoegd.<br>\n<a href=\"adminpoll.php\">Terug</a>", 1);
        }

    }
else {
        $admin->openform("toevoegen");
        $admin->formtext("Vraag", "vraag", "", 200);
        for($x=1; $x<=10; $x++) {
            $admin->formtext("Keuze ".$x, "keuze".$x, "", 50);
        }

        $admin->formcheckbox("Actief", "actief", 1);
        $admin->sluitform("Toevoegen");
    }





/**** BEWERK ****/
} elseif($a == "bewerk") {
    $id = $admin->formdata($HTTP_GET_VARS['id']);
    if(isset($HTTP_POST_VARS['submit'])) {
        $vraag = $admin->formdata($HTTP_POST_VARS['vraag']);
        for($x=1; $x<=10; $x++) {
            $keuze[$x] = $admin->formdata($HTTP_POST_VARS["keuze".$x]);
        }

        $actief = $admin->formdata($HTTP_POST_VARS['actief']);
        $reset = $admin->formdata($HTTP_POST_VARS['reset']);
        if(empty($vraag) || empty($keuze[1]) || empty($keuze[2])) {
            $admin->error(1, "bewerk&id".$id);
        }
else {
            @
mysql_query("UPDATE poll SET vraag='$vraag', actief='$actief', keuze1='".$keuze[1]."', keuze2='".$keuze[2]."', keuze3='".$keuze[3]."', keuze4='".$keuze[4]."', keuze5='".$keuze[5]."', keuze6='".$keuze[6]."', keuze7='".$keuze[7]."', keuze8='".$keuze[8]."', keuze9='".$keuze[9]."', keuze10='".$keuze[10]."' WHERE id='$id'");
            if($reset == "1") {
                @
mysql_query("UPDATE poll SET antwoord1='0', antwoord2='0', antwoord3='0', antwoord4='0', antwoord5='0', antwoord6='0', antwoord7='0', antwoord8='0', antwoord9='0', antwoord10='0', gestemd='' WHERE id='$id'");
            }

            $admin->bericht("Poll is bewerkt.<br>\n<a href=\"adminpoll.php\">Terug</a>", 1);
        }

    }
else {
        $sql = @mysql_query("SELECT * FROM poll WHERE id='$id'");
        $list = @mysql_fetch_assoc($sql);
        $admin->openform("bewerk&id=".$id);
        $admin->formtext("Vraag", "vraag", $list['vraag'], 200);
        for($x=1; $x<=10; $x++) {
            $admin->formtext("Keuze ".$x, "keuze".$x, $list["keuze".$x], 50);
        }

        $admin->formcheckbox("Actief", "actief", $list['actief']);
        $admin->formcheckbox("Reset stemmen", "reset", 0);
        $admin->sluitform("Bewerk");
    }





/**** VERWIJDER ****/
} elseif($a == "verwijder") {
    $id = $admin->formdata($HTTP_GET_VARS['id']);
    @
mysql_query("DELETE FROM poll WHERE id='$id'");
    $admin->bericht("Poll is verwijderd.<br>\n<a href=\"adminpoll.php\">Terug</a>", 1);




/**** LIJST ****/
} else {
    $admin->bericht("<a href=\"adminpoll.php?a=toevoegen\">Poll Toevoegen</a><br><br>", 1);
    $admin->polllist();
}

?>

</h1>
</body>
</html>


admin.inc.php

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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php

class wmadmin {
    function
htmlparse($string){
        return htmlentities(trim($string), ENT_QUOTES);
    }

    function
bericht($string, $html=1) {
        if($html == 0) {
            $string = htmlparse($string);
        }

        echo $string."\n";
    }

    function
error($error=1, $actie) {
        if($error == 1) {
            echo "Er is iets niet ingevuld, <a href=\"adminpoll.php?a=".$actie."\">ga terug.</a>\n";
        }
    }

    function
polllist() {
        echo "<table width=\"50%\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\">\n";
            $sql = @mysql_query("SELECT id, vraag FROM poll ORDER BY id DESC");
            while($list = @mysql_fetch_assoc($sql)) {
                echo "<tr><td>".$this->htmlparse($list['vraag'])."</td><td width=\"50\"\><a href=\"adminpoll.php?a=bewerk&id=".$list['id']."\">bewerk</a></td><td width=\"50\"\><a href=\"adminpoll.php?a=verwijder&id=".$list['id']."\">verwijder</a></td></tr>\n";
            }

        echo "</table>\n";
    }

    function
openform($action) {
        echo "<form action=\"adminpoll.php?a=".$action."\" method=\"POST\">\n<table width=\"50%\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\">\n";
    }

    function
formtext($bericht, $naam, $value="", $lengte=50) {
        echo "<tr><td><b>".$this->htmlparse($bericht)."</b></td><td><input type=\"text\" name=\"".$naam."\" value=\"".$this->htmlparse($value)."\" maxlength=\"".$lengte."\"></td></tr>\n";
    }

    function
formcheckbox($bericht, $naam, $checked=1) {
        echo "<tr><td><b>".$this->htmlparse($bericht)."</b></td><td><input type=\"checkbox\" name=\"".$naam."\" value=\"1\"";
        if($checked == 1) {
            echo " checked";
        }

        echo "></td></tr>\n";
    }

    function
sluitform($submit) {
        echo "<tr><td></td><td><input type=\"submit\" name=\"submit\" value=\"".$submit."\"></td></tr>\n</table>\n</form>\n";
    }

    function
formdata($value){
        $quotes = get_magic_quotes_gpc();

        $value = trim($value);
        if($quotes == FALSE){
            $value = addslashes($value);
        }


        return $value;
    }
}

?>



wie kan mij helpen? :$
 
PHP hulp

PHP hulp

29/04/2024 09:41:19
 
Roy Bongers

Roy Bongers

13/02/2005 01:07:00
Quote Anchor link
zet eens achter die mysql_query("INSERT.....") or die(mysql_error()); En misschien ff die @ weghalen. Als het goed is krijg je dan een error :) Anders zou die het gewoon moeten doen.
 
Roderik

Roderik

13/02/2005 01:14:00
Quote Anchor link
het enigste wat er op de plek van de POLL komt te staan is dit:

Fout: er is momenteel geen actieve poll!


hij geeft ook geen error aan....
 
Johan

Johan

13/02/2005 08:50:00
Quote Anchor link
hmzz kvint een beetje raar dat je class admin oproept, terwijl in admin.inc.php de class wmadmin staat...
 
Roderik

Roderik

13/02/2005 11:00:00
Quote Anchor link
roy had het blijkbaar goed..
door wat hij zei dat heb ik gedaan
hij word nu wel toegevoegd aan de database maar hij stond er nog niet er stond een foutje in het script waar ik hem weer opvraag :P
 



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.