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.

Submitting multiple forms with single button

Featured Replies

Hello,

 

I am wanting to submit the values of multiple form inputs to $_SESSION variables by clicking a single button. I will include snippets of my code to help explain my situation.

 

 

// First Form - Warrants the user to input a new email address, and then again to confirm it (Displays current email as placeholder text)

 

<div class="sub2title"><h3>Enter a New Email Address</h3></div>
<form method="post" class="myForms">
<div class="email"><label for="email">New email address <span style="color: #6C1739">* </span><input id="email" type="email" size="35" name="customeremail" placeholder="
<?php
$row = mysql_fetch_array($result2, MYSQL_ASSOC);
echo $row['Email'];
?>
"/></label></div>
<p><div class="email2"><label for="email2">Confirm email address <span style="color: #6C1739">* </span><input id="email2" size="35" type="email" name="customeremail2" placeholder="
<?php echo $row['Email'];
?>
"/></label></div></p>
</form>
// Second Form - Similar to above. Warrants user to input a new username (Displays current username as placeholder text)
<form method="post" class="myForms">
<div class="username"><label for="username">Username <span style="color: #6C1739">* </span><input id="username" type="text" size="27" name="customerusername" placeholder="
<?php
echo $row['Username'];
?>
"/></label></div>
</form>

 

 

// I have a couple other forms but I am sure you get the idea by now

 

// The button I want to submit all forms is part of my reCaptcha form

 

<form class="recaptcha" method="post" action="verify.php">
<?php
require_once('recaptchalib.php');
$publickey = "6LeAde8SAAAAAFmIST1_Q9hFBDIzPt9jkWIAfC65";
echo recaptcha_get_html($publickey);
?>
<p><button type="submit" id="clickMe" value="Submit ALL" class="buttonextra4 big grey">Update</button>
</p>
</form>
I looked into using JS to do this, using this code:
<script>
$('.myForms').submit(function () {
console.log("");
return true;
})
$("#clickMe").click(function () {
$(".myForms").trigger('submit'); // should show 3 alerts (one for each form submission)
});
</script>
I had no luck with this method though. Any help would be greatly appreciated. Either advice on how to get the current JS method to work or a better method.
// My Goal?
I want the values for all the form inputs to be submitted to $_SESSION variables so that during verify.php I can use these variables to run a mySQL Update query.
- MjA -

 

  • Author

Is there any way around this then? I know it would be a lot easier to use a single form but would that work including the ReCaptcha? I'd rather know if I was working towards an achievable goal at least.

 

- MjA -

  • Author

Thank you. At least now I know what to be working towards.

 

- MjA -

  • 1 month later...
  • Author

Commenting as I need to get my post count up to 25 so I can send a PM, and I am 2 post counts short.

 

- MjA -

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.