Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > Скриптовые языки программирования > PHP
Регистрация

Восстановить пароль
Повторная активизация e-mail

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 12.08.2014, 12:38   #1
papacoca
 
Аватар для papacoca
 
Регистрация: 06.01.2013
Сообщений: 7
По умолчанию Форма <action> PHP

Форма отправляет на e-mail. Вот она: http://help-windows.net/form.php и ниже.
Нужно подправить скрипт action_demo.php чтобы пользователь дополнительно переходил по внешней URL ссылке при каждой отправке.
Пришел к выводу что <form action> выполнять 2 действия одновременно не умеет.

Цитата:
action_demo.php
PHP код:
<?php

//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();

}
?>
http://zapravka-nadom.com.ua - Заправка картриджей лазерных принтеров
papacoca вне форума Ответить с цитированием
Старый 12.08.2014, 13:57   #2
pompiduskus
юзер как все
Участник клуба
 
Аватар для pompiduskus
 
Регистрация: 10.01.2012
Сообщений: 1,586
По умолчанию

Код:
header("Location: http://www.google.com/");
<Дзен - Вся вселенная в тебе > | Резюме: https://ch3ll0v3k.github.io/CV/
pompiduskus вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц



Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Форма авторизации на PHP samuray444 Помощь студентам 1 22.04.2013 09:59
Php форма обратной связи OgStyle Помощь студентам 4 03.01.2011 17:13
Форма в PHP Slam1989 PHP 1 19.12.2010 12:57
помощь по PHP(форма и обработка) Eugene811 PHP 7 11.05.2009 04:17