skip to Main Content

I was trying to make a site and people could sign up/subscribe and i would store their email adresses in a database. I searched online for a solution but couldnt find anything

My code:

<html>
    <?php include_once('include/html/hoofd.php') ?>
    <body>

        <h1 id="css"> ----- </h1>
        <br><br><br>
        <ul>
            <form method="post" action="./emailverwerk.php" class="email" id="css2">
                <b><extra &nbsp;&nbsp; space >Register and we will notify you with the the next GREAT deal!</b><br>
                <br>
                Full Name: <input type="text" class="css2" name="naam" placeholder="Full name"><br>
                Email adress : <input type="email" class="css2" name="emailaddress" placeholder="Email Adress"><br>
                Email adress : <input type="email" class="css2" name="Emailaddressrepeat" placeholder="Repeat Email "><br>       
                <a href="http:/----------/emailverwerk.php"><input type ="Submit" value ="Subscribe" id="css3"><br>

                <?php
                session_destroy();
                if (isset($_SESSION["error"])) {
                    print ($_SESSION["error"]);
                }
                ?>
            </form>
        </ul>
        <ul>
            <form method="post" class="actie" id="expired1">
                <b>- Claim your free 1000 TRX here!!</b><br>
                 This is a one time offer! <br>
                 Click the link below and fill in your details to claim your free 1000 TRX!<br>
                <input type="submit" value="Expired!!" id="css3">          
            </form>
        </ul>
    </body>
</html>

And my SQLI code :

<?php

session_start();
include_once ("include/database.php");
$name = $_POST["naam"];
$email = $_POST["Emailaddress"];
$emailherh = $_POST["Emailaddressrepeat"];

$sql = "INSERT INTO emaillist (naam , email)
VALUES ('".$_POST["naam"]."','".$_POST["emailaddress"]."')";

if ($conn->query($sql) === TRUE) {
echo "<script type= 'text/javascript'>alert('New record created successfully');</script>";
} else {
echo "<script type= 'text/javascript'>alert('Error: " . $sql . "<br>" . $conn->error."');</script>";
}

$conn->close();
}
?>

Im a first year student as well so my programming experience isnt that big and perfect yet.

2

Answers


  1. Your Anchor tag is not needed around the form submit, and it was not closed .

    Login or Signup to reply.
  2. You must escape the strings. Else you are disallowing Irish. Think what happens with O'Brian. It will give you a mysterious “syntax error”.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search