Add/remove input field javascript and mysql.

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

faces
New php-forum User
New php-forum User
Posts: 11
Joined: Thu Mar 28, 2013 11:18 pm

Add/remove input field javascript and mysql.

Postby faces » Wed May 01, 2013 2:10 am

Hey!
How to do that. I have form and there is "add new" and then open
new input textbox and when click submit then save it database.
All textbox data must be new row in database.

Code: Select all

<html>
<head>
<title>Silmaring</title>
<meta name="description" content="Silmaring">
<meta name="author" content="Silmaring">
<STYLE type="text/css">
   #ained {
position:absolute;
margin-top:40px;
}
  #ope {
position:absolute;
margin-top:40px;
margin-left:200px;
}
#lisa {
position:absolute;
margin-top:500px;
}
 </STYLE>
</head>
<body>
    <form action= "" method="post" enctype="multipart/form-data">
    <H2>Registeeri uus kool</h2>
Koolinimi:
 <input type="text" name = "kool" size="15" /></br>

 <div id="ained">
Ained:</br>
<input type="text" name="aine" id="aine"><br>
<input type="text" name="aine" id="aine"><br>
</div>
<div id="ope">
Õpetajad:
<input type="text" name="ope" id="ope"><br>
<input type="text" name="ope" id="ope"><br>
</div>

<div id="lisa">
</br><input type="submit" value="Lisa kool" />
 </div>
</form>
</body>
</html>
<?php
error_reporting(E_ALL ^ E_NOTICE);
$kool = $_REQUEST['kool'];
$aine = $_REQUEST['aine'];
$ope = $_REQUEST['ope'];
// MySQL uhendus
$user="root";
$password="asd876";
$database="silmaring";
$con="localhost";
mysql_connect($con,$user,$password);
@mysql_select_db($database) or die( "Unable to select database");
mysql_query("CREATE TABLE $kool(id int(6) NOT NULL auto_increment,aine varchar(50) NOT NULL,opetaja varchar(50) NOT NULL,PRIMARY KEY (id),UNIQUE id (id),KEY id_2 (id))");
mysql_query("INSERT INTO $kool(aine,opetaja) VALUES ('$ope','$ope')");
mysql_query("INSERT INTO $kool(aine,opetaja) VALUES ('$ope','$ope')");
mysql_close();
?>

Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 5 guests