Send email using the answer from a form

  • Thread starter Thread starter Anonymous
  • Start date Start date
A

Anonymous

Guest
I have a problem with creating the PhP script for my contact-form. My html-form looks like this:
Code:
    <div id="getintouch" class="contact_area fix">
        <div class="wrapper contact_us fix">
            <h4>LET’S <span class="header_bold">WORK TOGETHER</span></h4>
            <p>A very long text wold go here</p>
            <span>LEAVE YOUR DETAILS AND WE’LL GET IN TOUCH</span>
            <form id="form" class="bottom_form fix" action="action.php">
                <span class="input_icon"><i class="fa fa-user"></i></span>
                <input name="name" type="text" placeholder="Your name">
                <span class="input_icon_two"><i class="fa fa-envelope"></i></span>
                <input name="email" type="email" placeholder="Your preferred email address">
                <button id="formsubmit">Submit</button>
            </form>
        </div>
    </div>
I am wondering what I should write in my action.php file to make the server send a mail (to me) with the name and email address that was registred in the form.
 
Normally you would have a method value on your form tag so you can POST the data back to the server:

Code:
<form id="form" class="bottom_form fix" action="action.php" method="POST">

Then you will be able to access the values entered into the form with PHP code like this:
Code:
$_POST['name'] and $_POST['email']

You should of course sanitize any inputs received from users POSTed to the server.

There are different options for sending an email, this is probably the simplest:
http://php.net/manual/en/function.mail.php
 
Back
Top