Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

PHP forms

Posted on 2006-10-26
4
Medium Priority
?
283 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

610 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