|
Форма <action> PHP
#38718048
Ссылка:
Ссылка на сообщение:
Ссылка с названием темы:
|
|
|
|
Форма отправляет на e-mail. Вот она: http://help-windows.net/form.php и ниже.
Нужно подправить скрипт action_demo.php чтобы пользователь дополнительно переходил по внешней URL ссылке при каждой отправке.
Пришел к выводу что <form action> выполнять 2 действия одновременно не умеет.
авторКод формы
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. 54. 55. 56. 57. 58. 59. 60. 61. 62. 63. 64. 65. 66. 67. 68. 69. 70. 71. 72. 73. 74. 75. 76. 77. 78. 79. 80. 81. 82. 83. 84. 85.
<script>
jQuery(function($){
//Initialisation of the form
$('#container_w2ContactForm').w2ContactForm({
noSpamControl: true, //Specifie if No Spam Control is activate (true / false)
noSpamControlType: 3, //Spcifie the Type of No Spam Control (1 / 2)
resetForm: true, //Spcifie if reset form after submit (true / false)
attachmentFile: true, //Specifie if attachment file is activate (true / false)
maxAttachments: 5, //Specifie the maximum number of attachments files
showBtnSend: false, //Specifie if the btn send is visible when loading form when No Spam Control is activate (true / false)
customFileInput: true, //Specifie if file input is custom skin (true / false)
submitAlertType: "slide", //Specifie the type of alert displaying for submit (dialog / slide)
maxAttAlertType: "slide", //Specifie the type of alert displaying for maximum attachments (dialog / slide)
reCaptchaPublicKey: "null", //Specifie your reCaptcha PublicKey
reCaptchaId: 'recaptcha_id', //Specifie an unqiue ID for HTML element where reCaptcha will be integrated (just specifie the ID do not create the element in the form)
reCaptchaTheme: "clean", //Specifie the reCaptcha theme you want to use
reCaptchaLang: "en", //Specifie the reCaptcha Lang you want to use
reloadCaptcha: true, //Specifie if captcha is reloaded after submit (true / false)
ayah: false //Specifie if AYAH is activate
});
});
</script>
<form class="w2_form cmxform" id="contactForm" method="post" enctype="multipart/form-data" action='w2_acf/action_demo.php'>
<!--IMPORTANT DO NOT REMOVE-->
<div class="timeField"></div>
<input type="hidden" name="recipient" value="1" />
<div class="block_element_form" >
<select id="country" name="version" class="required shadow">
<option value="" selected>Выберите услугу</option>
<option value="nastroyka teamviewer">Удаленная (онлайн) компьютерная помощь</option>
<option value="install Windows">Установка, настройка Windows</option>
<option value="remont sborka">Ремонт, сборка компьютеров</option>
<option value="Zaschita ot virusov">Удаление вирусов, защита от вирусов</option>
<option value="Vosstanovlenie dannih">Восстановление данных</option>
<option value="Ustanovka Wifi">Установка, настройка WiFi оборудования</option>
</select>
</div>
<div class="block_element_form">
<input id="mail" name="mail" class="required shadow" type="email" style="width:160px;" value="E-mail" onfocus="if (this.value == 'E-mail') {this.value = '';}" onblur="if (this.value == '') {this.value = 'E-mail';}"/>
</div>
<div class="block_element_form">
<input id="phone" name="phone" class="required shadow" value="+3" type="text" style="width:35px;"/>
<input id="phone1" name="phone1" class="required shadow" type="text" style="width:60px;" value="Код" onfocus="if (this.value == 'Код') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Код';}"/>
<input id="phone2" name="phone2" class="required shadow" type="text" style="width:134px;" value="Телефон" onfocus="if (this.value == 'Телефон') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Телефон';}"/>
</div>
<div class="block_element_form" >
<select id="country" name="country" class="required shadow">
<option value="" selected>Выберите страну</option>
<option value="ukraine">Украина</option>
<option value="russia">Россия</option>
<option value="byelorussia">Белоруссия</option>
</select>
</div>
<div class="block_element_form">
<input id="adress" name="adress" class="shadow" minlength="2" type="text" value="Адрес проживания" onfocus="if (this.value == 'Адрес проживания') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Адрес проживания';}"/>
</div>
<div class="clear"> </div>
<div class="block_element_form">
<input id="subject" name="subject" class="required shadow" minlength="2" type="text" value="Тема" onfocus="if (this.value == 'Тема') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Тема';}"/>
</div>
<div class="block_element_form">
<textarea id="message" name="message" class="required shadow" minlength="2" style="height:65px;" placeholder="Сообщение"></textarea>
</div>
<div class="clear"> </div>
<!-- begin container for additionnals features (attachment file, no spam control) DO NOT REMOVE -->
<div class="container_features" notification="(.jpg, .jpeg, .png, .gif, .pdf, .doc, .docx) не больше 5-ти файлов" ></div>
<!-- end container for additionnals features -->
<div class="block_element_form">
<button type="submit" class="btn_send shadow" style="display:none;">
Отправить
<span></span>
</button>
<button type="reset" class="btn_send shadow" style="display:none;">
Очистить
<span></span>
</button>
</div>
</form>
авторaction_demo.php
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. 54. 55. 56. 57. 58. 59. 60. 61. 62. 63. 64. 65. 66. 67. 68. 69. 70. 71. 72. 73. 74. 75. 76. 77. 78. 79. 80. 81. 82. 83. 84. 85. 86. 87. 88. 89. 90. 91. 92. 93. 94. 95. 96. 97. 98. 99. 100. 101. 102. 103. 104. 105. 106. 107. 108. 109.
<?php
/***************************
* *
* Treatment *
* for *
* the demo forms *
* *
***************************/
//include the PHP Class w2ContactForm
//for the first use don't forget to specify your own encryption key for no spam control (file: "w2_acf/w2ContactForm.php")
require_once('w2ContactForm.php');
//a form is submited
if(isset($_POST) && !empty($_POST)){
//use the form hidden field form_id to know what form is submitted
$form_id = '';
if(isset($_POST['form_id']))
$form_id = $_POST['form_id'];
//creation of a new instance of Class Contact
$contact = new W2ContactForm();
//Specifies the emails sender. If you don't specifie email sender the email used to send the mail will be the user mail (who submit the form)
$contact->setMailSender('no-reply@mywebsite.net');
//Specifies the emails recipients. You can specifies several emails for multiple recipient. If only one email is specifie the default email will be the first (index 1)
$contact->setMailRecipient(array('1' => 'help.windows.net@gmail.com', '2' => 'help.windows.net@gmail.com'));
//Specifies if you want to use auto responder feature
$contact->setAutoResponder(true);
//Specifies if you want to use an email different that email sender to the auto responder
$contact->setMailResponder('no-reply2@mywebsite.net');
//internationnalization with simple .tmx file (laguages/w2_cf_notifications.tmx)
$contact->setLang('en');
//Use this code only if you need to send email via SMTP
//For SMTP sending - specify your own SMTP HOST (generally "smtp.domaine.com" - use "localhost" for Hosted Dedicated Server)
//Basic example
/*$contact->setSmtpHost('smtp.domaine.com');*/
//Example for gmail config (openSSL must be installed in your server to send mail via gmail smtp)
/*$config = array('ssl' => 'tls',
'port' => 587,
'auth' => 'login',
'username' => 'username@gmail.com',
'password' => 'password');
$contact->setSmtpHost('smtp.gmail.com', $config);*/
//I use a switch to specify the specific rules of PHP validation for each form. If you use several form in your website and you don't want to use a switch you can use several "action.php" file (action1.php, action2.php ... one file per form).
switch($form_id) {
//PHP rules of validation for form "example1-1"
case 'example1-1':
$contact->setMaxAttachmentFiles(5);
$contact->setRequiredFields(array('recipient', 'mail', 'subject', 'message', 'phone', 'datebirth', 'country', 'version', 'website'));
$contact->setBodyMessageFields('<p>E-mail: [mail]</p><p>Version: [version]</p><p>Phone: [phone]</p><p>Date of Birth: [datebirth]</p><p>Country: [country]</p><p>Web site: [website]</p><p>Message: [message]</p>');
break;
//PHP rules of validation for form "example1-2"
case 'example1-2':
$contact->setMaxAttachmentFiles(2);
$contact->setRequiredFields(array('recipient', 'mail', 'subject', 'message'));
break;
//PHP rules of validation for form "example1-3"
case 'example1-3':
$contact->setNoSpamControl(false);
$contact->setMaxAttachmentFiles(5);
break;
//PHP rules of validation for form "example1-4"
case 'example1-4':
$contact->setNoSpamControl(false);
$contact->setMaxAttachmentFiles(0);
break;
case 'example1-5':
//Specifies the max file size for the attachments files (in octet)
$contact->setMaxFileSize(1000000);
//IMPORTANT : Sepcifies the number of attachment file
$contact->setMaxAttachmentFiles(1);
//Specifies the accepted extensions (.jpg, .png, .pdf ...) for the attachments files
$contact->setExtFileOk(array('jpeg', 'jpg', 'png'));
//Specifies if you want to delete files uploaded after email sending
$contact->setDeleteUploadsAfterSending(true);
$contact->setRequiredFields(array('recipient', 'mail', 'subject', 'message'));
$contact->setBodyMessageFields('<p>E-mail: [mail]</p><p>Subject: [subject]</p><p>Message: [message]</p>');
break;
//PHP rules of validation for form "example-recaptcha"
case 'example-recaptcha':
$contact->setMaxAttachmentFiles(2);
$contact->setRequiredFields(array('recipient', 'mail', 'subject', 'message'));
$contact->setNoSpamControl(false);
$contact->setReCaptcha(true);
break;
//PHP rules of validation for form "example-ayah"
case 'example-ayah':
$contact->setMaxAttachmentFiles(5);
$contact->setRequiredFields(array('recipient', 'mail', 'subject', 'message'));
$contact->setNoSpamControl(false);
$contact->setAyah(true);
break;
default:
break;
}
//Sending email
$contact->sendEmail();
}
?>
|
|
|