Hi.
I am having trouble with a few of my PHP scripts.
I can't find anything wrong with them, and they produce no error, but they don't execute anything.

So basically, what happens is, I have some HTML at the top of the page, which will always be displayed. Now, say it is a script add something to a database..
I have a if ($add=='1') {
and the code inside it.. However, it just doesn't execute at all! It just produces the HTML i specified at the top, and then a blank page.

Here is the code of one of the scripts (it has happened with a few of my scripts):

Code:
<?php
require("key.php");
?>

<html>
<title>ADD TARGETTED ADVERT - eliter advert management system.</title>
<body bgcolor="ffffff" text="000000" topmargin=1 leftmargin=1 rightmargin=1>
<link rel="stylesheet" href="../style.css" TYPE="text/css">

<table cellpadding=0 cellspacing=0 border=0 bgcolor=ffffff width=580>
<tr width=580 valign=top><td width=300>
<img src="titleadvertsys.gif">
</td>
<td width=280></td>
</tr></table>
<br>

<?php

mysql_connect("$connection", "$mysqlusername", "$mysqlpassword") or die ("Could not connect to the database.");
mysql_select_db("$eliterdb") or die ("Could not connect to the 'eliter' database.");

if  ($add == 1)  {

if ( isset ($login) ) {

$idget = mysql_query("SELECT id FROM advertisers WHERE login='$login' ");

while ( $getid = mysql_fetch_array($idget) ) {

$advertiserid = $getid["id"];

}
?>

<img src=../arrow.bmp> <font class=tenpt><u>Add Targetted Advert</u></font><br><br><br>

<form name=addadvert action="<?php echo($PHP_SELF);?>" method=post>

<table cellspacing=1 cellpadding=1 bgcolor="ffffff" width="400">
<tr bgcolor="ffffff" width=400>
<td width=140 bgcolor=eeeeee><font class=tenpt>Advertiser:</font></td>
<td width=10></td>
<td width=250><font class=tenpt><?php echo($login);?></font></td>
</tr>

<input type=hidden name=login value="<?php echo($login); ?>">
<input type=hidden name=advertiserid value="<?php echo($advertiserid); ?>">

<tr bgcolor="ffffff" width=400>
<td width=140 bgcolor=eeeeee><font class=tenpt>Password:</font></td>
<td width=10></td>
<td width=250><input type=password style="font-family:arial;" name="advertiserpassword"></td>
</tr>

<tr><td><br></td></tr>

<tr bgcolor="ffffff" width=400>
<td width=140 bgcolor=eeeeee><font class=tenpt>Keyword:</font></td>
<td width=10></td>
<td width=250><input type=text style="font-family:arial;" name=keyword></td>
</tr>


<tr bgcolor="ffffff" width=400>
<td width=140 bgcolor=eeeeee><font class=tenpt>Title of Advert:</font></td>
<td width=10></td>
<td width=250><input type=text style="font-family:arial;" name=adtitle></td>
</tr>


<tr bgcolor="ffffff" width=400>
<td width=140 bgcolor=eeeeee><font class=tenpt>Show URL:</font></td>
<td width=10></td>
<td width=250><input type=text style="font-family:arial;" name="adshowurl"></td>
</tr>

<tr bgcolor="ffffff" width=400>
<td width=140 bgcolor=eeeeee><font class=tenpt>Actual Link:</font></td>
<td width=10></td>
<td width=250><input type=text style="font-family:arial;" name=adlink value="http://"></td>
</tr>


<tr bgcolor="ffffff" width=400>
<td width=140 bgcolor=eeeeee><font class=tenpt>Description:</font></td>
<td width=10></td>
<td width=250><textarea style="font-family:arial;" name=adtext rows=3 cols=25></textarea></td>
</tr>

<tr><td><br></td></tr>

<tr bgcolor="ffffff" width=400>
<td width=140 bgcolor=eeeeee><font class=tenpt>Payment:</font></td>
<td width=10></td>
<td width=250><SELECT style="font-family:arial;" name=payment><option value=perclick selected>Per Click</option></select></td>
</tr>

<tr bgcolor="ffffff" width=400>
<td width=140 bgcolor=eeeeee><font class=tenpt>Initial Status:</font></td>
<td width=10></td>
<td width=250><SELECT style="font-family:arial;" name=active><option value=n selected>Inactive</option><option value=y>Active</option></select></td>
</tr>

<tr><td colspan=3><br><font class=sevenptverdana>(These details can be modified at any time, in advertiser area)</font><br><br></td></tr>

<tr bgcolor="ffffff" width=400>
<td width=140></td>
<td width=10></td>
<td width=250>


<input type=submit style="font-family:arial;" value="Add Advert to Account" name=submit>
</form>
<form name=previewadvert action="previewadvert.php" method=post>
<input type=submit style="font-family:arial;" value="Preview Advert" name=preview>
</td>
</tr>
</table>

<br>
<font class=eightptverdana><b>Note:</b> Each new targetted advert must be validated by the administrator.</font>
</form>

<?php

} else {
echo("<font class=twelvept><b>You are not logged in</b></font><br>$backhtml"); 
}



if ($submit) {
echo("$login<br>");
echo("$advertiserid");


/* check the password entered against the real password */
 
$result = mysql_query("SELECT adpassword FROM advertisers WHERE login='$login' ");

while ( $pwget = mysql_fetch_array($result) ) {

$adpw = $pwget["adpassword"];

echo("$adpw");
}

if ('$advertiserpassword' == '$adpw') {

$submitsql = "INSERT INTO adverts SET advertiser='$advertiserid', 
		keyword='$keyword', adtitle='$adtitle', adshowurl='$adshowurl', 
		adlink='$adlink', adtext='$adtext', payment='$payment', validated='n', address='$address' ";
		
if (mysql_query($submitsql)) {
echo("THE ADVERT HAS BEEN ADDED!");
} else {
echo("There was an error adding the advert :<br>" .
mysql_error() . "<br>");
}

} else {
echo("Invalid Password");

}
}
}
?>
Sorry for the long code.
However, this is really annoying me.. Its probably a simple error, but I really need it sorted!
Cheers
-AJ