OK... Made some progress!
Now, upon adding a song and artist to the makemusic.htm form, it saves to the database. But I do get an error. It is: Notice: Undefined variable: songid in c:\program files\easyphp1-7\www\info\makemusic1.php on line 16
If I try to remove the $songid, the sqlquery fails, so apparently, I need it in there.
Another problem: The php script on the makemusic.htm does not function. What's wrong with it?
Here is my SQL database information:
Query:
explain songs;
Result Set:
Field Type Null Key Default Extra
songid bigint(20) PRI auto_increment
songname varchar(20)
groupname varchar(20)
And here is the code from my two pages:
This is the form to add a song:
makemusic.htm
<html>
<head>
<title>Add</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<table width="350" border="0" align="center" cellpadding="0" cellspacing="0" height="277">
<tr>
<td bgcolor="#000000" height="2">
<div align="center"><b><font color="#FFFFFF">ADD A RECORD</font></b></div>
</td>
</tr>
<tr>
<td width="48%" height="121" bgcolor="#CCCCCC">
<form name="form1" method="post" action="makemusic1.php">
<table width="75%" border="0" align="center">
<tr>
<td width="36%"><b> Name</b></td>
<td width="64%">
<div align="center">
<input type="text" name="songname" size="20">
</div>
</td>
</tr>
<tr>
<td colspan=2>
<div align="center">
<select name="artist" tabindex="4" onChange=submit()>
<option value="notset">- or select an artist -</option>
<?
//--- CREATE ARTIST SELECT ---
$sql = "SELECT DISTINCT songname FROM songs ORDER BY songname";
$artists = mysql_query($sql) or die($sql . '<br />' . mysql_error());
while ($row = mysql_fetch_array($songname)) {
echo '<option value="' . $row['songname'] . '">' . $row['songname'] . '</option>';
}
?>
</select>
</div>
</td>
</tr>
<tr>
<td width="36%"><b>Group</b></td>
<td width="64%">
<div align="center">
<input type="text" name="groupname" size="20">
</div>
</td>
</tr>
<tr>
<td colspan="2">
<div align="center">
<input type="submit" name="Submit22" value="Submit">
</div>
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</body>
</html>
And this is the page to display the addition:
makemusic1.php
<html>
<head>
<title>Untitled</title>
</head>
<body>
<?php
$connect= mysql_connect("localhost","root","******")
or die("Could not connect to database in localhost !");
$result=mysql_select_db("music")
or die("Could not select music database !");
$sqlquery = "INSERT INTO songs VALUES('". $songid ."','". $songname ."','". $groupname ."')";
$queryresult = mysql_query($sqlquery) or die(" Could not execute mysql query !");
echo "<table border=1 align=center width=500>";
echo " <tr> ";
echo " <td> ";
echo " Song Name";
echo " </td>";
echo " <td>".$songname. "</td>";
echo " </tr>";
echo " <tr> ";
echo " <td > ";
echo " Group";
echo " </td>";
echo " <td >".$groupname. "</td>";
echo " </tr>";
//echo " <tr> ";
//echo " <td > ";
//echo " Song ID";
//echo " </td>";
//echo " <td>".$songid. "</td>";
//echo " </tr>";
//echo " <tr> ";
//echo " <td colspan=2> ";
//echo " Add another record <a href="http://localhost/info/makemusic.htm">LINK</a>";
//echo " </td>";
//echo " </tr>";
echo "</table>";
?>
Add another record <a href="http://localhost/info/makemusic.htm">LINK</a>
</body>
</html>