iheartlinus Posted July 20, 2009 Share Posted July 20, 2009 So I have created an HTML form that uses PHP to calculate the price of something. The user fills out the form and hits “Price” and it shows (on the same page) the price. When that page displays I want to add a button to the price that says something to the effect of “Get Started” When the user hit’s the “Get Started” button they will enter their contact information, and I would like the information they entered on the first form, along with the contact information to be captured and emailed to me. I realize it would probably be easier if I just made them put their email address in the first form, but I hate having to give my information out just to find out pricing info, and I don’t want to make potential clients do that. So basically I want the process to work like this: They fill out the “pricing calculator” They Hit Submit and it shows them the Price (This is as far as I have gotten) and a Button that says “Get Started” They Hit “Get Started” and it shows a form that captures their contact information They Hit “Submit” and the contact information AS WELL AS the data they entered into the pricing calculator are emailed to me. Anyone who can help would be a real life saver! Here is my PHP so far: <?php $submit = $_GET['submit']; if($submit == "true") { $total = ($_POST['one'] + $_POST['two'] + $_POST['three'] + $_POST['four'] + $_POST['five'] + $_POST['six'] + $_POST['seven'] + $_POST['eight']+ $_POST['nine'] + $_POST['ten']+ $_POST['eleven'] + $_POST['twelve']+ $_POST['thirteen']); echo " Your Price is \$" .number_format ($total, 2, '.', ','); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/166700-multiple-html-forms-and-conditional-php-statements/ Share on other sites More sharing options...
sKunKbad Posted July 20, 2009 Share Posted July 20, 2009 It seems that you must be using Ajaxian type code to get the price, so you should at the same time create a form button when the price is displayed. Alternatively, you could change the name and value of the existing submit button, so that it functions as a multipurpose button. When this information is posted to the second page, where you will collect the user's email address, you will simply populate some hidden form fields with the data that came from the first page (price) When all of this info is submitted, you will show a thank you message and use php's mail function, or another mail class/script to send the email to yourself. I can't write code for you, but this is the strategy that I would use, and it's actually something that you will use often. Quote Link to comment https://forums.phpfreaks.com/topic/166700-multiple-html-forms-and-conditional-php-statements/#findComment-879071 Share on other sites More sharing options...
JJ2K Posted July 21, 2009 Share Posted July 21, 2009 You could do something like this: The top part is effectivley the last part of the process and the last part is the first part if($_POST['contact']){ //Then retrieve + sanitize contact details and mail them here } elseif($_POST['started']){ //Then the user wants to get started enter there contact information here, so display contact form and dont forget to send the other info through aswell through hidden fields again } elseif($_POST){ //Then calculate the total here, and send it in hidden fields along with the get started button } else{ //Nothing has been done so display the first form here } Quote Link to comment https://forums.phpfreaks.com/topic/166700-multiple-html-forms-and-conditional-php-statements/#findComment-879114 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.