didnt have the print_r function
here are the codes, this is actually for sending email, i put the email addresses in an array to check the validity of each,
$complete = true;
if (isset($_POST['Submit'])) {
$to = ($_POST['to']);
$subject = ($_POST['subject']);
$message = ($_POST['message']);
if (empty($to)) {
$errmsg ="There are no recipients of this email";
$complete = false;
}
if (empty($subject)) {
$errmsg ="This email has no subject";
$complete = false;
}
if (empty($message)) {
$errmsg ="This email has no message";
$complete = false;
}
if (!empty($to)) {
var_dump(explode(',', $to));
$count = (count($to));
for ($i = 0; $i <= $count; $i++) {
$myStr = $to[$i];
if (isValidEmail($myStr) == 1) {
$errmsg = "Please provide a valid Email Address";
$mail = "";
$complete = false;
} //end if
} // end for
}//end if
if ($complete = true); {
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'From: ' . $username . "@e-hime.ph \r\n";
// Mail it
(mail($to, $subject, $message, $headers));
}
}//end if
function isValidEmail($myemail)
{
return preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*$/i", $myemail);
}
here's the html form :
<form action="inbox.php?show=compose" method="post">
<table height="213">
<tr>
<td width="122" height="21"><div align="right">To : </div></td>
<td width="459"><input name="to" type="text" id="to" value="<?=$to?>" size="85"></td>
</tr>
<td height="22"><div align="right">Subject : </div></td>
<td><input name="subject" type="text" id="subject" value="<?=$subject?>" size="85"></td>
</tr>
<tr>
<td height="94"><div align="right">Message : </div></td>
<td><textarea name="message" cols="50" rows="15"><?=$message?>
</textarea></td>
</tr>
<tr>
<td><div align="right">
<input type="reset" name="Reset" value="Reset">
</div></td>
<td>
<input type="submit" name="Submit" value="Send Email"></td>
</tr>
</table>
</form>