How to insert multiple rows in mysql using php form

How to insert multiple rows in mysql using php form:

add

<?php
session_start();
$con=mysql_connect(“localhost”,”root”,””) or die(“mysql is not connected”);
$database=mysql_select_db(“myproject”,$con) or die(“database is not connected”);
$artistname=$_POST[‘artistname’];
$address=$_POST[‘address’];
$email=$_POST[’email’];
$phone=$_POST[‘phone’];
$description=$_POST[‘description’];
if(isset($_POST[‘submit’]))
{
/**if(($_FILES[“image_name”][“type”] == “image/gif”) || ($_FILES[“image_name”][“type”] == “image/jpeg”))*/

$image_name=time().$_FILES[“image_name”][“name”];
move_uploaded_file($_FILES[“image_name”][“tmp_name”],”img/”.$image_name);
$query=”insert into artists(artistname,address,email,phone,image_name,description) values(‘$artistname’,’$address’,’$email’,’$phone’,’$image_name’,’$description’)”;
$result=mysql_query($query);
if($result)
{
header(“Location:home.php”);
}
else
{
header(“Location:addform.php”);
}
}

?>
<html>
<head>
<title>add form</title>
</head>

<body bgcolor=”#FFFFCC”>

<div style=”background-color:#006699; height:150px; width:100%; float:left; border:1px #000000 solid;”></div>
<div style=”float:left; height:600px; width:100%”>
<div style=”float:left; height:600px; background-color:#00CCFF; width:24%; border:1px #000000 solid;”></div>
<div style=”background-color:#CCCCCC; height:600px; float:right; width:75%; border:1px #000000 solid;”>
<form action=”” method=”post” enctype=”multipart/form-data” name=”frm”>
<table align=”center” width=”400″ border=”1″>
<tr><td>Artist Name:</td><td><input type=”text” name=”artistname” /></td></tr>
<tr><td>Address:</td><td><input type=”text” name=”address” /></td></tr>
<tr><td>Email:</td><td><input type=”text” name=”email” /></td></tr>
<tr><td>Phone:</td><td><input type=”text” name=”phone” /></td></tr>
<tr><td>Image:</td><td><input type=”file” name=”image_name” /></td></tr>
<tr><td>Description:</td><td><input type=”text” name=”description” /></td></tr>
<tr><td></td><td><input type=”submit” name=”submit” value=”add new” /></td></tr>
</table>

</form>

</div>
</div>
<div style=”background-color:#006699; height:150px; width:100%; float:left; border:1px #000000 solid;”></div>
</body>
</html>

Please follow and like us:
0

Add a Comment

Your email address will not be published. Required fields are marked *