PHP Adding new records

Associate
Joined
8 Jan 2013
Posts
220
Hi im basically making a simple site/database to manage our backups at work.

I need to be able to add a months worth of backups (20 or so tapes) into the same 'submit' so they all add at the same time.

I have 3 forms

Month, tape and location.
The month and location will stay the same for the months backups but the tape number will change.
How do i easily have the option to add multiple numbers into a form but keep the month/location the same (I hope im explaining it correct)
This is my first attempt at something like this :)

My Forms
Code:
<form action="insert.php" method="post">
<p style="text-align: center;">Month: <input type="text" name="Month" /></p>
<p style="text-align: center;">Tape: <input type="text" name="Tape" /></p>
<p style="text-align: center;">Location: <input type="text" name="Location" /></p>
<p style="text-align: center;"><input type="submit" value="Submit Query" /></p>

</form>

Insert.php
Code:
<?php
$con = mysql_connect("localhost","    ","    ");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("backups", $con);

$sql="INSERT INTO `2007` (Month, Tape, Location)
VALUES
('$_POST[Month]','$_POST[Tape]','$_POST[Location]')";

if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "Record added";


mysql_close($con);
?>

Any helpful pointers would be great! :D
 
oops sorry didn't want to start an argument :p

I'm definitely a newcomer, prepared to learn and jump into it

This is to be used by myself and maybe another Engineer internally. There should be no funny data input by myself so validations etc are not totally needed right now but would be helpful going forward. Security isn't going to be a problem in our environment
I'm using this data to also test out my Query's i have to display the data which is the more important part

All of this is very helpful didn't expect the code to be written out for me, so many thanks for that :) Has given me a lot more to look at and modify my existing basic code
 
Last edited:
Back
Top Bottom