mouse
09-20-2002, 11:21 PM
I have a form:<html>
<head>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<form method="post" name="form" action="addremove.php">
<p>Name: <input name="name"></p>
<p>Email address: <input name="email"></p>
<p><input type="radio" name="radio" value="add" checked> Add to list <input type="radio" name="radio" value="remove"> Remove from list</p>
<br/>
<p><input type="submit" name="submit" value="submit"> <input type="reset" name="reset"></p>
</form>
</body>
</html>
And a php script to process it:<?
include("connection.php");
if($radio == "add"){
mysql_query("INSERT INTO $table SET name=$name, email=$email)");
}
if($radio == "remove"){
mysql_query("DELETE FROM $table WHERE name=$name AND email=$email");
}
?>
<a href="index.html">To index</a>
The table has been created with the following query:$query=mysql_query("CREATE TABLE newsletter (ID INT (5) not null AUTO_INCREMENT, name VARCHAR (20) not null , email VARCHAR (30) not null , PRIMARY KEY (ID))");
Can anyone see why this isn't working from the above? It doesn't seem to be a connection problem, the table has been created okay but adding names to the database doesn't work. :confused:
<head>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<form method="post" name="form" action="addremove.php">
<p>Name: <input name="name"></p>
<p>Email address: <input name="email"></p>
<p><input type="radio" name="radio" value="add" checked> Add to list <input type="radio" name="radio" value="remove"> Remove from list</p>
<br/>
<p><input type="submit" name="submit" value="submit"> <input type="reset" name="reset"></p>
</form>
</body>
</html>
And a php script to process it:<?
include("connection.php");
if($radio == "add"){
mysql_query("INSERT INTO $table SET name=$name, email=$email)");
}
if($radio == "remove"){
mysql_query("DELETE FROM $table WHERE name=$name AND email=$email");
}
?>
<a href="index.html">To index</a>
The table has been created with the following query:$query=mysql_query("CREATE TABLE newsletter (ID INT (5) not null AUTO_INCREMENT, name VARCHAR (20) not null , email VARCHAR (30) not null , PRIMARY KEY (ID))");
Can anyone see why this isn't working from the above? It doesn't seem to be a connection problem, the table has been created okay but adding names to the database doesn't work. :confused: