Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Help with a mailing list
Old 03-04-2011, 09:07 PM Help with a mailing list
Skilled Talker

Posts: 83
Trades: 0
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

Code:
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

Code:
<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....
__________________
»
Please login or register to view this content. Registration is FREE
- Interactive maps for websites
»
Please login or register to view this content. Registration is FREE
for web developers
DmitryS is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-11-2011, 11:09 PM Re: Help with a mailing list
Super Spam Talker

Posts: 880
Name: Paul W
Trades: 0
"or die" should be banned. Change that branch to use mysql_errror to display something meaningful and also print out the values you think you're getting from the form. That should indicate the issue. On a more general note you might want to do some validation of user input - it would be simple for someone to enter a wildcard and delete the whole table.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE


*** New:
Please login or register to view this content. Registration is FREE
PaulW is online now
Reply With Quote
View Public Profile
 
Reply     « Reply to Help with a mailing list
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.15738 seconds with 12 queries