Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more

Go Back   Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more > Web Programming > PHP Development
User Name
Password

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 06-13-2007, 12:42 PM   #1 (permalink)
eni9889
Junior Member
 
Join Date: Jun 2007
Posts: 1
Default I need a a form

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.
eni9889 is offline   Reply With Quote
Sponsored Links
Old 06-28-2007, 10:04 AM   #2 (permalink)
AdIncent.com
Junior Member
 
Join Date: Jun 2007
Posts: 7
Default Re: I need a a form

For your form you should make fields like this :
<input type="text" name="firstname[]" size="20" />
So when the form is sent, you can use the variable like that :
$_POST['firstname'][0]
Each time you add a field, the number is incremented like :
<input type="text" name="firstname[]" size="20" />
<input type="text" name="firstname[]" size="20" />
=> In php :
$_POST['firstname'][0] // first field
$_POST['firstname'][1] // second field

Does it help you ?
AdIncent.com is offline   Reply With Quote
Old 07-25-2007, 07:03 PM   #3 (permalink)
TryUsOut
Junior Member
 
TryUsOut's Avatar
 
Join Date: Jul 2007
Posts: 6
Default Re: I need a a form

Hi there!

Visit our site ( Projects Outsourcing Webmasters Freelancers Project Outsource Web Design Development ) and post your project specs. You'll get quality and affordable services from our dedicated pool of freelancers.

Cheers!
__________________
Freelancers looking for projects? Service buyers looking for affordable services? Visit us at http://www.netafreelancer.com
TryUsOut is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Points Per Thread View: 1.00
Points Per Thread: 11.00
Points Per Reply: 5.00



» Sponsors

» Links

» Affiliates
Web Hosting
Online Backup Reviews
Marketing Find
Merchant Select
SiteMap Builder
Host Compare
Dedicated Servers

» Links

» Sports Network
Paintball Forum
Football Forum
Hockey Forum
Golf Forum
Boxing Forum
Lacrosse Forum
Baseball Forum
SnowBoarding Forum
Soccer Forum
MMA Forum


All times are GMT -4. The time now is 10:31 PM.



LinkBacks Enabled by vBSEO 3.0.0 RC8
Webmaster Forums