Post email from input into the database

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
New php-forum User
New php-forum User
Posts: 1
Joined: Sat Nov 18, 2017 1:12 pm

Sat Nov 18, 2017 1:16 pm

Hello. My problem is:

1.I need submit button to be not active before real email will be written down. I have this form now:

Code: Select all

<form action ="/includes/newsletter-signup.php" method="post" id="submit-email">

<input "autocomplete="off" type="email" name="email-address" id ="txtmail"
 placeholder="<?php echo $lang['e-mail-footer']; ?>">

<input disabled="true" class="btn-disabled btn-reset button button-blue" 
type="submit" id = "btn-reset" value="<?php echo $lang['sign-up']; ?>">
and code:

Code: Select all


// news subscription:
		rules: {
			txtmail: {
				required: true,
				email: true

		messages: {
			email: "Please enter a valid email address"

	}); // end reset-form
  $("#txtmail").on("blur", function(){
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.

Code: Select all

	$email_data = $_POST['email-address']; 
	$sql_email = "INSERT INTO newsletter_subscribers (sub_email)VALUES ($email_data)";

Thanks in advance for every help.

php-forum Active User
php-forum Active User
Posts: 483
Joined: Fri Apr 01, 2016 2:18 am

Mon Nov 20, 2017 12:01 am

you're not actually queriing the database, read this:

enable exceptions.

Post Reply