Having some trouble with the simple task passing variables via a form!
<? // start the session
session_start();
header("Cache-control: private"); //IE 6 Fix
?>
<?
// Asign session variables
$useranme = $_SESSION['username'];
$artist = addslashes ($_POST['artist']);
?>
<table width="100%" border="0" cellpadding="5">
<tr>
<td width="41%">Welcome <? echo $_SESSION['username']; ?></td>
<td width="59%"><div align="right"> </div></td>
</tr>
<tr>
<td height="29"><a href="index.php">Home</a> : <a href="edit_profile.php">Profile</a>
: <a href="logout.php"> Log-out</a></td>
<td><div align="right"></div></td>
</tr>
</table>
<?
include "db.php";
$sql = "SELECT * FROM `cds` WHERE `artist` = '$artist'";
$result = mysql_query($sql);
if (!$result) {
echo "Could not successfully run query ($sql) from DB: " . mysql_error();
exit;
}
if (mysql_num_rows($result) == 0) {
echo "<h4 align=center>Could not find any CD's by ".$artist."!</h4>";
exit;
}
?>
<table width="700" cellpadding="5" cellspacing="0">
<tr bgcolor="#F2F2F2">
<td width="119">Title </td>
<td width="82">
<div align="left">Status</div>
</td>
<td width="191">Promotion</td>
<td width="44">Price</td>
<td width="67"> </td>
<td width="135"> </td>
</tr>
<? while ($row = mysql_fetch_array($result))
{
extract($row);
//If CD's are availble print Cd's
if ($cd_title == NULL) { echo "No CD's Available";
}
else {
echo "<tr><td>".$cd_title."</td>";
echo "<td>".$cd_status."</td>";
echo "<td>".$cd_promotion."</td>";
echo "<td>".$cd_price."</td>";
echo "<td><div align='right'>";
echo "<form action='edit_cd.php' method='POST'>";
echo "<input type='hidden' name='cd_title' value='".$cd_title."'>";
echo "<input name='POST' type='submit' value='Edit'>";
echo "</form></div></td>";
echo "<td><form name=\"tracks\" method=\"POST\" action=\"tracks.php\">";
echo "<input type='hidden' name='cd_title' value='".$cd_title."'>";
echo "<input type='hidden' name='artist' value='".$artist."'>";
echo "<input type=\"submit\" name=\"Submit\" value=\"Tracks\"></form>";
}
}
mysql_free_result($result);
mysql_close($conn);
?>
</td>
</tr>
</table>
When I run it It outputs:
Could not find any CD's by !
Which leads me to think that the $artist varible is not being passed to it from this script:
<? // start the session
session_start();
header("Cache-control: private"); //IE 6 Fix
// Asign session variables
$username = $_SESSION['username'];
?>
<table width="100%" border="0" cellpadding="5">
<tr>
<td width="41%">Welcome <? echo $_SESSION['username']; ?></td>
<td width="59%"><div align="right"> </div></td>
</tr><tr>
<td height="29"><a href="index.php"> Home</a> : <a href="new_cd.php">New
CD </a> : <a href="new_artist.php">New Artist</a> : <a href="logout.php">Log-out</a>
</td>
<td><div align="right"></div></td>
</tr>
</table>
<table width="100%" border="0" cellpadding="5">
<tr>
<td width="92%">
</td>
</tr>
</table>
<table width='400' border="1" cellpadding='5' cellspacing='0' bordercolor="#FFFFFF">
<tr bgcolor='#F2F2F2'>
<td height="26" bordercolor="#CCCCCC" bgcolor='#E2E2E2'>View & Edit Artist</td>
</tr>
<tr>
<tr>
<td width='28%' bordercolor="#CCCCCC" bgcolor='#F4F4F4'>
<form action='admin_edit_artist.php' method='P0ST'>
<select name='artist'>
<?
include "db.php";
$sql = "SELECT * FROM `users` WHERE `user_group` = 'artist' ";
$result = mysql_query($sql);
if (!$result) {
echo "Could not successfully run query ($sql) from DB: " . mysql_error();
exit;
}
if (mysql_num_rows($result) == 0) {
echo "<h4 align=center>Could not find any artists!</h4>";
exit;
}
while ($row = mysql_fetch_array($result))
{
extract($row);
print "<option>".$artist."</option>";
}
mysql_free_result($result);
mysql_close($conn);
?>
</select>
<input name='POST' type='submit' value='Select'>
</form>
</td>
</tr>
</table>
I gone over it and over it but I carnt figure out why it's not passing the variable... ๐