Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

form preview before submitt

Status
Not open for further replies.

rtikeith

Technical User
Sep 16, 2002
24
US
I want to create a form on page(pg1) and pass the information from the form to a second page(pg2) where the user can either submit or reject the displayed information. On the submit on the second page(pg2) I want it to email me and the user the information.
(on the second page and in the emails I only want to display the fields that were filled out)

----
Where "Phone" is not filled out
----
name: John Smith
email: john.smith@anywhere.somthing
----

Where "Phone" is filled out
----
name: John Smith
email: john.smith@anywhere.somthing
phone: ###-###-####
----

----
<form method=&quot;post&quot; action=&quot;action&quot; >
Name <input type=&quot;text&quot; name=&quot;name&quot; value size=&quot;35&quot;><br>
Email <input type=&quot;text&quot; name=&quot;email&quot; value size=&quot;35&quot;><br>
Phone <input type=&quot;text&quot; name=&quot;phone&quot; value size=&quot;35&quot;>(optional)<br>
<input type=&quot;submit&quot; value=&quot;Submit Form&quot;><input type=&quot;Reset&quot; value=&quot;Reset Form&quot;>
</form>
----

There will obviously be more optional fields than just the one or it would be pointless to not to just display one blank field.

Thanks for your help.
 
There are different ways to approach this, I would post to another page that just puts the info into vars and displays the output. There would be two buttons except or reject, if the user rejects then go back to page1, if they except go to page3 and process the information

To err is human, to completely mess up takes a computer. [morning]
 
Sorry, I wasn't clear. I need to know the code to make this work.
 
rtikeith:
Tek-Tips is not a free code-writing service.


I would use a single PHP script, the backbone of which is a set of nested if-then-else blocks.

Each part of the block outputs the appropriate HTML forms and decides which block of code to run by analyzing input.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
sleipnir214:

I did not want you to write the code I just wanted to know what functions I was going to need to use to get the information to the second page or a webpage that would tell me how to get it done.

I thought I would have to write it to a database or something.

Someone else told me how that worked and I wrote the script.
 
rtikeith:
Okay.

I recommend you get very familiar with the PHP online manual. The main site is and there are mirrors everywhere.

To send mail, check out the mail() function:
The rest of it's just conditional blocks and print statement.


You haven't mentioned databases until know. It's difficult to advise you as to which PHP functions to use, because PHP has family of functs to communicate natively with MySQL, PostgreSQL, Oracle, MS SQL Server, Sybase, and others. It can also use ODBC. What database were you talking about?


Want the best answers? Ask the best questions: TANSTAAFL!!
 
Like I said in the previous post, I wrote the code.

----
Sample:

if ( empty ( $address ) )
print &quot;$empty&quot;;
else
print &quot;$address<br>&quot;;
----
No database needed.

All I did was to call the script from the action= in the html form tag. Then I format it the way I want it on the second page.

Thanks anyway
 
if ( empty ( $address ) ){
print &quot;$empty&quot;;
}else{
print &quot;$address<br>&quot;;
}

To err is human, to completely mess up takes a computer. [morning]
 
Is there a limit to the number of variables that I can submit to a php script from a html type form?

The reason I ask is that I got the code to work but if I add all of my fields, the submit button fails to work. (The form actually spans more than one table if that makes a difference.) I am checking the code from the form that I copied into the new page, but I wanted to check this while I did the checking.

Thanks
 
The two code snippets are functionally identical
So they are I had forgotten, sorry used to writing in C.
I am not aware of a limit to the number of variables, the form tag CAN span multiple tables. what is happening when u submit?

To err is human, to completely mess up takes a computer. [morning]
 
csniffer:
I hate to tell you this, but they would have been functionally identical in C, too. C does not require the curly-braces for single lines of code in if-else constructs, either.



rtikeith:
Not only how much data are you sending, but how are you sending it? GET-method (variables in the URL) has limits as to how much you can send, for example.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
There was an error in my form. One of the variables began with an number. When I changed it, it worked fine.

Thanks for the posts.

I'm done.
 

csniffer:
I hate to tell you this, but they would have been functionally identical in C, too. C does not require the curly-braces for single lines of code in if-else constructs, either


hmm.
well you learn something new everyday. i have always used them and will probably continue 2. but again I find myself humble to ur knowledge and again thank in you for the improvement of mine
thx


To err is human, to completely mess up takes a computer. [morning]
 
sorry for ignoring your post rtikeith please Supply a bit of the code ie state how code was changed etc

To err is human, to completely mess up takes a computer. [morning]
 
I'll admit I aways use them, too. I do it as a purposely-ingrained habit.

If they're already there I don't have to worry about adding them should I need to make my code do more than one thing in an else-block. Also, it keeps my indentation scheme more regular.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top