Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 290
  • Last Modified:

PHP forms

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
fred_belanger
Asked:
fred_belanger
  • 3
1 Solution
 
b0lsc0ttIT ManagerCommented:
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
 
fred_belangerAuthor Commented:
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
 
b0lsc0ttIT ManagerCommented:
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
 
b0lsc0ttIT ManagerCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now