Form submit niet meer na invoererror

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 »

Omar M

Omar M

16/01/2015 16:00:27
Quote Anchor link
Hallo iedereen,

Ik ben bezig om een profielwijzig pagina te maken, hier kun je o.a je wachtwoord wijzigen. Ik heb hiervoor een simpele pagina genaamd wijzigprofiel.php (alleen de cruciale lines heb ik geshowed):

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
<?php
$errors
= array();
        $berichten = array();


        if($_SERVER['REQUEST_METHOD'] == 'POST')
        {

            $gebruikers_id = 3; #moet natuurlijk uit sessie komen

            #Check voor wachtwoord

            if ($_POST['oudwachtwoord'] != '' and $_POST['nieuwwachtwoord'] != '' and $_POST['nieuwwachtwoord'] != '' )
            {

                $sql = "SELECT wachtwoord FROM gebruikers WHERE gebruikers_id = :gebruikers_id";
                $query = $db->prepare($sql);
                $query->bindParam( ':gebruikers_id', $gebruikers_id, PDO::PARAM_INT)  ;
                $query->execute();
                $resultaat = $query->fetch(PDO::FETCH_ASSOC);


                echo $resultaat['wachtwoord'];

                if( $resultaat['wachtwoord'] == $_POST['oudwachtwoord'])
                {

                    if( $_POST['nieuwwachtwoord'] == $_POST['nieuwwachtwoordopnieuw'] )
                    {

                        $sql = "UPDATE gebruikers SET wachtwoord = :wachtwoord WHERE gebruikers_id = :gebruikers_id";
                        $query = $db->prepare($sql);
                        $query->bindParam( ':wachtwoord', $_POST['nieuwwachtwoordopnieuw'], PDO::PARAM_STR);
                        $query->bindParam( ':gebruikers_id', $gebruikers_id, PDO::PARAM_INT);
                        $query->execute();
                        $berichten[] = "Je wachtwoord is veranderd.";
                    }

                    else
                    {
                        $errors[] = "Je nieuwe wachtwoord komt niet overeen.";
                    }
                }

                else
                {
                    $errors[] = "Het oude wachtwoord is onjuist.";
                }
            }

?>

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
        <?php


        if( count($berichten) > 0 )
        {

            echo "<div style=\"background: #CEFEC8; border: 2px solid green; padding: 15px;\">";
            foreach( $berichten as $bericht )
            {

                echo "<li>" .$bericht. "</li>";
            }

            echo "</div>";
        }



        if( count($errors) > 0 )
        {


            echo "<div style=\"background: #FFC9C7; border: 2px solid red; padding: 15px;\">";
            foreach( $errors as $error )
            {

                echo "<li>" .$error. "</li>";
            }

            echo "</div";

        }







        ?>



Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
            <fieldset>
                <legend>Wachtwoord</legend>
                <label for="oudwachtwoord">Oude wachtwoord</label>
                <input type="password" name="oudwachtwoord" /><br/>
                <label for="nieuwwachtwoord">Nieuw wachtwoord</label>
                <input type="password" name="nieuwwachtwoord" /><br/>
                <label for="nieuwwachtwoordopnieuw">Nieuw wachtwoord opnieuw</label>
                <input type="password" name="nieuwwachtwoordopnieuw" />



            </fieldset>



Als ik een onjuist "oudwachtwoord" invoer en dan op submit druk krijg ik zoals het hoort een error. Als ik dan opnieuw het oudewachtwoord invoer samen met het nieuwe wachtwoord en ik druk op submit gebeurt er niks. De pagina wordt niet opnieuw geladen, noppes, nada, niks. Kortom het formulier wordt dan niet gesubmit.

Zou iemand weten hoe dit komt?

Met vriendelijke groet,
Omar
 
PHP hulp

PHP hulp

26/04/2024 22:58:35
 
- SanThe -

- SanThe -

16/01/2015 16:04:57
Quote Anchor link
Is je <form> nog wel compleet?
 
Omar M

Omar M

16/01/2015 16:05:49
Quote Anchor link
Bedankt voor de snelle reactie! Ja, ik heb enkel een snippet gepost maar dit is het hele form:

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
<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post">

            <fieldset>
                <legend>Profielfoto</legend>
                    <label for="bestand">Selecteer een foto:</label>
                    

                    <input type="file" name="bestand" />

            </fieldset>

            <fieldset>
                <legend>Persoonlijke gegeven</legend>
                <label for="man">Man</label>
                <input type="radio" id="man" name="geslacht" value="man" />
                <label for="vrouw">Vrouw</label>
                <input type="radio" id="vrouw" name="geslacht" value="vrouw">
                <label for="dag">Geboortedatum</label>
                <br/>
                <select name="dag">
                <?php
                    for($i=1; $i <= 31; $i++ )
                    {

                        echo "<option value=" .$i. ">" .$i. "</option>";
                    }

                ?>

                </select>
                
                <select name="maand">
                <option value="1">Januari</option>
                <option value="2">Februari</option>
                <option value="3">Maart</option>
                <option value="4">April</option>
                <option value="5">Mei</option>
                <option value="6">Juni</option>
                <option value="7">Juli</option>
                <option value="8">Augustus</option>
                <option value="9">September</option>
                <option value="10">Oktober</option>
                <option value="11">November</option>
                <option value="12">December</option>
                </select>

                <select name="jaar">
                <?php
                    for($i= date("Y"); $i >= 1900; $i-- )
                    {

                        echo "<option value=" .$i. ">" .$i. "</option>";
                    }

                ?>

                </select>

            </fieldset>

            <fieldset>
                <legend>Privacy</legend>
                <label for="openbaar">Openbaar</label>
                <input type="radio" id="openbaar" name="openbaar" value="openbaar" />
                <label for="prive">Priv</label>
                <input type="radio" id="prive" name="openbaar" value="prive" />
            </fieldset>
            
            <fieldset>
                <legend>Wachtwoord</legend>
                <label for="oudwachtwoord">Oude wachtwoord</label>
                <input type="password" name="oudwachtwoord" /><br/>
                <label for="nieuwwachtwoord">Nieuw wachtwoord</label>
                <input type="password" name="nieuwwachtwoord" /><br/>
                <label for="nieuwwachtwoordopnieuw">Nieuw wachtwoord opnieuw</label>
                <input type="password" name="nieuwwachtwoordopnieuw" />



            </fieldset>
            <br />
            <input type="submit" value="Update mijn profiel" />



        </form>
 
- SanThe -

- SanThe -

16/01/2015 16:08:31
Quote Anchor link
Dit:
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post">

kan gewoon zo:
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
<form action="" method="post">
Gewijzigd op 16/01/2015 16:09:15 door - SanThe -
 
Omar M

Omar M

16/01/2015 16:12:44
Quote Anchor link
Ik had het eerst op die manier, maar omdat het niet werkte ging ik gebruik maken van PHP_SELF hahaha :P.

Overigens komt het probleem niet voor als ik wel een juist oudwachtwoord, nieuwwachtwoord en nieuwwachtwoordopnieuw invul. Dan kan ik oneindig veel keer het form resubmitten. Alleen als er een error voorkomt kun je het form niet meer submitten.
 
- SanThe -

- SanThe -

16/01/2015 16:16:15
Quote Anchor link
Zitten bovenstaande scripts in 1 bestand?
Gewijzigd op 16/01/2015 16:16:30 door - SanThe -
 
Omar M

Omar M

16/01/2015 16:17:16
Quote Anchor link
Ja, alles zit in 1 bestand genaamd wijzigprofiel.php
 
- SanThe -

- SanThe -

16/01/2015 16:20:32
Quote Anchor link
Kijk eens na een fout in de broncode of het formulier nog compleet ia.
 
Omar M

Omar M

16/01/2015 16:26:23
Quote Anchor link
Thanks! Dat was de oplossing! Als er een error werd geprint werd de div niet met een ">" afgesloten.

Dat zo'n klein foutje zulk effect kan hebben :P.

Duizendmaal dank!
 
- SanThe -

- SanThe -

16/01/2015 16:29:28
Quote Anchor link
Ha, ik zie het nou ook.
Tweede script regel 23 mist inderdaad een >.
 
Omar M

Omar M

16/01/2015 16:33:53
Quote Anchor link
Inderdaad, dat was hem!

Nogmaals bedankt!
 



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.