1
PHP / проблема с переменной из формы
« : 30 Ноября 2003, 07:40:10 »
Здравствуйте. Подскажите, пожалуйста, я здесь что-то напутал и у меня не вставляется переменная name из формы в бд.
<?php
if (isset($_POST[\'submit\'])) {
mysql_connect () or die (\'no connect db\');
mysql_query(\'create database volk\');
mysql_select_db(\'volk\') or die (\'no select db\');
mysql_query(\'create table clients (id int(4) not null auto_increment, primary key (id), name varchar (25))\')
or (mysql_query(\'select * from clients\') or die (\'no select clients\'));
mysql_query("insert into clients values (\'id\',\'$name\')") or die (\'not insert values\');
print "client add";
}
if (isset($_GET[\'action\']) == \'add\') {
print "
<form action=" . $_SERVER[\'PHP_SELF\'] . "?&action=sub method=post>
<input type=text name=name>
<input type=submit name=submit value=\'Submit\'>
</form>";
} else {
print "<a href=" . $_SERVER[\'PHP_SELF\'] . "?&action=add>Add new client</a>";
}
?>
<?php
if (isset($_POST[\'submit\'])) {
mysql_connect () or die (\'no connect db\');
mysql_query(\'create database volk\');
mysql_select_db(\'volk\') or die (\'no select db\');
mysql_query(\'create table clients (id int(4) not null auto_increment, primary key (id), name varchar (25))\')
or (mysql_query(\'select * from clients\') or die (\'no select clients\'));
mysql_query("insert into clients values (\'id\',\'$name\')") or die (\'not insert values\');
print "client add";
}
if (isset($_GET[\'action\']) == \'add\') {
print "
<form action=" . $_SERVER[\'PHP_SELF\'] . "?&action=sub method=post>
<input type=text name=name>
<input type=submit name=submit value=\'Submit\'>
</form>";
} else {
print "<a href=" . $_SERVER[\'PHP_SELF\'] . "?&action=add>Add new client</a>";
}
?>