Jump to content

robsstevejobs

Members
  • Posts

    30
  • Joined

  • Last visited

Posts posted by robsstevejobs

  1. ok, look at my code in html and PHP with the image of my database, it skips the line and it leaves empty box on the table.

     

    HTML CODE

    Form 

            <form id="news" action="insert.php" method="POST">
    
    
    
                <label for="name">Nom</label>
    
                    <input type="text" name="name" placeholder="votre nom">
    
                    <Br>
    
                     <br>
    
                <label for="email">E-mail</label>
    
                <input type="email" name="email" placeholder="votre mail">
    
                <br>
    
                <br>
    
                <input type="submit" name="button" value="newsletters">
    
            </form>

     

    PHP CODE

     

    This is insert.php file 

     

    <?php
    
    $servername = "localhost";
    
    $username = "root";
    
    $password = "Robss123";
    
    $dbname = "newsletter_database";
    
    
    
    // Create connection
    
    $conn = new mysqli($servername, $username, $password, $dbname);
    
    // Check connection
    
    if ($conn->connect_error) {
    
        die("connection failed:" .$conn->connect_error);
    
    }
    
    
    
    
    
    $name = mysqli_real_escape_string($conn, $_POST['name']);
    
    $email = mysqli_real_escape_string($conn, $_POST['email']);
    
    
    
    
    
    $sql = "INSERT INTO data_user_insert (name, email)
    
    VALUES ('$name','$email')";
    
    
    
    
    
    if ($conn->query($sql) === TRUE) {
    
        echo "Votre enregistrement à reussi";
    
    } else {
    
        echo "Error: " . $sql . "<br>" . $conn->error;
    
    }
    
    
    
    $conn->close();
    
    
    
    
    
    if ($_SREVER["REQUEST_METHOD"] == "POST"){
    
    
    
      $name = test_input($_POST["name"]);
    
      $email = test_input($_POST["email"]);
    
    
    
    }
    
    
    
      function test_input ($data){
    
          $data = trim($data);
    
          $data = stripcslashes($data);
    
          $data = htmlspecialchars($data);
    
          return $data;
    
    
    
      }
    
    
    
    ?>

     

    7298D02B-2AC9-48DA-9456-584CBA57D62F.jpeg

  2. hi everyone, is there anyone to help me, I created a database with PHPmyadmin with a registration form. to my surprise when I save a member the database assigned random incrementation and then it leaves empty box in database. what can I do?

×
×
  • Create New...