I had designed user input form that collects user name, email address, subject and message. I had verified all elements stored these element in variable. Now I need to send this information to the owner via email. How can I solve this problem in localhost(too)?
- How can I send email to owner?
- How can I add all information so that I can get back or differ it later in owner email.
contact.php
<form action="contact_ok.php" method="post" autocomplete="on">
<p>
<label for="username"> Name <span class="required">*</span></label>
<input type="text" name="username" required="TRUE"/>
</p>
<p>
<label for="usermail"> E-mail address <span class="required">*</span></label>
<input type="email" name="usermail"required="TRUE"/>
</p>
<p>
<label for="subject"> Subject </label>
<input type="text" name="subject" required="TRUE" />
</p>
<p>
<label for="message"> Message <span class="required">*</span></label>
<textarea name="msg" required="TRUE" ></textarea>
</p>
<input type="submit" name="submit mail"/>
</form>
contact_ok.php
<?php
$name = addslashes($_POST['username']);
$uml = addslashes($_POST['usermail']);
$sub = addslashes($_POST['subject']);
$msg =addslashes($_POST['msg']);
//sending mail to owner
$to ='owner@gmail.com';
//enter input information in array ******
//send email
mail($to,$sub,$msg);
?>
For sending mail I read about PHP mailer but I found hard to understand. Also I studied this thread on SO it is also not sufficient.
2.For storing all elements I tried to convert message firstly to array by using $msg=str_split($msg)
and push all other information by using push_array($msg)
and change it by using print_r($msg,TRUE)
but it does not work.