OK
I am making a form that submits to a MySQL Database when submited. I have everything working fine. The one thing I would like to do is check to see if the artist the person entered is already in the database.
Here's the whole page that I have so far.
<HTML>
<HEAD>
<NOBANNER>
<META name="description" content="A Page For All Music Lovers."><style type="text/css">body {margin: 0px;}</style>
<TITLE>MusicFreaksOnline</TITLE>
</HEAD>
<BODY bgcolor="#000000" text="#DB0700" link="orange" vlink="orange">
<!--HEADER-->
<TABLE width="100%">
<TR><TD align="left" valign="top" colspan="3">
<IFRAME name="header" src=http://www.htmlforums.com/archive/index.php/"../header.html" width="100%" height="110" frameborder="0" scrolling="no"></IFRAME>
</TD>
</TR>
<TR>
<TD width="10%" align="left" valign="top" border="0">
<IFRAME src=http://www.htmlforums.com/archive/index.php/"../menu.html" width="162" height="1000" frameborder="0" scrolling="no"></IFRAME>
</TD>
<!--LEFT-->
<!--MAIN-->
<TD valign="top" width="*">
<TABLE width="100%" border="0" cellpadding="0" cellspacing="0"><TR><td align="center">
<font face="Arial, Helvetica, sans-serif">
<center><h2>Submit Your Band</h2>
If you ARE NOT a member of this band please use the <a href=http://www.htmlforums.com/archive/index.php/"band.php" target="_top">Submit A Band Form</a><br><br></center>
</font>
<?php
if ($submit) {
// process form
$db = mysql_connect("localhost", "name", "pass");
mysql_select_db("skafreaks",$db);
$sql = "INSERT INTO points (forumname,points,added) VALUES ('$forumname','$points','$artist''$date')";
$result = mysql_query($sql);
} else{
// display form
} // end if ?>
<?php
if ($submit) {
if (!$artist) {
$error = "YOU DIDN'T EVEN PUT IN AN ARTIST!!";
} else {
/* Check if username is already in use */
if(artistTaken($artist)){
$error = "error";
} else {
$db = mysql_connect("localhost", "name", "pass");
mysql_select_db("skafreaks",$db);
$sql = "INSERT INTO artistpages (artist,genre,stillplaying,picture,website,location,contact,messageboard,bio,edit) VALUES ('$artist','$genre','$stillplaying','$picture','$website','$location','$contact','$messageboard','$b io','$edit')";
$result = mysql_query($sql);
echo "Thank You!";
}
}
}
if (!$submit || $error) {
echo $error;
?>
<form method="post" action="<?php echo $PHP_SELF?>">
<table width="100%">
<tr><td>Forum Name:</td><td><input type="Text" name="forumname" size="50"></td></tr>
<input type="hidden" name="points" value="50">
<tr><td> Artist Name: </td><td><INPUT TYPE="text" NAME="artist" SIZE=50></td></tr>
<tr><td> Contact Email Address: </td><td><INPUT TYPE="text" NAME="contact" SIZE=50></td></tr>
<tr><td> Geographic Location: </td><td><INPUT TYPE="text" NAME="location" VALUE="Country, State, City" SIZE=50></td></tr>
<tr><td> URL Address: </td><td><INPUT TYPE="text" NAME="website" SIZE=50></td></tr>
<tr><td> Message Board URL: </td><td><input type="Text" name="messageboard" size="50"></td></tr>
<tr><td> Bands Genre:<br>you may choose multiple genres by holding down 'ctrl'.</td><td>
<select NAME="genre" multiple>
<option VALUE="Irish">Irish
<option VALUE="Jam">Jam Rock
<option VALUE="Punk">Punk
<option VALUE="Reggae">Reggae
<option VALUE="Ska">Ska
<option VALUE="Skacore">Ska-Core
<option VALUE="SkaPunk">Ska Punk
<option VALUE="Skatwotone">Ska Two-Tone
</select></td></tr>
<tr><td> Is the band still playing together? </td><td><INPUT TYPE="radio" NAME="stillplaying" VALUE="yes">Yes <INPUT TYPE="radio" NAME="stillplaying" VALUE="no">No <INPUT TYPE="radio" NAME="stillplaying" VALUE="ns">Not Sure</td></tr>
<tr><td> Would you like to be able to edit your bands information on the page?<br>
If you select yes I will email a user name and password to the Contact Email Address above. If you have not entered an email you will not recieve your password and will not be able to edit anything.</td><td><INPUT TYPE="radio" NAME="edit" VALUE="yes">Yes <INPUT TYPE="radio" NAME="edit" VALUE="no">No</td></tr>
</table>
<input type="Submit" name="submit" value="Enter information">
</form>
<?php
}
?>
</body>
</html>
I tried to use a piece of another script to get it to work but it isn't working
/* Check if username is already in use */
if(artistTaken($artist)){
$error = "error";
} else {
Can someone either let me know how to do this or point me to a place to read and learn how to do this?
Thanks A Lot!$query = mysql_query("SELECT * FROM artists WHERE artist = 'artist'") or die(mysql_error());
$count = mysql_num_rows($query);
if($count > 0)
{
echo 'exists';
}
else
{
echo 'oh no!no record!';
}sweet. That worked perfectly! Thanks!!!!
I am making a form that submits to a MySQL Database when submited. I have everything working fine. The one thing I would like to do is check to see if the artist the person entered is already in the database.
Here's the whole page that I have so far.
<HTML>
<HEAD>
<NOBANNER>
<META name="description" content="A Page For All Music Lovers."><style type="text/css">body {margin: 0px;}</style>
<TITLE>MusicFreaksOnline</TITLE>
</HEAD>
<BODY bgcolor="#000000" text="#DB0700" link="orange" vlink="orange">
<!--HEADER-->
<TABLE width="100%">
<TR><TD align="left" valign="top" colspan="3">
<IFRAME name="header" src=http://www.htmlforums.com/archive/index.php/"../header.html" width="100%" height="110" frameborder="0" scrolling="no"></IFRAME>
</TD>
</TR>
<TR>
<TD width="10%" align="left" valign="top" border="0">
<IFRAME src=http://www.htmlforums.com/archive/index.php/"../menu.html" width="162" height="1000" frameborder="0" scrolling="no"></IFRAME>
</TD>
<!--LEFT-->
<!--MAIN-->
<TD valign="top" width="*">
<TABLE width="100%" border="0" cellpadding="0" cellspacing="0"><TR><td align="center">
<font face="Arial, Helvetica, sans-serif">
<center><h2>Submit Your Band</h2>
If you ARE NOT a member of this band please use the <a href=http://www.htmlforums.com/archive/index.php/"band.php" target="_top">Submit A Band Form</a><br><br></center>
</font>
<?php
if ($submit) {
// process form
$db = mysql_connect("localhost", "name", "pass");
mysql_select_db("skafreaks",$db);
$sql = "INSERT INTO points (forumname,points,added) VALUES ('$forumname','$points','$artist''$date')";
$result = mysql_query($sql);
} else{
// display form
} // end if ?>
<?php
if ($submit) {
if (!$artist) {
$error = "YOU DIDN'T EVEN PUT IN AN ARTIST!!";
} else {
/* Check if username is already in use */
if(artistTaken($artist)){
$error = "error";
} else {
$db = mysql_connect("localhost", "name", "pass");
mysql_select_db("skafreaks",$db);
$sql = "INSERT INTO artistpages (artist,genre,stillplaying,picture,website,location,contact,messageboard,bio,edit) VALUES ('$artist','$genre','$stillplaying','$picture','$website','$location','$contact','$messageboard','$b io','$edit')";
$result = mysql_query($sql);
echo "Thank You!";
}
}
}
if (!$submit || $error) {
echo $error;
?>
<form method="post" action="<?php echo $PHP_SELF?>">
<table width="100%">
<tr><td>Forum Name:</td><td><input type="Text" name="forumname" size="50"></td></tr>
<input type="hidden" name="points" value="50">
<tr><td> Artist Name: </td><td><INPUT TYPE="text" NAME="artist" SIZE=50></td></tr>
<tr><td> Contact Email Address: </td><td><INPUT TYPE="text" NAME="contact" SIZE=50></td></tr>
<tr><td> Geographic Location: </td><td><INPUT TYPE="text" NAME="location" VALUE="Country, State, City" SIZE=50></td></tr>
<tr><td> URL Address: </td><td><INPUT TYPE="text" NAME="website" SIZE=50></td></tr>
<tr><td> Message Board URL: </td><td><input type="Text" name="messageboard" size="50"></td></tr>
<tr><td> Bands Genre:<br>you may choose multiple genres by holding down 'ctrl'.</td><td>
<select NAME="genre" multiple>
<option VALUE="Irish">Irish
<option VALUE="Jam">Jam Rock
<option VALUE="Punk">Punk
<option VALUE="Reggae">Reggae
<option VALUE="Ska">Ska
<option VALUE="Skacore">Ska-Core
<option VALUE="SkaPunk">Ska Punk
<option VALUE="Skatwotone">Ska Two-Tone
</select></td></tr>
<tr><td> Is the band still playing together? </td><td><INPUT TYPE="radio" NAME="stillplaying" VALUE="yes">Yes <INPUT TYPE="radio" NAME="stillplaying" VALUE="no">No <INPUT TYPE="radio" NAME="stillplaying" VALUE="ns">Not Sure</td></tr>
<tr><td> Would you like to be able to edit your bands information on the page?<br>
If you select yes I will email a user name and password to the Contact Email Address above. If you have not entered an email you will not recieve your password and will not be able to edit anything.</td><td><INPUT TYPE="radio" NAME="edit" VALUE="yes">Yes <INPUT TYPE="radio" NAME="edit" VALUE="no">No</td></tr>
</table>
<input type="Submit" name="submit" value="Enter information">
</form>
<?php
}
?>
</body>
</html>
I tried to use a piece of another script to get it to work but it isn't working
/* Check if username is already in use */
if(artistTaken($artist)){
$error = "error";
} else {
Can someone either let me know how to do this or point me to a place to read and learn how to do this?
Thanks A Lot!$query = mysql_query("SELECT * FROM artists WHERE artist = 'artist'") or die(mysql_error());
$count = mysql_num_rows($query);
if($count > 0)
{
echo 'exists';
}
else
{
echo 'oh no!no record!';
}sweet. That worked perfectly! Thanks!!!!