So my dad just opened up a travel agency and he wants a website with it. I made a form thanks to the help of this forum that looks like this
Code:
<?
$usr = "root";
$pwd = "";
$db = "atlantic";
$host = "localhost";
# connect to database
$cid = mysql_connect($host,$usr,$pwd);
mysql_select_db($db);
if (mysql_error()) { print "Database ERROR: " . mysql_error(); }
?>
<html>
<head>
<title>Insert New Record</title>
</head>
<body bgcolor="#ffffff">
<h2>Insert New Record</h2>
<?
# this is processed when the form is submitted
# back on to this page (POST METHOD)
if ($_SERVER['REQUEST_METHOD'] == "POST")
{
# escape data and set variables
$FIRST_NAME = addslashes($_POST["FIRST_NAME"]);
$LAST_NAME = addslashes($_POST["LAST_NAME"]);
$SOME_FIELD = addslashes($_POST["SOME_FIELD"]);
$NOTES = addslashes($_POST["NOTES"]);
$from = addslashes($_POST["from"]);
$to = addslashes($_POST["to"]);
$ddate = addslashes($_POST["ddate"]);
$rdate = addslashes($_POST["rdate"]);
$name = addslashes($_POST["name"]);
$email = addslashes($_POST["email"]);
$phone = addslashes($_POST["phone"]);
$numadults = addslashes($_POST["numadults"]);
$numchild = addslashes($_POST["numchild"]);
$misc = addslashes($_POST["misc"]);
# setup SQL statement
$sql = " INSERT INTO reservations ";
$sql .= " VALUES ('$from','$to','$ddate','$rdate','$name','$email','$phone','$numadults','$numchild','$misc') ";
#execute SQL statement
$result = mysql_query($sql, $cid);
# check for error
if (mysql_error()) { print "Database ERROR: " . mysql_error(); }
print "<h3><font color=red>New Job Added - View it <a href=show_last_record.php>HERE</a></font></h3>";
}
?>
<form name="fa" action="new_record.php" method="POST">
<table>
<tr><td><b>Departing From </b> </td><td><input type="text" name="from" size=30></td></tr>
<tr><td><b>Destination </b> </td><td><input type="text" name="to" size=30></td></tr>
<tr><td><b>Departure Date </b> </td><td><input type="text" name="ddate" size=20></td></tr>
<tr><td><b>Return Date </b> </td><td><input type="text" name="rdate" size=20></td></tr>
<tr><td><b>Your Name</b> </td><td><input type="text" name="name" size=20></td></tr>
<tr><td><b>Your E-Mail </b> </td><td><input type="text" name="email" size=20></td></tr>
<tr><td><b>Phone </b> </td><td><input type="text" name="phone" size=20></td></tr>
<tr><td bgcolor="#F5F5F5" class="bodytxt" align="right"><b>Passengers: <span class="resRed"></span></b></td>
<td bgcolor="#F5F5F5" class="bodytxt" align="left">Adults: <SELECT name = "numadults" size = "1" onchange="dosum()">
<OPTION value="0">0</OPTION>
<OPTION value="1" selected = "selected">1</OPTION>
<OPTION value="2">2</OPTION>
<OPTION value="3">3</OPTION>
<OPTION value="4">4</OPTION>
<OPTION value="5">5</OPTION>
<OPTION value="6">6</OPTION>
<OPTION value="7">7</OPTION>
</SELECT>Children: <SELECT name="numchild" size="1" onchange="dosum()">
<OPTION value="0" selected = "selected">0</OPTION>
<OPTION value="1">1</OPTION>
<OPTION value="2">2</OPTION>
<OPTION value="3">3</OPTION>
<OPTION value="4">4</OPTION>
<OPTION value="5">5</OPTION>
<OPTION value="6">6</OPTION>
<OPTION value="7">7</OPTION>
</SELECT>
<tr><td valign=top><b>Misc: </b> </td><td> <textarea name="misc" rows=4 cols=30></textarea></td></tr>
<tr><th colspan=2><p><input type="submit" value="Add Record"></p></th></tr>
</table>
</form>
</body>
</html>
now what i need is like a variable form for example if the customer says there are 3 adults then 3 input boxes pop up and the customer can put the 3 names. I don't know if that makes any sense but any help would be greatly appreciated. I was thinking about this and would i have to be putting the names in arrays since i cannot have an infinite number of names in my database or would i have to just make like 30 name colums and hope that no one has 30 ppl in their family lol anyone who helps out thank you i really appreciate it.