iNoize Posted June 11, 2019 Share Posted June 11, 2019 Hello, i use 3 different forms on site now i will check from which form the data comes and send the vars. e.g. I have a callback form, a contact form and an info form. Now i use one page Tnak you for your mail and how to choose the right script ? The forms have different number of values and i dont want to create 3 different Thank you pages. <?php $empfang = "my@email.here"; if(isset($input->post->submit)) { $aname = $sanitizer->text($input->post->aktion_name); $fname = $sanitizer->text($input->post->fullname); $subject = $sanitizer->text($input->post->subject); $femail = $sanitizer->text($input->post->email); $phone = $sanitizer->text($input->post->phone); $message = $sanitizer->text($input->post->message); $mail = wireMail(); $mail->to($empfang)->from($femail); $mail->subject('Anfrage von '.$aname); $mail->body('Mail Body'); $mail->bodyHTML('<html><body><h1>von '.$fname.'</h1><br> Betreff: '.$subject.'<br> Mail'.$femail.'<br> Telefon'.$phone.'<br>Nachricht:'.$message.'</body></html>'); $mail->send(); } Link to comment Share on other sites More sharing options...
horst Posted June 11, 2019 Share Posted June 11, 2019 Why do you not include type hidden fields into your forms where you add identifiers? $validFormIdentifier = ['aaaaaaaa', 'bbbbbbb', 'ccccccc']; $myIdentifiedForm = $sanitizer->text($input->post->hiddenidentifier); if(!in_array($myIdentifiedForm, $validFormIdentifier)) { // invalid formsubmission, do not process further } 2 Link to comment Share on other sites More sharing options...
iNoize Posted June 13, 2019 Author Share Posted June 13, 2019 On 6/11/2019 at 1:40 PM, horst said: Why do you not include type hidden fields into your forms where you add identifiers? $validFormIdentifier = ['aaaaaaaa', 'bbbbbbb', 'ccccccc']; $myIdentifiedForm = $sanitizer->text($input->post->hiddenidentifier); if(!in_array($myIdentifiedForm, $validFormIdentifier)) { // invalid formsubmission, do not process further } Thanks for the advice but i need to know wchich form of my 3 forms is sending currently because form 1 has 5 values form 2 has 8 values and form 3 20 values to send. So i want to select what to send it depends on the values Link to comment Share on other sites More sharing options...
rick Posted June 13, 2019 Share Posted June 13, 2019 You have three forms on one page, so provide a hidden element with a unique name (as @horst suggests), then test for the form name when submitted and process accordingly. The page with your forms... <form> <input type="hidden" name="form1" value="form1" /> ... // Your form data collection fields </form> ... <form> <input type="hidden" name="form2" value="form2" /> ... // Your form data collection fields </form> ... <form> <input type="hidden" name="form3" value="form3" /> ... // Your form data collection fields </form> Then within your page, test for each... <?php if( $input->post->form1 == "form1" ) { // process your data and send your message for option 1 } elseif ( $input->post->form2 == "form2" ) { // process your data and send your message for option 2 } elseif ( $input->post->form3 == "form3" ) { // process your data and send your message for option 3 } // render your page as normal 3 Link to comment Share on other sites More sharing options...
iNoize Posted June 15, 2019 Author Share Posted June 15, 2019 Thank you very much ? so simple ?♂️ Link to comment Share on other sites More sharing options...
Brandon10 Posted June 15, 2019 Share Posted June 15, 2019 Ya so simple it is....Thank you so much.Will definitely try it once dqfansurvey Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now