And I do not know if it works because it proceed nothing to database and there is 2 question.
2. Is it the right way to collect email from the input and put it into the database(newsletter_subscribers TABLE and sub_email ROW)?
This file below is newsletter-signup.php which is mentioned in the code before.
I’m not sure what your question is, but this is not an easy thing to debug without having access to your project. If you can run your server using a debugger, that would be ideal. Otherwise, have it output something to the console when it receives a POST request at your specified path.
The code looks okay to me. The problem that I do see is that, although you’ve constructed your query correctly, you’re not executing it.
To keep things simple, first open connection to the database and then run your query stored in $sql_email. Only problem being your $sql_query is a variable and you need to concatenate it to your query. Also the value needs to be wrapped in single quotes
So your
$sql_email = "INSERT INTO newsletter_subscribers (sub_email)VALUES ($email_data)";