SORRY!!!! WRONG CODE!! Right code:
<?php require_once('Connections/cramlist.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $SERVER['PHP_SELF'];
if (isset($SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($POST["MM_insert"])) && ($POST["MM_insert"] == "form2")) {
$insertSQL = sprintf("INSERT INTO RequestDB (campaign_ID, clientid, agent_email, agentid) VALUES (%s, %s, %s, %s)",
GetSQLValueString($POST['campaign_id'], "text"),
GetSQLValueString($POST['clientid'], "text"),
GetSQLValueString($POST['hagentemail'], "text"),
GetSQLValueString(isset($POST['choose[]']) ? "true" : "", "defined","1","0"));
mysql_select_db($database_cramlist, $cramlist);
$Result1 = mysql_query($insertSQL, $cramlist) or die(mysql_error());
}
$maxRows_searchresults = 10;
$pageNum_searchresults = 0;
if (isset($GET['pageNum_searchresults'])) {
$pageNum_searchresults = $GET['pageNum_searchresults'];
}
$startRow_searchresults = $pageNum_searchresults * $maxRows_searchresults;
$colname_searchresults = "-1";
if (isset($POST['search'])) {
$colname_searchresults = $POST['search'];
}
mysql_select_db($database_cramlist, $cramlist);
$query_searchresults = sprintf("SELECT agents_DB.email, agents_DB.firstname, agents_DB.lastname, agents_DB.networksize, agents_DB.keywords, agents_DB.city, agents_DB.state, agents_DB.zip, agents_DB.agentid FROM agents_DB WHERE MATCH (agents_DB.email) AGAINST (%s) OR MATCH (agents_DB.firstname) AGAINST (%s) OR MATCH (agents_DB.lastname) AGAINST (%s) OR MATCH (agents_DB.keywords) AGAINST (%s) OR MATCH (agents_DB.city) AGAINST (%s) OR MATCH (agents_DB.state) AGAINST (%s) OR MATCH (agents_DB.zip) AGAINST (%s)", GetSQLValueString($colname_searchresults, "text"),GetSQLValueString($colname_searchresults, "text"),GetSQLValueString($colname_searchresults, "text"),GetSQLValueString($colname_searchresults, "text"),GetSQLValueString($colname_searchresults, "text"),GetSQLValueString($colname_searchresults, "text"),GetSQLValueString($colname_searchresults, "text"));
$query_limit_searchresults = sprintf("%s LIMIT %d, %d", $query_searchresults, $startRow_searchresults, $maxRows_searchresults);
$searchresults = mysql_query($query_limit_searchresults, $cramlist) or die(mysql_error());
$row_searchresults = mysql_fetch_assoc($searchresults);
if (isset($GET['totalRows_searchresults'])) {
$totalRows_searchresults = $GET['totalRows_searchresults'];
} else {
$all_searchresults = mysql_query($query_searchresults);
$totalRows_searchresults = mysql_num_rows($all_searchresults);
}
$totalPages_searchresults = ceil($totalRows_searchresults/$maxRows_searchresults)-1;
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>
<body>
<p>Select Your Agents</p>
<p>You can reach your target audience by entering search terms in the box below.
Mamadu will match your search with Agents who's networks fit the profile you're
looking for. You can enter the city, state, or zip code you want, audience
demographic information, interests, etc. Once Mamadu displays your matching
Agents, choose the ones you want, and they'll be updated so they can begin
spreading the word. It's that easy.</p>
<form id="form1" name="form1" method="post" action="agentsearch2.php?clientid=<?php echo $GET['clientid']; ?>&campaign_id=<?php echo $GET['campaign_id']; ?>">
<input name="search" type="text" id="search" size="50" />
<input type="submit" name="submit" id="submit" value="Go" />
</form>
<p>
Records <?php echo ($startRow_searchresults + 1) ?> to <?php echo min($startRow_searchresults + $maxRows_searchresults, $totalRows_searchresults) ?> of <?php echo $totalRows_searchresults ?> </p>
<form id="form2" name="form2" method="POST" action="<?php echo $editFormAction; ?>">
<?php do { ?>
<table >
<tr>
<?php
$searchresults_endRow = 0;
$searchresults_columns = 3; // number of columns
$searchresults_hloopRow1 = 0; // first row flag
do {
if($searchresults_endRow == 0 && $searchresults_hloopRow1++ != 0) echo "<tr>";
?>
<td><p><?php echo $row_searchresults['firstname']; ?> <?php echo $row_searchresults['lastname']; ?></p>
<p><?php echo $row_searchresults['email']; ?></p>
<p><?php echo $row_searchresults['city']; ?>, <?php echo $row_searchresults['state']; ?></p>
<p>Network Size: <?php echo $row_searchresults['networksize']; ?>+</p>
<p>Choose this Agent.
<input type="checkbox" name="choose[]" id="choose" value="<?php echo $row_searchresults['agentid']; ?>" />
<input name="hagentemail" type="hidden" id="hagentemail" value="<?php echo $row_searchresults['email']; ?>" />
</p></td>
<?php $searchresults_endRow++;
if($searchresults_endRow >= $searchresults_columns) {
?>
</tr>
<?php
$searchresults_endRow = 0;
}
} while ($row_searchresults = mysql_fetch_assoc($searchresults));
if($searchresults_endRow != 0) {
while ($searchresults_endRow < $searchresults_columns) {
echo("<td> </td>");
$searchresults_endRow++;
}
echo("</tr>");
}?>
</table>
<?php } while ($row_searchresults = mysql_fetch_assoc($searchresults)); ?>
<p>
<input type="submit" name="submit" id="submit" value="Submit" />
<input name="clientid" type="hidden" id="clientid" value="<?php echo $_GET['clientid']; ?>" />
<input name="campaign_id" type="hidden" id="campaign_id" value="<?php echo $_GET['campaign_id']; ?>" />
</p>
<input type="hidden" name="MM_insert" value="form2" />
</form>
<p> </p>
</body>
</html>
<?php
mysql_free_result($searchresults);
?>