PHP Ad Tracker: Site Administration Ad Banner Data Form

If you have read any of the other posts in this series you know that we have done quite a bit with our PHP ad tracker.

In this session, we will look at the HTML form that calls these actions.

First, we create the HTML table that will hold the form header:

<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td><b>Developer Drive Advertisements Administration</b></td>
</tr>

Next, we specify the operation (add/edit/delete/deactivate) for this form and display that operation:

<tr>
<td> To <?php print $op ?> this item in the system, please complete the form below.</td>
</tr>

If any errors occurred, we display them in red

<tr>
<td><font color=”red”><?php writeErrors() ?></font></td>
</tr>
</table>

The form action will call the routines we outlined in last week’s session. When the user submits the form, the form will also carry the requested operation and the ID number for the ad banner.

<form action="<?php print SELF ?>?op=<?php print $op ?>&id=<?php print $id ?>" method="post" name="devdriveform" enctype="multipart/form-data">

The form calls the getClientsList function from the class file and creates a drop down menu listing each client’s name and ID number. If the ID number in the client table matches the number in the query string, then the menu highlights that option as selected.

<table border="0" cellpadding="0" cellspacing="0">
<?php
$aClients = $oAds->getClientsList();
if (count($aClients)) {
?>
<tr>
<td><div>Client:</div></td>
<td><select name="clientid" />
<option value="">Choose a client</option>
<?php
$i = 0;
while ($i < count($aClients)) {
if (!strcmp($aClients[$i]["Client Id"] , $iClientId)) {
?>
<option value="<?php print $aClients[$i]["Client Id"] ?>" selected><?php print clean($aClients[$i]["Client"]) ?></option>
<?php } else { ?>
<option value="<?php print $aClients[$i]["Client Id"] ?>"><?php print clean($aClients[$i]["Client"]) ?></option>
<?php } ?>
<?php
++$i;
}
?>
</select></td>
</tr>
<?php } ?>

The next row displays the title of the banner ad:

<tr>
<td><div>Banner Title:</div></td>
<td><input type="text" name="title" value="<?php print clean($sTitle) ?>" /></td>
</tr>

The next row displays the URL for that banner ad. When the user clicks on this banner, the browser redirects to that URL.

<tr>
<td><div>Banner URL:</div></td>
<td><input type="text" name="url" value="<?php print clean($sUrl) ?>" /></td>
</tr>

The next row displays the name of the file that contains the banner image.

<tr>
<td><div>Banner File:</div></td>
<td><input type="file" name="banner" value="<?php print clean($sImgName) ?>" /></td>
</tr>

The next row inserts a space between the banner information and the client form:

<tr>
<td colspan="2"><img src="../../_img/spacer.gif" width="1" height="15" alt="" border="0" /></td>
</tr>

If the operation query string does not specify that the user should add a new client, the form will display the client information in the form fields for editing.

<?php if (!strcmp("add", $op)) { ?>
<tr>
<td><div>Client Name:</div></td>
<td><input type="text" name="client" value="<?php print clean($sClient) ?>" /></td>
</tr>
<tr>
<td><div>Client Contact:</div></td>
<td><input type="text" name="contact" value="<?php print clean($sContact) ?>" /></td>
</tr>
<tr>
<td><div>Contact Email:</div></td>
<td><input type="text" name="email" value="<?php print clean($sEmail) ?>" /></td>
</tr>
<tr>
<td><div>Contact Phone:</div></td>
<td><input type="text" name="phone" value="<?php print clean($sPhone) ?>" /></td>
</tr>
<tr>
<td colspan="2"><img src="../../_img/spacer.gif" width="1" height="15" alt="" border="0" /></td>
</tr>

If the condition is not met, the page will print the information in a table rather than in the form fields.

<?php } else { ?>
<tr>
<td><div>Client Name:</div></td>
<td><?php print format($sClient) ?></td>
</tr>
<tr>
<td><div>Client Contact:</div></td>
<td><?php print format($sContact) ?></td>
</tr>
<tr>
<td><div>Contact Email:</div></td>
<td><?php print format($sEmail) ?></td>
</tr>
<tr>
<td><div>Contact Phone:</div></td>
<td><?php print format($sPhone) ?></td>
</tr>
<tr>
<td colspan="2"><img src="../../_img/spacer.gif" width="1" height="15" alt="" border="0" /></td>
</tr>
<?php } ?>

The last row includes the graphic for the “submit” button:

<tr>
<td align="right" colspan="2"><input type="image" src="../../_img/buttons/btn_submit.gif" alt="" border="0" /></td>
</tr>
</table>
</form>

As a whole, the ad banner application is relatively easy. While the details can sometimes be difficult to track, the system does a fine job of tracking ad banner activity, which helps many shops keep track of their ad revenues.

SHARE THIS POST
  • John

    That’s it, I’m unsubscribing from your RSS feed. Are you really using the font tag?

  • jeff_DD

    The font tag is deprecated but not yet obsolete. Thanks for pointing out the use of it in the tutorial. Ideally, we would want to see font attributes defined with CSS.

  • niek89

    ol1I – Last few years I used to be extremely low on $$ and debts were killing me from all sides! that was UNTIL i found out how to generate money on the INTERNET. I visited surveymoneymaker period net, and started doing surveys for money, and doing so i’ve been far more able to get around financialy!! I am very glad i did this!!! With all the financial stress these years, I really hope all of you will give it a chance. – kE3I