Add multiple placeholder and file upload to form

7 replies · opened May 3, 2016

PpesterevilyaMay 3, 2016

Hi! I added to my contact form multiple placeholder and file upload, but i don't know how to setup sendemail.php for form working correctly.

My website — http://geo.ipesterev.ru

Code of my contact form:


	
	Куда оптравить наше предложение?
	
		Имя *
		
		
	

	
		Телефон *
		
		
	

	
		E-mail *
		
		
	

	

	
		Какие материалы вы используете?
		
			Геомембрана
			Бентомат
			Биомат
			Георешетка
			Геотекстиль
			Дренажный мат
			Теплонит
			Анкеры
		
	

	
	Прикрепите документы по текущему проекту (если имеются)
	

		
	

	
		
	

	
		Отправить
	

Code of my sendemail.php:

 'info@zenlabs.ru', // Your Email Address
				'name' => 'Your Name' // Your Name
			);

// Form Processing Messages
$message_success = 'We have **successfully** received your Message and will get Back to you as soon as possible.';

// Add this only if you use reCaptcha with your Contact Forms
$recaptcha_secret = 'your-recaptcha-secret-key'; // Your reCaptcha Secret

$mail = new PHPMailer();

// If you intend you use SMTP, add your SMTP Code after this Line

if( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
	if( $_POST['template-contactform-email'] != '' ) {

	
		$name = isset( $_POST['template-contactform-name'] ) ? $_POST['template-contactform-name'] : '';
		$email = isset( $_POST['template-contactform-email'] ) ? $_POST['template-contactform-email'] : '';
		$phone = isset( $_POST['template-contactform-phone'] ) ? $_POST['template-contactform-phone'] : '';
		$service = isset( $_POST['template-contactform-service'] ) ? $_POST['template-contactform-service'] : '';

		$botcheck = $_POST['template-contactform-botcheck'];

		if( $botcheck == '' ) {

			$mail->SetFrom( $email , $name );
			$mail->AddReplyTo( $email , $name );
			foreach( $toemails as $toemail ) {
				$mail->AddAddress( $toemail['email'] , $toemail['name'] );
			}
			$mail->Subject = "Заявка с сайта geo174.ru";

			$name = isset($name) ? "Имя: $name

" : '';
			$email = isset($email) ? "E-mail: $email

" : '';
			$phone = isset($phone) ? "Телефон: $phone

" : '';
			$service = isset($service) ? "Материалы: $service

" : '';

			$referrer = $_SERVER['HTTP_REFERER'] ? '

This Form was submitted from: ' . $_SERVER['HTTP_REFERER'] : '';

			$body = "$name $email $phone $service $message $referrer";

			// Runs only when File Field is present in the Contact Form
			if ( isset( $_FILES['template-contactform-file'] ) && $_FILES['template-contactform-file']['error'] == UPLOAD_ERR_OK ) {
				$mail->IsHTML(true);
				$mail->AddAttachment( $_FILES['template-contactform-file']['tmp_name'], $_FILES['template-contactform-file']['name'] );
			}

			// Runs only when reCaptcha is present in the Contact Form
			if( isset( $_POST['g-recaptcha-response'] ) ) {
				$recaptcha_response = $_POST['g-recaptcha-response'];
				$response = file_get_contents( "https://www.google.com/recaptcha/api/siteverify?secret=" . $recaptcha_secret . "&response=" . $recaptcha_response );

				$g_response = json_decode( $response );

				if ( $g_response->success !== true ) {
					echo '{ "alert": "error", "message": "Captcha not Validated! Please Try Again." }';
					die;
				}
			}

			$mail->MsgHTML( $body );
			$sendEmail = $mail->Send();

			if( $sendEmail == true ):
				echo '{ "alert": "success", "message": "' . $message_success . '" }';
			else:
				echo '{ "alert": "error", "message": "Email **could not** be sent due to some Unexpected Error. Please Try Again later.

**Reason:**
' . $mail->ErrorInfo . '" }';
			endif;
		} else {
			echo '{ "alert": "error", "message": "Bot **Detected**.! Clean yourself Botster.!" }';
		}
	} else {
		echo '{ "alert": "error", "message": "Please **Fill up** all the Fields and Try Again." }';
	}
} else {
	echo '{ "alert": "error", "message": "An **unexpected error** occured. Please Try Again later." }';
}

?>
PpesterevilyaMay 3, 2016

I attach files sendemail.php and index.html

PpesterevilyaMay 3, 2016

Can anybody help me?

SSemicolon WebSTAFFMay 4, 2016

Hello,

We have just checked out your Website and the Codes seem to be correctly configured. We have also tried testing your Contact Form by submitting an input and the Responses are going through fine and giving us a Successful Response. Is there any specific issue you are facing with the Form so that we can help you further with this?

Thanks for your Patience. Meanwhile, do let us know if we can help you with anything else or if you find any further issues with Canvas.

PpesterevilyaMay 4, 2016

In a letter in the mail do not come attached files, and does not display information from multiple select. Perhaps need to configure the file sendemail.php, but i don't know how do it.

SSemicolon WebSTAFFMay 5, 2016

Hello,

We have checked out your Form and since you are using Custom Fields in your Forms using Multiple Value, the Form Emails are not getting the Values properly. This is Definitely Possible but will require some PHP customization. We will definitely provide you with the Customized code within 6-8 Hours so that your Form sends you the proper information. Thanks for your Patience.

Meanwhile, do let us know if we can help you with anything else or if you find any further issues with Canvas.

PpesterevilyaMay 6, 2016

Hello! you write code today?

SSemicolon WebSTAFFMay 6, 2016

Hello,

Thank You so much for your Patience.

  1. Please use the following HTML Code for your Form:

	

	

		

		Куда оптравить наше предложение?
		
			Имя *
			
			
		

		
			Телефон *
			
			
		

		
			E-mail *
			
			
		

		

		
			Какие материалы вы используете?
			
				Геомембрана
				Бентомат
				Биомат
				Георешетка
				Геотекстиль
				Дренажный мат
				Теплонит
				Анкеры
			
		

		
		Прикрепите документы по текущему проекту (если имеются)
		

			
		

		
			
		

		
			Отправить
		

	
  1. Now Download and add this File: https://www.dropbox.com/s/kobowpandg2oda8/sendemail-multi.php?dl=1 to your HTML/include Folder.

You can simply open the include/sendemail-multi.php File and add your Email Address in the Appropriate Places.

This will definitely work fine. Let us know if we can help you with anything else or if you find any further issues.

Have the same question, or something new?

Sign in to the Canvas dashboard to reply or open your own topic. Canvas owners get direct help from the SemiColonWeb team.

Reply on the dashboard