Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Getting form into mysql database
Old 12-09-2005, 04:18 AM Getting form into mysql database
Junior Talker

Posts: 3
Trades: 0
How do I keep this form looping and send to mysql database.

<html>
<head>
<title>Guest list pages!</title>
</head>
<body>
<?
if (!isset($_GET['Number_of_family_members'])) {
// this checks if the form has been posted. if it hasnt it dsiplays the html below.
?>
<p>
First enter number of family members staying at address<br>
and press enter.On the next page enter family details<br>
press enter next family. Repeat process untill your guest
list is complete.
</p>
<form name="emailform" method="GET">
<SELECT NAME="Number_of_family_members" SIZE="1">
<OPTION SELECTED>1
<OPTION>2
<OPTION>3
<OPTION>4
<OPTION>5
<OPTION>6
<OPTION>7
<OPTION>8
<OPTION>9
<OPTION>10
<OPTION>11
<OPTION>12
</SELECT>
<INPUT TYPE="submit" value="Enter family details">
</form>
<?
}else { // if the form has been posted display this...
?>
<form action="number of members.php" method="GET">
<?
for ($i = 1; $i <= $_GET['Number_of_family_members']; $i++) {

//this loops thru Number_of_family_members
?>

<dl>

<dt>Family Member:</dt>
<dd><input type="text" name="family member<?echo $i;?>"></dd>


</dl>
<?};?>
<dt>Förnamn:</dt>
<dd><input type="text" name="förnamn"></dd>
<dt>Efternamn:</dt>
<dd><input type="text" name="efternamn"></dd>

<dt>Address:</dt>
<dd><input type="text" name="address"></dd>

<dt>Postnummer:</dt>
<dd><input type="text" name="postnummer"></dd>
<INPUT TYPE="submit" value="Enter next family">
<INPUT TYPE="reset" value="Reset Form">
</form>
<? }; ?>
</body>
</html>
Thanks for any help
lardy is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-09-2005, 08:19 AM
Skilled Talker

Posts: 70
Trades: 0
what you need to do is connect to the database and make an insert statement.
cerebro89 is offline
Reply With Quote
View Public Profile
 
Old 12-09-2005, 09:00 AM
Junior Talker

Posts: 3
Trades: 0
Ive done that before using a insert.php, but I dont see how that will work haere as I need it to loop back.
lardy is offline
Reply With Quote
View Public Profile
 
Old 12-13-2005, 07:59 AM
Ultra Talker

Posts: 264
Location: UK
Trades: 3
Ok, once you select the number of family members, you need to allow the script to post the final results. The loop back remains is still in place but the final results can be sent to a database.


You need to change this:

Quote:
<form action="number of members.php" method="GET">
to:

Quote:
<form action="addmembers.php" method="post">
Then create an page entitled addmembers.php and add a connect to database command and then an insert command.

If you need further help let me know.


Nick
uktvindex is offline
Reply With Quote
View Public Profile
 
Old 12-13-2005, 02:24 PM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
How is the form supposed to behave? Do you want people to be able to fill out an unlimited number of forms, and have the server remember and store the results for all of them? I would advise using sessions for this - you need to call session_start() at the top of all the pages that need to manipulate form data. Then you can assign things to elements of the special $_SESSION array, and these are carried over to the next page. You can even store multi dimensional arrays, so you might end up setting
$_SESSION['page'][1] = $_POST
on page one, which copies the entire form submission into the active session. Then on page two you can say
$_SESSION['page'][2] = $_POST
etc until all the forms are filled. Then when finished, your database insert code can look at the $_SESSION array which has all the data from as many pages as you want all in one place.

Sound like it might solve your problem? Let us know if you want more help on it.
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Reply     « Reply to Getting form into mysql database
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.19862 seconds with 12 queries