PHP forms

Davey

New Member
I'm using PHP to process HTML forms in to a MySQL database. What I want to do is have an "add another" feature on a form. For example, a form that takes details from someone attending a conference. They fill in their details (fine so far) then they need to add a friend from the same company. So they hit the "add another button" and refill in the name fields. Basically each additional name is added as a new record in a second table (first table being for the rest of the form) so it's like a form within a form, each time the Add Another Button is hit it posts the data from the name field and display the field again but empty, so the same field is used over and over.

I've seen it done in ASP but don't know how to make it work with PHP. Anyone know or have a working example?
 

dqhendricks

New Member
It would all be in one form. You would add new fields to the same form using javascript, and name the fields in sequence like (first_name_1, first_name_2, etc). then PHP side, you would count upwards in a loop until there is no first_name field set with the current index.

Code:
$i = 1;
while (isset($_POST['first_name_'.$i])) {
    // process
    
    $i ++;
}

- dqhendricks
http://www.spotlesswebdesign.com/
 

projectfizz

New Member
You would also need a JavaScript function to add new elements incrementing a hidden variable as the counter.

The database structure would most likely use a new table for 'friends' or something similar so you can have multiple rows rather than using the same table and adding additional columns.
 

jacky001

New Member
This tutorial has emphasis on processing PHP forms with security in mind! There are too many tutorials out there that rely on PHP's notorious register_globals setting activated with very little or no form input validating. Proper validation of form input data is the most important step in protecting your form from hackers and spammers!
One of the more common questions is how to submit a form to send information in an e-mail. Using PHP, it's really very easy. Here we'll learn about processing forms to send e-mail using PHP. The tutorial assumes only a very basic knowledge of PHP, but even that's not required. We'll start simple and build on the knowledge we gain to implement a full featured form to e-mail handler. The only thing really necessary is that you be fairly comfortable working in Code View.
 

jonmark

New Member
This tutorial has emphasis on processing PHP forms with security in mind! There are too many tutorials out there that rely on PHP's notorious register_globals setting activated with very little or no form input validating. Proper validation of form input data is the most important step in protecting your form from hackers and spammers!phpFormGenerator is a an easy, online tool for creating reliable, efficient, and aesthetically pleasing web forms in a snap. No programming of any sort is required: phpFormGenerator generates the HTML code, the form processor code (PHP), and the field validation code automatically via an easy, point-and-click interface.
 

jonnymark

New Member
PHP (Hypertext Preprocessor) is one of the most popular means of processing HTML forms. Originally it was created by Rasmus Lerdorf in 1995 and stood for Personal Home Page. It began in 1994 as a set of Common Gateway Interface binaries written in the C programming language. The Danish/Greenlandic programmer Rasmus Lerdorf created these Personal Home Page Tools to replace a small set of Perl scripts used to maintain his personal homepage. The tools served for displaying his resume and recording how much traffic his page was receiving.
PHP is a scripting language. It was designed for producing dynamic web pages. Now it can include a command line interface capability and can be used in standalone graphical applications. It is similar to other server-side scripts that provide dynamic content from a web server to a client, such as Microsoft's Active Server Pages, Sun Microsystems' JavaServer Pages, and mod_perl. PHP executes hundreds of base functions and thousands more via extensions.
 

HungryCoader

New Member
Hi,
I also face same problem one week ago...Kyle Gush (PHP programmer) send me same instruction what jeneliya do........
Successful programmer Kyle Gush background can be checked in NY
 

alvin80

New Member
If you want to improve your web page, then you basically need to learn php since it plays important role in HTML document. Educate yourself and learn with ease in many tutorials online.
 
Last edited:
Top