form submission

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dru_nasty
Forum Commoner
Posts: 81
Joined: Sat Sep 10, 2005 10:26 am

form submission

Post by dru_nasty »

The following isn't working, and I'm not sure why.

I've got a basic form to add email addresses

Code: Select all

<html> 
<head><title>Do Not Email</title></head> 
<body> 
    <form action="donotemailphp.php" method="POST">
Enter your email address to take your name off the list.<br><br>
<input type="text" name="email" size="30">
<p><input type="submit" name="submit" value="Submit"></p>
</form>
</body> 
</html>
and the donotemailphp.php file

Code: Select all

<?
include_once('/usr/home/fss/websites/fivestarsports.net/inc/func.inc.php');
$db_conn = five_connect_db();
mysql_select_db('fivestar',$db_conn);
$sql = "INSERT INTO donotemail(email) VALUES ('', '$_POST[email]')";
if (mysql_query($sql, $db_conn)) {
echo "record added!";
}else{
echo "something went wrong in database communication";
}
?>
Does anyone see anything wrong? I'm still a newb by the way.
Thanks.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you've told mysql you want to insert one field, but you give it two fields.
dru_nasty
Forum Commoner
Posts: 81
Joined: Sat Sep 10, 2005 10:26 am

Post by dru_nasty »

ahh, that's it, thanks, it's working now! :D
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Post by nickman013 »

can you please post the working php script... thanks alot!
dru_nasty
Forum Commoner
Posts: 81
Joined: Sat Sep 10, 2005 10:26 am

Post by dru_nasty »

Code: Select all

$sql = "INSERT INTO donotemail(email) VALUES ('$_POST[email]')";
Post Reply