Help with a mailing list

Hello,

I know very little about PHP, i am a graphics and HTML guy :), i had a simple mailing list script up on a clients page for a couple years, and now all of a sudden it has stopped working. When you enter your name, and email, you get “select fails” and it does not get added to the database.

Here is the code, any help would be great, i am lost since nothign has changed, but it just stoppped working.

from the config.php file

function insert_mail() {

	$fname = $_POST['fname'];
	$lname = $_POST['lname'];
	$email = $_POST['email'];


	$sql2="select * from mail where email='$email'";
	$result2=mysql_query($sql2) or die("select fails");
	$no=mysql_num_rows($result2);



	if ($no==0) {


		$sql = "insert into mail(id,fname,lname,email) values(NULL,'$fname','$lname','$email')";
		$result = mysql_query($sql) or die("insert fails");

		echo "Email added to list: " . LISTNAME;

	} else {

		echo "Email Address Already Exists in List: " . LISTNAME;

	}



}

function delete_mail() {

    $email = $_POST['email'];

    if ($email == "") {
       $email = $_GET['email'];
    }

    $sql2="select * from mail where email='$email'";
    $result2=mysql_query($sql2) or die("select  fails");
    $no=mysql_num_rows($result2);

    if ($no==0) {
       echo "Your email was not found in the list: " . LISTNAME;
    } else {
       echo "Your email was unsubscribed from the list: " . LISTNAME;
    }

    $sql2="delete from mail where email='$email'";
    $result2=mysql_query($sql2) or die("unsubscribe failed, please try again");

}

?>

From the HTML


<center>

<form action='<? echo BASEHREF; ?>index.php' method=post>

<TABLE BORDER=0 ALIGN=center>
	<TR>

		<TD><b>first name</b></TD>
		<TD><INPUT TYPE=text name=fname></TD>

	</TR>


	<TR>
		<TD><b>last name</b></TD>
		<TD><INPUT TYPE=text name=lname></TD>
	</TR>

	<TR>
		<TD><b>email</b></tD>
		<TD><INPUT TYPE=text name=email></td>
	</tR>

	<TR>
		<TD colspan=2 align=center><INPUT TYPE=submit value=join> <INPUT TYPE=reset value=reset><BR></TD>
	</tR>

</TABLE>


</FORM>

</center>

Let me know what else you may need…

That could be any number of things. Change “select fails” to mysql_error() and you’ll get a more descriptive error message. Post the new error message.

$result2=mysql_query($sql2) or die(mysql_error());

Don’t forget to sanitize your POST variables!