toben88
asked on
PHP not recognizing end of email address
I have a form that is used to invite people to a site via email addresses.
The problem seems to be the code does not recognize the end of the email address so one email address works, but if you put in more than 1 it tells you the address is incorrect as it sees the space or comma between addresses.
I need to be able to enter multiple addresses separated by space or comma and have it loop through the list to send out the emails.
Help me get this working and you will get a fast 500 points.
Help me adjust it to limit a max of 99 emails and you are even better.
The problem seems to be the code does not recognize the end of the email address so one email address works, but if you put in more than 1 it tells you the address is incorrect as it sees the space or comma between addresses.
I need to be able to enter multiple addresses separated by space or comma and have it loop through the list to send out the emails.
Help me get this working and you will get a fast 500 points.
Help me adjust it to limit a max of 99 emails and you are even better.
<?php session_start();ob_start();
include("include/db.inc.php");
if($_SESSION['lang']=='')
{
$_SESSION['lang'] = "en";
}
include 'languages/lang.'.$_SESSION['lang'].'.php';
include("include/bit_functions.inc.php");
include("include/mail.php");
$headermsg=_INVEFRDS_;
$db1=new db;
$db1->open();
$uid=$_SESSION[id];
$sql="select * from user where id='$uid'";
$res=mysql_query($sql);
$row1=mysql_fetch_array($res);
$sq="select * from profile where uid='$uid'";
$re=mysql_query($sq);
$ro=mysql_fetch_array($re);
if(isset($_POST['submit']))
{
$email=$_POST['toid'];
$inviteId=substr(md5($email),0,15);
invite_your_friends($_POST['toid'], get_fieldval(id,email,user,$uid), $inviteId);
$q="insert into invite values('','$uid','$email','$inviteId')";
$r=mysql_query($q) or die(mysql_error());
/* $headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=utf8\r\n";
$headers .= "From:".get_fieldval(id,email,user,$uid)."\r\n";
mail($email,_INVIT_FR_FRNDSHIP_,$mess,$headers);*/
header('Location:user_detail.php');
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<script src="include/validation.js"></script>
<script language="javascript">
function validemail()
{
var email=document.invite.toid.value;
if(!is_email(email))
{
alert(" <?=_PLS_V_E_ADD_?>");
document.invite.toid.focus();
return false;
}
}
function openpopup(val)
{
window.open("import/import.php?spimport=" + val ,"invite","width=380,height=330,scrollbars=yes,resizable=0");
}
</script>
<meta content="friends networking sharing photos finding friends blogs journals blogging journaling bands, music rate pics join groups forums classifieds online social networking" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="Description" content="Faithout is a social networking site, photos, friends, groups, events, bulletin, networks, messages, pokes and much more. find and make your friends here" />
<meta name="Keywords" content="" />
<meta name="rating" content="General"/>
<meta name="copyright" content="Copyright (c) 2007 by Christian.tv Network" />
<meta name="classification" content="all"/>
<meta name="coverage" content="Worldwide"/>
<meta name="title" content="Faithout | Christian.tv Network"/>
<meta name="page-topic" content="products, services, technology, business, Internet, Web, friends, photos, networks, connections, events, groups, relations"/>
<meta name="audience" content="all, experts, advanced, professionals, business, youth, children, ladies, females, males"/>
<meta name="reply-to" content="helpdesk@faithout.com"/>
<meta name="author" content="Christian.tv Network website development"/>
<title><?=_TITLE_?> | <?=_INVTFRDS_?></title>
<link href="cssnew/create_amazers.css" rel="stylesheet" type="text/css" />
<link href="cssnew/template.css" rel="stylesheet" type="text/css" />
<link href="cssnew/links.css" rel="stylesheet" type="text/css" />
<link href="cssnew/div.css" rel="stylesheet" type="text/css" />
<link href="cssnew/fonts.css" rel="stylesheet" type="text/css" />
<link href="cssnew/worship.css" rel="stylesheet" type="text/css" />
<link href="cssnew/index.css" rel="stylesheet" type="text/css" />
<!--[if lte IE 6]><style type="text/css" media="screen">/* <![CDATA[ */ @import url(<?=_BASEURL_?>/cssnew/ie6.css?55:80277); /* ]]> */</style><![endif]-->
<!--[if gte IE 7]><style type="text/css" media="screen">/* <![CDATA[ */ @import url(<?=_BASEURL_?>/cssnew/ie7.css?55:81207); /* ]]> */</style><![endif]-->
<link rel="shortcut icon" href="<?=_BASEURL_?>/favicon.ico" />
</head>
<body>
<div id="framing_main">
<div id="framing_left"><a href="<?=_BASEURL_?>" class="go_home" style="background-image:url('<?=_BASEURL_?>/site/logo.gif')"> </a>
<div id="framing_left_content">
<? include("leftnew.php");?><? include("banner_inc.php");?>
</div>
</div>
<div id="framingwidebar" class="clearfix">
<? include("headeroff.php");?>
<div id="normal_shadow" onMouseOver="hide_all_menu();">
<div id="no_shadow" class="clearfix">
<!--:::::::::::::::::::::::::::::::::::::::::::center::::::::::::::::::::::::::::::::::::::::::::::::-->
<table width="100%" border="0" cellpadding="0" cellspacing="0" background="img/tdbackbar620p.png">
<tr height="30px"><td class="head" valign="top" background="img/tdbackbar620w.png"> <?=_INV_UR_FRND_?></td></tr>
<tr height="1px"><td><img src="img/line295.gif" style="width:665px; height:1px;" /></td></tr>
<tr>
<td valign="top" style="padding-left:1px; padding-right:1px">
<table border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#efefef" width="100%" style="padding-left:20px; padding-top:20px">
<form id="invite" name="invite" method="post" action="invite.php" onsubmit="return validemail();">
<tr>
<td width="34%" class="normaltextblackbold"><?=_FROM_?>:</td>
<td width="34%" class="normaltextblack"><?=get_fieldval(id,email,user,$uid)?></td>
<td width="32%" class="normaltextblack"> </td>
</tr>
<tr><td> </td>
<td> </td>
<td rowspan="4" align="left" valign="top">
<div style="padding-top:10px; padding-bottom:10px; border-bottom:1px solid #CCCCCC; border-top:1px solid #CCCCCC; margin-right:10px">
<h2><a href="javascript:(openpopup('Hotmail'));">Import Email Addresses <img src="template_image/dropUp1.gif" alt="" /></a></h2>
<p>from your Yahoo, Hotmail, AOL, Gmail, MSN, Live.com or Comcast address book. Click on provider below</p>
<p><img src="template_image/hotmail_logo.gif" onclick="openpopup('Hotmail');" alt="import contacts from hotmail" width="58" height="19" /> <img src="template_image/gmail_logo.gif" onclick="openpopup('Gmail');" alt="import contacts from gmail" width="49" height="17" />
<br />
<img src="template_image/yahoo_logo.gif" onclick="openpopup('Yahoo');" alt="import contacts from yahoo" width="79" height="14" /> <img src="template_image/aol_logo.gif" onclick="openpopup('AOL');" alt="import contacts from aol" width="48" height="16" /></p>
</div></td>
</tr>
<tr>
<td class="normaltextblack"><div align="justify"><span class="normaltextblackbold"><?=_TO_?></span><br />
<?=_SEP_MAIL_BY_COMS_?></br>
<a href="javascript:(openpopup('Gmail'));" class="smalla1" ><?=_LKUP_MAIL_?></a>
<br />
<div style="padding-right:10px"><?=_FRM_UR_YHAG_A_BK_?> <?=_OPN_?>.</div>
</div></td>
<td><textarea name="toid" rows="3" cols="30" class="normaltextnotbold"><?=$_SESSION['addressbook']?></textarea></td>
</tr>
<tr><td> </td>
<td> </td>
</tr>
<tr>
<td class="normaltext" valign="top"><span class="normaltextblackbold"><?=_MESSAGE_?>:</br>
</span> <span class="normaltextblack"><?=_OPN_?></span></td>
<td><textarea name="message" rows="3" cols="30" class="normaltextnotbold"></textarea></td>
</tr>
<tr height="30px">
<td colspan="3" align="center"><br />
<br />
<div align="center"><input type="submit" name="submit" class="inputsubmit" value="<?=_INVIT_?>">
<input type="reset" name="recet" class="inputsubmit" value="<?=_CANCEL_?>" onclick="window.location.href='user_detail.php'"></div> <br />
<br />
<br />
<br /> </td></tr>
</form>
</table>
</td>
</tr>
</table>
<? $_SESSION['addressbook']='';?>
<!--:::::::::::::::::::::::::::::::::::::::::::center::::::::::::::::::::::::::::::::::::::::::::::::-->
</div>
</div>
<div id="pagefooter" class="clearfix">
<div class="copyright_and_location clearfix">
<div class="copyright">
<? include("chat.php");?><? include("footernew.php");?><?=bannerBottom(2)?>
</div>
</div>
</div>
also in another file:
function is_email(email)
{
if(!email.match(/^[A-Za-z0-9\._\-+]+@[A-Za-z0-9_\-+]+(\.[A-Za-z0-9_\-+]+)+$/))
return false;
return true;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER