Greeting everyone,
With all the website crawlers out, I thought that I would try and secure the email addresses a little better by doing the following. On the first webpage, I have the following code:
<?php
include("../../../includes/db.inc");
$dbh=@mysql_connect ("$dbhost", "$dbuser", "$dbpass") or die ('I cannot
connect to the database because: ' . mysql_error());
mysql_select_db ("$dbname");
//Set the number of columns for the page
$columns = 4;
$qrySurname__letter = "%";
// Output letters as links: (Ascii range from 65 to 90 are letters A to Z!)
// Trying to do this automatically without having to resort to hand coding // of every single link
for($x=65;$x<=90;$x++)
{
if ($x==ord($subsel)) echo "<b>".chr($x)."</b>";
else
echo "<a href=\"surnames.html?letter=".chr($x)."\">".chr($x)."</a> ";
}
$letter = $_GET["letter"];
if (isset($letter))
{
$qrySurname = "SELECT * FROM surnames WHERE nm_surname LIKE '$letter%' ORDER BY nm_surname";
//} else {
//$qrySurname = "SELECT * FROM surnames ORDER BY nm_surname";
//}
$result = mysql_query($qrySurname);
//Need to know the number of rows, so use this line
$num_rows = mysql_num_rows($result);
//Set a new variable called $rows
$rows = ceil($num_rows / $columns);
//For this vertical display, need to run another loop, which will populate an array with our values
while($row = mysql_fetch_array($result)) {
$email[] = $row['nm_email'];
$surname[] = $row['nm_surname'];
$eID[] = $row['eID'];
$valid_em[] = $row['valid_em'];
$valid_mem[] = $row['valid_mem'];
}
echo "<TABLE BORDER=1 cellpadding=5 align=center>\n";
for ($i = 0; $i < $rows; $i++) {
echo "<tr>";
for ($j = 0; $j <$columns; $j++) {
if(isset($eID[$i + ($j * $rows)])) {
echo "<td><li> <A HREF=\"JavaScript:newWindow('researcher.php?researcher=".$eID[$i + ($j * $rows)]."','popup',420,320,'')\">".$surname[$i + ($j * $rows)]."</a></li> ";
}
if (strcmp("No", $valid_em[$i + ($j * $rows)])==0) {
echo "<img width=16 height=15 align=absmiddle src=\"exclamation.jpg\" border=0> ";
}
if (strcmp("Yes", $valid_mem[$i + ($j * $rows)])==0) {
echo "<img align=absmiddle src=\"mem.jpg\" border=0></td>";
}
}
echo "</tr>";
}
echo "</table>";
}
This populates a 4 column table with the surnames. I have the script pull the eID (email ID number) listed with each associated surname and call a new PHP file (which opens a new window) and passes the information that the researcher=eID.
Based on this eID - it looks for similar surnames with this same eID and creates a list of these surnames. I would like to use this eID to insert the email address associated with it (preferably once).
From the first page - this information is getting passed to the second page fine. The correct surname with the same eID is listed. However, I cannot, for the life of me, get the email address associated with this ID to display the email address. Just turns up blank!
Here is the code for the second page:
<html>
<head>
<title>Researcher Information</title>
</head>
<body bgcolor="#ffffff">
<?php
include("../../../includes/db.inc");
$dbh=@mysql_connect ("$dbhost", "$dbuser", "$dbpass") or die ('I cannot
connect to the database because: ' . mysql_error());
mysql_select_db ("$dbname");
$researcher = $_GET["researcher"];
if (isset($researcher)) {
$qryResearcher = "SELECT nm_email,nm_surname,nm_addinfo FROM surnames WHERE eID LIKE '%$researcher%' ORDER BY nm_surname";
}
$result = mysql_query($qryResearcher);
//$num = mysql_num_rows($result);
//echo "$num";
echo "<TABLE BORDER=0 cellpadding=5>";
echo "<tr bgcolor=\"#9999CC\">";
echo "<td width=45%><strong>Researcher Information</strong></td>";
echo "</tr>";
echo "<tr><td>Contact email address: <A HREF=\"mailto:{$result['nm_email']}\">{$result['nm_email']}</td></tr>";
echo "<tr><td>Other surnames being researched:</td></tr>";
echo "<tr><td>";
while ($row = mysql_fetch_array($result))
{
echo "<LI><b>{$row['nm_surname']}</B> <em>{$row['nm_addinfo']}</em><br>";
}
echo "</td></tr>";
echo "<tr><td><center><A HREF=\"Javascript:self.close();\">Close Window</A></center></td></tr>";
echo "</TABLE>";
?>
<font face="Verdana, Arial, Helvetica" size="-1"></font>
</body>
</html>
I am missing a step somewhere...
Thanks!