איך אני משלב את זה:
PHP קוד:
<?php
function IsValidEmailAddress($str)
{
if (preg_match("/^[\w\-\.]+\@[\w\-\.]+\.[\w\-]+$/i",$str)!=0)
return true;
return false;
}
echo "Email 1 is ".((IsValidEmailAddress("user-name1@domain.com"))?"valid":"not valid")."<BR>";
echo "Email 2 is ".((IsValidEmailAddress("user-name2#domain.com"))?"valid":"not valid")."<BR>";
?>
עם זה??
PHP קוד:
<?
ob_start();
?>
<html dir="rtl">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1255">
<title>News</title>
</head>
<body>
<?
include('config.php');
$action = $_GET['action'];
$page = $_GET['page'];
$id = $_GET['id'];
if (isset($p)==false) {
$p = 1;
}
$ro="10";
$start_row = $ro*$p;
$start_row -= $ro;
if(isset($id) == 0) {
echo "<p align='center'><font face='ARIAL' color='#256483' size='5'><b><u>חדשות</font></b></u></p>";
$q = mysql_query("SELECT * FROM news ORDER BY id DESC LIMIT $start_row,$ro");
while($r = mysql_fetch_array($q)) {
$id = $r['id'];
$user = $r['name'];
$title = $r['title'];
$date = $r['date'];
$desc = $r['desc'];
$pic = $r['pic'];
$seen = $r['seen'];
echo "
<table border='1' cellpadding='0' cellspacing='0' style='border-collapse: collapse' bordercolor='#256483' width='350' id='AutoNumber1' height='43'>
<tr>
<td width='57' height='79' bgcolor='#D6EAF3'>
<p align='center'><img border='0' src='$pic' width='41' height='54'></td>
<td width='232' height='79' bgcolor='#D6EAF3' bordercolor='#256483'><u>
<font color='#42AED7' face='Arial'>$date]<b>$title</b></font></u>
<br>
<font color='#256483' face='Arial'>$desc</font>
<br>
(<a href='index.php?id=$id'>קרא הכל</a> | $seen צפיות | נכתב על ידי:$user ) </td>
</tr>
</table>
<br>
";
}
?>
<p align="center">
<?
$q = mysql_query("SELECT * FROM news");
$number = mysql_num_rows($q);
$pages = ceil($number / $ro);
for($i = 1; $i<= $pages; $i++) {
if($i == $p) {
$link = $i;
} else {
$link = "<a href='index.php?p=".$i."'>".$i."</a>";
}
echo $link;
if($i+1 <= $pages) {
echo " , ";
}
}
?>
</p>
<?
}
elseif(isset($id) == 1) {
$id = $_GET['id'];
$up=mysql_query("UPDATE news SET seen = seen +1 where id ='$id'");
$q = mysql_query("SELECT * FROM news WHERE id = '$id' LIMIT 0,1");
while($r = mysql_fetch_array($q)) {
$id = $r['id'];
$user = $r['name'];
$title = $r['title'];
$date = $r['date'];
$news = $r['news'];
$desc = $r['desc'];
$pic = $r['pic'];
$seen = $r['seen'];
echo "
<table border='0' cellpadding='0' cellspacing='0' width='100%' height='38'>
<tr>
<td width='100%' height='38' bgcolor='#000'><p align='center'><font color='#ffffff' face='Arial' size='2'><b>$title ($seen צפיות)</b></font></p></td>
</tr>
</table>
<br>
<font color='#B9B9B9' face='Arial' size='2'>
נכתב על ידי: $user בתאריך:$date
</font>
<br><br>
<font color='#000000' face='Arial' size='2'><b>
$desc
</b></font>
<br><br>
<font color='#000000' face='Arial' size='2'>
$news
</font>
<br>
<br>
";
}
$q = mysql_query("SELECT * FROM news_comments WHERE nid='$id'");
while($r = mysql_fetch_array($q)) {
$id = $r['id'];
$name = $r['name'];
$message = $r['message'];
$date = $r['date'];
$nid = $r['nid'];
$email = $r['email'];
echo "
<script language='JavaScript'>
function showSubMenu(sDiv) {
myDiv = eval('document.all.' + sDiv + 'u.style');
if(myDiv.display == 'inline') {
myDiv.display = 'none';
} else {
myDiv.display = 'inline';
}
}
</script>
<div id='m1'><a href='javascript:showSubMenu('m$id');'>$id.$name</a></div>
<div style='padding-right: 20px;'>
<div id='m$idu' style='display: none;'>
$message
</div>
</div>
<br />
";
}
echo "
<form action='index.php?id=$id&action=a' method='POST'>
שמך:<input type='text' name='name'><br>
אימייל:<input type='text' name='email'><br>
הודעה:<br><textarea name='message' rows='20' cols='60'></textarea><br>
<input type='submit' name='submit' value='שלח'>
<input type='reset' name='reset' value='נקה'>
<input type='hidden' name='nid' value='".$_GET['id']."'>
</form>
";
}
if(isset($id) & $action == a ) {
$name = $_POST['name'];
$email = $_POST['email'];
$nid = $_POST['nid'];
$message2 = $_POST['message'];
$message1 = htmlspecialchars($message2);
$message = nl2br($message1);
$date=date("Y/m/d H:i:s");
$q = mysql_query("INSERT INTO news_comments(name,email,message,nid,date) VALUES ('$name','$email','$message','$nid','$date')") or die (mysql_error());
echo "התגובה הוספה בהצלחה";
header("location:index.php");
}
?>
</body>
</html>
כך שמתי שרושמים תגובה זה יכתוב שימלאו אימייל כראוי?