Eetuprkl
Eetuprkl

Reputation: 1

Form send giving Error 500 after preventing spam

My form was working perfectly — untill today when I found out rough way I forgot to prevent bot spam 🙈 There I went and added my usual hidden honeypot and thought the problem was solved, but nope, I created a new one! Now every time the form is send, I'll get ERROR 500 ("The page isn't working. www.haukkaleva.net cannot process this request at this time.")

I took the honeypot away for a while and put back previous code, but it still keeps giving 500 — yes, the same code that was working perfectly this morning.

There's something wrong with my sender php, maybe something really obvious, but I just can't see it. Is there any fresh eyes here to help my tired ones out?

Sending lomake.php looks like this:

<?php
$nimi = $_POST["nimi"];
$email = $_POST["email"];
$viesti = $_POST["viesti"];
$aihe = $_POST["aihe"];
$username = $_POST["username"];
$ok = mail("[email protected]",
           "Yhteydenotto kotisivuilta",
           "Aihe: $aihe\nNimi: $nimi\nEmail: $email\nViesti: $viesti");
           
if ($ok && $username == '') {
    header("Location: kiitos.php");
} else {
    header("Location: virhe.php");
}
?>

And the html body of the form:

        <form method="post" action="lomake.php">
                                <div class="fields">
                                    <div class="field">
                                        <label for="name">Nimi</label>
                                        <input type="text" name="nimi" id="name" />
                                    </div>
                                    <div class="field">
                                        <label for="email">Email</label>
                                        <input type="text" name="email" id="email" />
                                    </div>
                                    <!-- Break -->
<div class="col-4 col-12-small">
    <input type="radio" id="valintatuntivaraus" name="aihe" value="Tuntivaraus" checked>
    <label for="valintatuntivaraus">Tuntivaraus</label>
</div>
<div class="col-4 col-12-small">
    <input type="radio" id="valintamuukoulutus" name="aihe" value="Muu koulutus">
    <label for="valintamuukoulutus">Muu koulutus</label>
</div>
<div class="col-4 col-12-small">
    <input type="radio" id="valintatilaustaide" name="aihe" value="Tilaustaide">
    <label for="valintatilaustaide">Tilaustaide</label>
</div>
<div class="col-4 col-12-small">
    <input type="radio" id="valintamuu" name="aihe" value="Muu">
    <label for="valintamuu">Muu</label>
</div>

    <p class="antispam"><input type="text" name="username" placeholder="Write your username" tabindex="-1" autocomplete="new-password"></p>
<!-- Break -->
                                    <div class="field">
                                        <label for="message">Viesti</label>
                                        <textarea name="viesti" id="message" rows="3">Kirjoita viestisi sisältö tähän (tuntivaraukset, hevosen koulutus, kuvitustilaus tai muotokuva jne.)</textarea>
                                    </div>
                                </div>

                                <ul class="actions">
                                    <li><input type="submit" value="Lähetä viesti" /></li>
                                </ul>
                            </form>

What have I tried:

Upvotes: 0

Views: 45

Answers (0)

Related Questions