user2977046 user2977046 - 6 months ago 27
CSS Question

request for email and send with link of page

Okay my question is, how can I request from user when clicks on button to enter his email and receive message with link of my web page?

Answer

You cannot do this with just HTML or even with just HTML and javascript.

To send an email, you need to use a back-end script, which is usually PHP (on most shared hosting servers) or asp/.Net (on Microsoft web servers)

Javascript has been made much easier with the jQuery add-in. Here is a link to some free videos about how to use jQuery. Basically, jQuery cuts typing dramatically and makes javascript much easier. All you need to use jQuery is to include the jQuery library between script tags -- place that code just above the closing </body> tag.

Here is some example code using jQuery, just to show what it would look like. This example:
* asks user for email address (but does not validate what they enter)
* creates a form with an element named eml that contains what the user typed
* submits the form to a backend PHP file called sendcontact.php. It is up to you to also write sendcontact.php

$(document).ready(function(){

    $('#mybutt').click(function(){
        var em = prompt('Enter your email');
        $('body').append('<form id="yrForm" action="sendcontact.php" method="post"><input name="eml" value="' +em+ '" ></form>');
        $('#yrForm').submit();
    });
  
}); //END document.ready
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<button id="mybutt">Click Me</button>


Now, you need to have another back-end file, sendcontact.php that will receive the data sent via the form, and send an email. Here is an overview of how to do that:

http://tangledindesign.com/how-to-create-a-contact-form-using-html5-css3-and-php/

(You can ignore the entire first part of the above tutorial that deals with creating the contact form. You only need to read about how to receive the information in PHP and send the email.)