Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Contact form issue

Featured Replies

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

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 by Wickham

OK, but the Contact page has two forms with the same action, so that must be why submitting one form sends both.

  • Author

but the buttons have different names submit and test_submit

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.

  • 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

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?

  • 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.

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.

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 by Leonvv

  • 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...

  • 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

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.