I’m completely lost here. I want to send an email with PHP without leaving my page. But I can’t figure out how to get the data to the PHP file to email it. And when I do get it there, I would be lost. So any help with what the PHP file should look like would be great too.
Here is the form.
<table id="dialog">
<tr><td><input type="text" id="name" name="name" placeholder="Your Name" size="20" class="tbow" /></td></tr>
<tr><td><input type="text" id="email" name="email" placeholder="Your Email" size="20" class="tbow" /></td></tr>
<tr><td><input type="text" id="number" name="number" placeholder="Your Phone Number" size="20" class="tbow" /></td></tr>
<tr><td><textarea id="message" name="message" rows="5" cols="25" class="tbow" placeholder="Your Message"></textarea></td></tr>
<tr><td><input type="button" value="Send!" onclick="senem();" id="sender" /></td></tr>
</table>
And I’ve tried this…
function senem(){
var name = document.getElementById("name").value;
var email = document.getElementById("email").value;
var number = document.getElementById("number").value;
var message = document.getElementById("message").value;
$.ajax({
type: "POST",
url: "mmaa.php",
data: "name=" + name + "&email=" + email + "&number=" + number = "&message=" + message,
success: alert("It works!!!");
});
}
Not intended as a copy-and-paste job, but should give you the building blocks to write it yourself:
Your javascript function;
and in the php;
The values of var1 and var2 you will probably want to assign clientside, using jQuery (eg $(“#name”).val(); ) and you will also need to install and configure an SMTP server alongside Apache (use Exim, and find a friendly geek to help you).
PS: the \r\n is because SMTP shares some syntax with HTTP, it’s not important, but the mail command probably won’t work without them.