I’m trying to create a very simple mailform. This is what I have so far:
<html>
<h2>Email Verzenden</h2>
<script language = "Javascript">
function explodeArray(emailID,delimiter) {
tempArray=new Array(1);
var Count=0;
var tempString=new String(emailID);
while (tempString.indexOf(delimiter)>0) {
tempArray[Count]=tempString.substr(0,tempString.indexOf(delimiter));
tempString=tempString.substr(tempString.indexOf(delimiter)+1,tempString.length-tempString.indexOf(delimiter)+1);
Count=Count+1
}
tempArray[Count]=tempString.replace("\r","");
return tempArray;
}
function checkEmail(hallo) {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(hallo)){
return true;
}
return false;
}
function validate(){
var emailID=document.form.email;
var delimiter="\n";
var emailArray=explodeArray(emailID.value,delimiter);
var textID=document.form.text;
var length = emailArray.length,
element = null;
for (var i = 0; i < length; i++) {
emailVar = emailArray[i];
if (emailVar==null){
alert("Email-adres bestaat niet")
emailID.focus()
return false
}
if (emailVar==""){
alert("Email-adres veld is leeg")
emailID.focus()
return false
}
if (checkEmail(emailVar)==false){
emailVar.value=""
alert("Ongeldig E-mail adres");
emailVar.focus()
return false
}
}
if ((textID.value==null)||(textID.value==""))
{
alert("E-mail textveld is leeg")
textID.focus()
return false
}
return true
}
</script>
<form name="form" method="post" onSubmit="return validate()">
<pre>
Vul hier de/het E-mail adres(sen) in
<textarea name="email" rows="5" cols="50"></textarea><br>
Typ hier de E-mail
<textarea name="text" rows="5" cols="50"></textarea><br>
<input type="submit" name="Submit" value="Submit">
</pre>
</form>
</html>
as you can see, there are 2 textareas. In the upper one, you’re supposed to put down email addresses underneath eachother, and in the bottom one you’re supposed to write the actual email. I already got my script to check if the email addresses are valid, and if the actual email actually has any input and whatnot, but I am clueless as to how to how implement any PHP code in order to actually send the e-mail to all the addresses filled in in the top textarea. Could anybody help me?
make yourscript.php.