The below code is giving me some grief. The snipit below I believe is the cause of h problem. its not redirecting correctly when I submit the form to search. the code stops and does not include the message and the “leftlinks’
any idea how to reorganize the coed to fix this
[code=php]
header(“location: SearchForm.php?msg=$msg”);
exit(); // if the error checking has failed, exit the script!
}
[code=php]
<?php
/* Check User Script */
session_start(); // Start Session
include (“Connections/db.php”);
//check if user is already logged in
if (!isset($_SESSION[‘user_id’])){
$msg = ‘You tryed to access a members only page. Login or become a registered member to access that page!’;
header(“Location: index.php?msg=”.$msg);
}
?>
<!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=iso-8859-1″ />
<title>Search</title>
<link rel=”stylesheet” type=”text/css” href=”design/niftyCorners.css”>
<link rel=”stylesheet” type=”text/css” href=”design/niftyPrint.css” media=”print”>
<script type=”text/javascript” src=”design/nifty.js”></script>
<link href=”design/main.css” rel=”stylesheet” type=”text/css” />
<script type=”text/javascript”>
window.onload=function(){
if(!NiftyCheck())
return;
<?php include(‘design/round.php’); ?>
}
</script>
</head>
<body>
<div id=”outer”>
<?php include(‘design/banner.php’); ?>
<div id=”sub”>
<div id=”center”>
<?php
$msg = (isset($_GET[‘msg’]) AND $_GET[‘msg’]<> “”) ? urldecode($_GET[‘msg’]) : ”;
if ($msg <> “”) {
if (get_magic_quotes_gpc()) {
$msg = stripslashes($msg);
}
echo “<div id=’formmessage’><p style=’margin-left:40px;’>$msg</p></div>”;
}
?>
<form name=”form1″ method=”post” action=”<?php echo $PHP_SELF; ?>”>
<table class=”columntable” cellspacing=”2″>
<th class=’tableheader’ colspan=’2′>Search familyclick.ca</td><br></tr>
<tr>
<td class=”rowLeft” scope=”row”><div align=”left”><strong>First Name*</strong></div></td>
<td class=”rowRight”><input name=”s_firstname” type=”text” id=”s_firstname” size=”15″></td>
</tr>
<tr>
<td class=”rowLeft” scope=”row”><div align=”left”><strong>Last Name*</strong></div></td>
<td class=”rowRight”><input name=”s_lastname” type=”text” id=”s_lastname” size=”15″></td>
</tr>
<tr>
<th colspan=”2″ scope=”row”><div align=”left”>
<input type=”submit” name=”Submit” value=”Submit”>
</div>
</tr>
</table>
</form>
<form name=”rowLeft” method=”post” action=”addbuddy.php”>
<table style=”margin:10px auto 0 auto; width:90%” class=”columnTable”>
<tr>
<td class=”tableheader” colspan=”3″>Search Results</td>
</tr>
<tr>
<td class=”rowLeft” style=”width:5%;”>Buddy</td>
<td class=”rowRight” style=”width:40%;”> Name</td>
<td class=”rowRight” style=”width:55%;”> Address</td>
</tr>
<?php
if(isset($_POST[‘Submit’])){
$s_firstname = trim($_POST[‘s_firstname’]);
$s_lastname = trim($_POST[‘s_lastname’]);
if((!$s_firstname) || (!$s_lastname))
{
if(!$s_firstname)
{
$msg .= “Enter First Name.<br />”;
}
if(!$s_lastname)
{
$msg .= “Enter Last Name.<br />”;
}
header(“location: SearchForm.php?msg=$msg”);
exit(); // if the error checking has failed, exit the script!
}
$query = (“SELECT * FROM users WHERE first_name LIKE ‘$s_firstname%’ AND last_name LIKE ‘$s_lastname%'”);
$result=mysql_query($query)or die(“Get Search results Error: “.mysql_error());
if(mysql_num_rows($result) < 1) {
$msg .= ‘<p> No matches found</p>’;
header(“location: SeachForm.php?msg=$msg”);
}
while($r=mysql_fetch_assoc($result))
{
$firstname = $r[‘first_name’];
$lastname = $r[‘last_name’];
$street = $r[‘street_address’];
$pobox = $r[‘post_office_box’];
$city = $r[‘city’];
$provice = $r[‘province’];
$postal = $r[‘postal’];
$dob = $r[‘DOB’];
$id = $r[‘user_id’];
?>
<tr>
<td class=”rowRight” style=”width:5%;”><input type=radio name=”addbuddy” value=”<?php echo $id; ?>”></td>
<td class=”rowRight” style=”width:40%;”><a href=”SearchDetails.php?owner_id=<?php echo $id; ?>”><?php echo $firstname.’ ‘. $lastname ?></a></td>
<td class=”rowRight” style=”width:55%;”> <?php echo $street.’ ‘. $pobox.’ ‘. $city.’ ‘. $province.’ ‘. $postal; ?></td>
</tr>
<?php }
}?>
</table>
<p><input style=”text-align:left;” type=”submit” name=”submit” value=”Add Buddies”></p>
</form>
</div>
<div id=”left”>
<?php include(‘design/leftlinks.php’); ?>
</div>
</div>
<div id=”right”></div>
<div id=”footer”>
<?php include(‘design/footer.php’); ?>
</div>
</div>
</body>
</html>