March 3, 201412 yr 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 -
March 3, 201412 yr I would be careful relying on js for anything serious when it comes to validation or updating. It's great for initial checks but a chocolate fireguard for updating data.
March 4, 201412 yr 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 -
April 4, 201412 yr 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