How do I get the value of the form into a mysql table?

So all I want, is to get the var1 from the input into my sql table. It always creates a new ID, so this is working, but it leaves an empty field in row Email. I never worked with sql before and couldn't find something similar here. I thought the problem could also be in the settings of the table, but couldn't find anything wrong there. Maybe someone can help me out with the .php?

<input name="var1" id="contact-email2" class="contact-input abo-email" type="text" placeholder="Email *" required="required"/>
<form class="newsletter-form" action="newsletter.php" method="POST">
             <button class="contact-submit" id="abo-button" type="submit" value="Abonnieren">Absenden
             </button>
</form>
<?php 
 
 $user = "user";  
 $password = "password";  
 $host = "localhost:0000";  
 $dbase = "base";  
 $table = "table";  
 

 


 // Connection to DBase  
 $con= new mysqli ($host,$user,$password,$dbase)  
 or die("Can't connect"); 
 $var1 = $_POST['var1'];

 $sql = "INSERT INTO table (id, Email) VALUES ('?', '_POST[var1]')";

 $result = mysqli_query($con,$sql) or die ("Not working");

 
 echo 'You are in!' . '<br>'; 

 mysqli_close($con); 
  
 ?> 


Read more here: https://stackoverflow.com/questions/64626581/how-do-i-get-the-value-of-the-form-into-a-mysql-table

Content Attribution

This content was originally published by noah222 at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: