Solved

PHP forms

Posted on 2006-10-26
4
267 Views
Last Modified: 2006-11-18
Hi,

I'm new here and new to PHP and I really need help with a form. Currently I have an html form on a clients website. The form starts with a check box field, then there's a text field for an email address. What follows is a repetition of a series of three text fields:
OwnerName#1
Model#1
Serial#1

OwnerName#2
Model#2
Serial#2

This repeats through #25...it's a very long form

I currently use FormMail to process the form.

Someone told me that by using PHP it would be possible to insert a field before OwnerName#1 that would ask the user to enter the number of Serial# Researches they are requesting. Then using PHP there would be a loop statement that would allow the next page to display just the appropriate number of fields corresponding to the number they entered. So that if they entered 6 the next page would come up with six sets of the three fields shown above as opposed to all 25. Of course the person who told me how "easy" this is could not tell me how to do it.

I posted this in another forum but didn't get much response. Hope I do better here with the experts. This is a definite 500 pointer.

Thanks in advance for any input.

Fred
0
Comment
Question by:fred_belanger
  • 3
4 Comments
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 17815762
fred_belanger,

Let's say that the field that held this number was named serialNo and used post method in your form.  You could use code like the one below.

for ($i=1; $i<=$_POST['serialNo']; $i++) {
  echo "Owner Name #$i: <input type=\"text\" name=\"ownerName[]\"><br>";
  echo "Model #$i: <input type=\"text\" name=\"model[]\"><br>";
  echo "Serial #$i: <input type=\"text\" name=\"serial[]\"><br>";
}

The name uses square brackets so on the next page PHP will create an array with each value that is entered.  That way all of the values are in one variable, an array.  Let me know if you have any questions or need more information.

b0lsc0tt
0
 

Author Comment

by:fred_belanger
ID: 17816045
Thanks for the response b0lsc0tt.

What would I set as the Action on the form at this point? See what I mean about being new to all this?

Right now it looks like this:
<form action="http://www.CompanyName.com/cgi-CompanyName/formmail.cgi" method="POST" onSubmit="MM_validateForm('email','','RisEmail');return document.MM_returnValue" >
                <input type="hidden" name="redirect" value="http://www.CompanyName.com/research_orderB.htm">
                <input type="hidden" name="recipient" value="sales@tCompanyName.com">      

***For client privacy I replaced their info with CompanyName***

I was told I could still use FormMail to process the form but if another way would work better I'm open to suggestions.

Thanks again.

Fred
0
 
LVL 54

Accepted Solution

by:
b0lsc0tt earned 500 total points
ID: 17816305
Fred,

I would write your own script in php.  PHP has a mail function that will send messages or your web hosting provider may have a PHP component that is even better than that function.  There are examples of using the function on EE and you can certainly get help by posting a question.

One big advantage of using your own script is you would not have to include your email address as a hidden field in the form, which exposes it to misuse.  In your script it would be hidden on the server and just available to the server.

Your action attribute would be the page or pages that you are using.  You could do each of these steps with one page (i.e. big, long script with multiple parts) or have a different page for each part (i.e. page1.php, page2.php, submit.php).  The action is the page where the form is submitted.

Let me know if you have any questions or need more information.
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 17816583
I'm glad that I could help you.  Thank you for the grade, the points and the fun question.  Enjoy learning and using PHP.  It's great!

bol
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
PHP extract HTML using DOMXpath from nested tables 8 48
Calculate values in an array 18 33
PHP Healthcheck 2 85
php email 2 26
This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
This article discusses four methods for overlaying images in a container on a web page
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now