My website is having a weird problem.
When a person registers on my page, they can list 1 item for free. But, when that person posts the item, it does not show up in the search engine, or under the catetory listed. (check out www.n2ads.com and register to see what i mean.) It does, however show up under their Manage Listings page.
Now, what is werid, is if I create a username and password for a member under my site admin, and they go to www.n2ads.com to post an item, everything is fine. It shows up in the search engine and under the category.
Here are my php codes for my webpages.
register page
<?
require_once("conn.php");
require_once("includes.php");
if(isset($_POST[s1]))
{
$MyExp = mktime(0,0,0,date(m) + 1, date(d), date(Y));
$q1 = "insert into re2_agents set
username = '$_POST[NewUsername]',
AccountType = '$_POST[AccountType]',
password = '$_POST[p1]',
FirstName = '$_POST[FirstName]',
LastName = '$_POST[LastName]',
resume = '$_POST[resume]',
phone = '$_POST[phone]',
cellular = '$_POST[cellular]',
pager = '$_POST[pager]',
ResumeImages = '$ImageStr',
email = '$_POST[email]',
RegDate = '$t',
ExpDate = '$MyExp',
AccountStatus = 'active',
offers = '1' ";
mysql_query($q1);
if(ereg("key 2", mysql_error()))
{
$error = "<font face=verdana size=2 color=red><b>The username <font color=black>$_POST[NewUsername]</font> is already in use!<br>Select another one, please!</b></font>";
unset($_POST[NewUsername]);
}
elseif(ereg("key 3", mysql_error()))
{
$error = "<font face=verdana size=2 color=red><b>You are already registered!<br>Update your account, please!</b></font>";
unset($_POST);
}
else
{
$last = mysql_insert_id();
$_SESSION[NewAgent] = $last;
//send an email
$to = $_POST[email];
$subject = "Your registration at $_SERVER[HTTP_HOST]";
$message = "Hello $_POST[FirstName] $_POST[LastName],\nhere is your login information for $_SERVER[HTTP_HOST]\n\nUsername: $_POST[NewUsername]\nPassword: $_POST[p1]\n\nYou are able to post a free listing. To login, follow this link:\n$site_url/login.php\n\nThank you for your registration!";
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\n";
$headers .= "Content-Transfer-Encoding: 8bit\n";
$headers .= "From: $_SERVER[HTTP_POST] <$aset[ContactEmail]>\n";
$headers .= "X-Priority: 1\n";
$headers .= "X-MSMail-Priority: High\n";
$headers .= "X-Mailer: PHP/" . phpversion()."\n";
mail($to, $subject, $message, $headers);
header("location:login.php");
exit();
}
}
if(!empty($_GET[AccountType]))
{
$AccountType = $_GET[AccountType];
}
else
{
$AccountType = $_POST[AccountType];
}
//get the templates
require_once("templates/HeaderTemplate.php");
require_once("templates/RegistrationTemplate.php");
require_once("templates/FooterTemplate.php");
?>
RegistrationTemplate:
<form method=post action="register.php" enctype="multipart/form-data" name=RegForm onsubmit="return CheckRegister();">
<table align=center width=300>
<caption align=center>
<font face=verdana size=2><b>Registration Form</b></font><br>
<?=$error?></caption>
<tr>
<td align=right>Username:</td>
<td><input type=text name=NewUsername value="<?=$_POST[NewUsername]?>"></td>
</tr>
<tr>
<td align=right>Password:</td>
<td><input type=password name=p1></td>
</tr>
<tr>
<td align=right>Confirm Password:</td>
<td><input type=password name=p2></td>
</tr>
<tr>
<td align=right>First Name:</td>
<td><input type=text name=FirstName value="<?=$_POST[FirstName]?>"></td>
</tr>
<tr>
<td align=right>Last Name:</td>
<td><input type=text name=LastName value="<?=$_POST[LastName]?>"></td>
</tr>
<tr>
<td align=right>Phone:</td>
<td><input type=text name=phone value="<?=$_POST[phone]?>"></td>
</tr>
<tr>
<td align=right>Email:</td>
<td><input type=text name=email value="<?=$_POST[email]?>"></td>
</tr>
<tr>
<td> </td>
<td>
<input type=hidden name=AccountType value="<?=$_GET[AccountType]?>">
<input type=submit name=s1 value="Submit">
</td>
</tr>
</table>
</form>
Manage listings:
<?
require_once("conn.php");
require_once("access.php");
require_once("includes.php");
if($_SESSION[AccountStatus] == "pending")
{
header("location:inactive.php");
exit();
}
//get the user offers
$q1 = "select * from re2_listings where AgentID = '$_SESSION[AgentID]' order by DateAdded desc ";
$r1 = mysql_query($q1) or die(mysql_error());
$rows = mysql_num_rows($r1);
if($rows > '0')
{
$ListingTable .= "<table align=center width=470 border=1 bordercolor=black frame=hsides rules=rows cellspacing=0>\n";
while($a1 = mysql_fetch_array($r1))
{
$ListingTable .= "<tr onMouseOver=\"this.style.background='#E2E2E2'; this.style.cursor='hand'\" onMouseOut=\"this.style.background='white'\" onClick=\"window.open('info.php?id=$a1[ListingID]', '_top')\">\n\t";
if($a1[PriorityLevel] > '1')
{
//get the priority level name
$qp = "select PriorityName from re2_priority where PriorityLevel = '$a1[PriorityLevel]' ";
$rp = mysql_query($qp) or die(mysql_error());
$ap = mysql_fetch_array($rp);
$sub = "<span class=RedLink><sup>$ap[0]</sup></span>";
}
else
{
$sub = "";
}
$ListingTable .= "\n\t<td width=15>";
if(!empty($a1[image]))
{
$ListingTable .= "<img src=\"myimages/camera.jpg\" width=15 height=15>";
}
$ListingTable .= "</td>\n\t";
$ListingTable .= "<td width=200><B>$a1[address]</B>$sub</td>\n\t";
$ListingTable .= "<td width=200>$a1[city], $a1[state], $sub</td>\n\t";
$MyPrice = number_format($a1[Price], 2, ".", ",");
$ListingTable .= "</td>\n\t<td align=center width=100><b>$$MyPrice</td>\n";
$ListingTable .= "</tr>\n";
}
$ListingTable .= "</table>";
}
if($rows < $_SESSION[MaxOffers])
{
$NewOffer = "<font face=verdana size=2>Click <a class=RedLink href=\"PostOffer.php\">here</a> to post a new offer.</font><BR>";
}
else
{
$NewOffer = "<span class=RedLink>If you want to post more properties, you should update your account!<br>Click <a class=BlackLink href=\"prices.php\">here</a> to continue.</span><bR>";
}
require_once("templates/HeaderTemplate.php");
require_once("templates/ManageListingsTemplate.php");
require_once("templates/FooterTemplate.php");
?>
Manage listings template:
<?=$NewOffer?><BR>
<?=$ListingTable?>
AddOffer page:
<?
require_once("conn.php");
if(isset($_POST[s1]))
{
if(!empty($_FILES[images][name][0]))
{
while(list($key,$value) = each($_FILES[images][name]))
{
if(!empty($value))
{
$NewImageName = $t."_offer_".$value;
copy($_FILES[images][tmp_name][$key], "re_images/".$NewImageName);
$MyImages[] = $NewImageName;
}
}
if(!empty($MyImages))
{
$ImageStr = implode("|", $MyImages);
}
}
$catInfo = explode("|", $_POST[SelectCategory]);
$CategoryID = $catInfo[0];
$SubcategoryID = $catInfo[1];
$q1 = "insert into re2_listings set
AgentID = '$_SESSION[AgentID]',
CategoryID = '$CategoryID',
SubcategoryID = '$SubcategoryID',
address = '$_POST[address]',
city = '$_POST[city]',
state = '$_POST[state]',
country = '$_POST[country]',
ShortDesc = '$_POST[ShortDesc]',
DetailedDesc = '$_POST[DetailedDesc]',
Price = '$_POST[Price]',
PropertyType = '$_POST[PropertyType]',
image = '$ImageStr',
DateAdded = '$t' ";
mysql_query($q1);
}
header("location:manage.php");
exit();
?>