September 21, 201214 yr Good afternoon all, a little problem for anyone who can be bothered on a friday afternoon. I am currently in the process of building my companies new website. Going well. a much bigger step up from their old website www.arporter.co.uk on the website i have several contact forms, The contact page itself, feedback form and pinned to the side of every page a request a quote form. my issue is, and i cannot see, for the life of me, why... when the forms, contact page, or feed back are filled in and submitted it also submits the form for request a quote. I am not seeing anything duplicated. obviously there is quite alot of code, so if anyone has any suggestions that would be great other than that i will post the code if requested. Thanks in advance
September 21, 201214 yr On your home page the form in the Request quote has action="/index.php" but on the Contact page the same form has action="/contact.php" which seems more correct as the index.php is presumably your home page, unless the index.php code has PHP processing code for the form which we can't see from View Source but you can check the full code for that page. On the Contact page the form higher up for contact also has action="/contact.php" which is the same. Look at contact.php to see what the mail function says. Edited September 21, 201214 yr by Wickham
September 21, 201214 yr OK, but the Contact page has two forms with the same action, so that must be why submitting one form sends both.
September 21, 201214 yr The value=".." for the buttons isn't relevant, but the action is. You need separate files with a .php extension for the two forms on the same page if you want just one different email to be sent from each form. You can send two different emails from the same contact.php but I don't think that's what you want.
September 21, 201214 yr Author I didnt state anything about the values of the buttons, i said the names. where the variables are called. if im say, once the form has been submitted by clicking test_submit why would the form that button is called submit, submit itself it makes no sense, there is no relation. and ive got websites that have 3/4 forms on the same page and i dont have this issue
September 21, 201214 yr Dont mind me butting in with my limited php knowledge, but couldn't you just simplify with one form using radio buttons to select functions? so you click the one radio button it sends the one form, you click the other it send the other lol. I appologise if I got the wrong end of the stick (it is friday afternoon). Simple if and else functions surely?
September 21, 201214 yr Author its a good idea. however, the forms already have validation. so if i submit the feedback form it submits successfully, and the other form states that the fields havnt been filled in. its not an important issue. but it would be nice to get it right.
September 21, 201214 yr At the moment, on the Contact page, you have two forms with action="/contact.php" so whichever form submit button is used the same processing will be used. It will take whatever inputs are filled in, whichever form is used (so it might happen that the form used has inputs that fit the processing or might not). If you want each form to be processed separately and send a different email set a diffferent action to another php file with different processing.
September 21, 201214 yr I don't think its a problem to validate two forms on one page. The only thing you should do is checking wich form is submitted by checking the value of the submit button. ( It returns one when that submit button is clicked ) if( addslashes( $_POST['submit_button_name'] ) ) { // Perform form validation. } else if ( addslashes($_POST['second_submit_button_name'] ) ) { // Perform validation for form two. } Edited September 21, 201214 yr by Leonvv
September 25, 201214 yr Author ok, this is all very helpful stuff, However, only duplicate forms are submitted if i click the submit button on the static form, if i click it on the quote form, it only sends the quote form...
September 26, 201214 yr Author I don't think its a problem to validate two forms on one page. The only thing you should do is checking wich form is submitted by checking the value of the submit button. ( It returns one when that submit button is clicked ) if( addslashes( $_POST['submit_button_name'] ) ) { // Perform form validation. } else if ( addslashes($_POST['second_submit_button_name'] ) ) { // Perform validation for form two. } I tried this method, but im still having the same issue. its very strange
September 26, 201214 yr I tried this method, but im still having the same issue. its very strange Posting your PHP code would help to solve your problem. Léon
Create an account or sign in to comment