Job Form - Email sends successfully but Page keeps waiting for response

2 replies · opened May 24, 2016

RrchaseMay 24, 2016

Hi Thank you for making this awesome theme!

I removed some of the fields from the job application in both HTML + PHP, and I added a file upload to it that I took from one of your contact form examples, but made sure it matched up in PHP + HTML

Everything works great, just one problem, there is no success message for some reason so the page keeps spinning after you hit submit

I had the exact same problem with the Contact Form but I read a post here and fixed it by changing SMTP debug = 0, but it didnt work this time on job application form.

Site:

http://dev.homemountain.com/jobs.php

Here's my code

PHP

 'rchase@homemountain.com', // Your Email Address
				'name' => 'Reilly Chase' // Your Name
			);

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

// Add this only if you use reCaptcha with your Contact Forms
$recaptcha_secret = '6LeZyyATAAAAAL18NQLGiXmEY22GEVVqaG5HCQXn'; // Your reCaptcha Secret

$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Sender = 'rchase@homemountain.com';
$mail->Host = "myserver";
$mail->SMTPSecure = "ssl";
$mail->SMTPDebug = 0;
$mail->SMTPAuth = true;
$mail->Port = 465;
$mail->Username = "rchase@homemountain.com";
$mail->Password = "mypassword";

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

if( $_SERVER['REQUEST_METHOD'] == 'POST' ) {

	$fname = $_POST['template-jobform-fname'];
	$lname = $_POST['template-jobform-lname'];
	$email = $_POST['template-jobform-email'];
	$position = $_POST['template-jobform-position'];
	$website = $_POST['template-jobform-website'];
	$application = $_POST['template-jobform-application'];

	$name = $fname . ' ' . $lname;

	$subject = 'New Job Application';

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

	if( $botcheck == '' ) {

		$mail->SetFrom( $email , $name );
		$mail->AddReplyTo( $email , $name );
		foreach( $toemails as $toemail ) {
			$mail->AddAddress( $toemail['email'] , $toemail['name'] );
		}
		$mail->Subject = $subject;

		$name = isset($name) ? "Name: $name

" : '';
		$email = isset($email) ? "Email: $email

" : '';
		$position = isset($position) ? "Position: $position

" : '';
		$website = isset($website) ? "Website: $website

" : '';
		$application = isset($application) ? "Application: $application

" : '';

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

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

		$body = "$name $email $position $website $application $referrer";

		// Runs only when File Field is present in the Contact Form
		if ( isset( $_FILES['template-jobform-cvfile'] ) && $_FILES['template-jobform-cvfile']['error'] == UPLOAD_ERR_OK ) {
			$mail->IsHTML(true);
			$mail->AddAttachment( $_FILES['template-jobform-cvfile']['tmp_name'], $_FILES['template-jobform-cvfile']['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 'We have **successfully** received your application and will get back to you as soon as possible.';
		else:
			echo 'Email **could not** be sent due to some Unexpected Error. Please try again later.

**Reason:**
' . $mail->ErrorInfo . '';
		endif;
	} else {
		echo '**Bot Detected**. Email not sent.';
	}
} else {
	echo 'An **Unexpected Error** occured. Please try again later.';
}

?>

HTML


	
	

	
	
- 
	
- 
	
- 
	
- 
	
- 
	
- 
	
- 
	
- 

	
- 
	
	
		
	

	

	
- 
	
- 
	
	Jobs - Home Mountain Printing | Valparaiso, IN

	
			
		
		

			

				

					

					
					
						[
![attachment](images/logo.png)
](index.php)
						[
![attachment](images/logo@2x.png)
](index.php)
					

					
					

						
							
- [Home](/index.php)
							
- [About](/about.php)

						
- [Products](/index.php#products)
								
									
- [Business Cards](/business_cards.php)
										
											
- [Design Online](#)
											
- [Upload Your Design](#)
											
- [Browse Our Templates](#)
										
									
									
- [Flyers](/flyers.php)
										
											
- [Design Online](#)
											
- [Upload Your Design](#)
											
- [Browse Our Templates](#)
										
									
									
- [Brochures](/brochures.php)
										
											
- [Design Online](#)
											
- [Upload Your Design](#)
											
- [Browse Our Templates](#)
										
									
									
- [Postcards](/postcards.php)
										
											
- [Design Online](#)
											
- [Upload Your Design](#)
											
- [Browse Our Templates](#)
										
									
									
- [Letterhead](/letterhead.php)
										
											
- [Design Online](#)
											
- [Upload Your Design](#)
											
- [Browse Our Templates](#)
										
									
									
- [Posters](/posters.php)
										
											
- [Design Online](#)
											
- [Upload Your Design](#)
											
- [Browse Our Templates](#)
										
									
									
- [Invitations](/invitations.php)
										
											
- [Design Online](#)
											
- [Upload Your Design](#)
											
- [Browse Our Templates](#)
										
									
									
- [Greeting Cards](/greeting_cards.php)
										
											
- [Design Online](#)
											
- [Upload Your Design](#)
											
- [Browse Our Templates](#)
										
									
									
- [Magazines](/magazines.php)
									
- [Newspapers](/newspapers.php)
									
- [Calendars](/calendars.php)
									
- [Newsletters](/newsletters.php)
									
- [Envelopes](/invitations.php)
								
							
							
- [Solutions](/index.php#solutions)
								
									
- [Direct Mail](direct_mail.php)
									
- [Web to Print](web_to_print.php)
									
- [Distribution](distribution.php)
								
							
							
- [Jobs](jobs.php)
							
- [Contact](contact.php)
							
- [Shop](https://devhomemountain.myprintdesk.net/DSF/SmartStore.aspx?6xni2of2cF1F4WjmMihQepexf8hiNmebcdCtBG4QNsUf8enAFRcNKVDsuUDKsgC0#!/CategoryHome/-1)

							
						
						
						
						
							[](https://devhomemountain.myprintdesk.net/DSF/SmartStore.aspx?6xni2of2cF1F4WjmMihQepexf8hiNmebcdCtBG4QNsUf8enAFRcNKVDsuUDKsgC0#!/DefaultLogin/)
							[](https://devhomemountain.myprintdesk.net/DSF/SmartStore.aspx?6xni2of2cF1F4WjmMihQepexf8hiNmebcdCtBG4QNsUf8enAFRcNKVDsuUDKsgC0#!/ShoppingCart)

						

						
						
							[](#)
							
								
							
						

					

				

			

		

		
		

			
				Jobs
				
					
- [Home](index.php)
					
- Jobs
				
			

		

		
		

			

				

					

						
							Customer Service Representative
						

						
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nemo, natus voluptatibus adipisci porro magni dolore eos eius ducimus corporis quos perspiciatis quis iste, vitae autem libero ullam omnis cupiditate quam.

						

							Requirements
							
								
									
- B.Tech./ B.E / MCA degree in Computer Science, Engineering or a related stream.
									
- 3+ years of software development experience.
									
- 3+ years of Python / Java development projects experience.
									
- Minimum of 4 live project roll outs.
									
- Experience with third-party libraries and APIs.
									
- In depth understanding and experience  of either SDLC or PDLC.
									
- Good Communication Skills
									
- Team Player
								
							

							What we Expect from you?
							
								
									
- Design and build applications/ components using open source technology.
									
- Taking complete ownership of the deliveries assigned.
									
- Collaborate with cross-functional teams to define, design, and ship new features.
									
- Work with outside data sources and API's.
									
- Unit-test code for robustness, including edge cases, usability, and general reliability.
									
- Work on bug fixing and improving application performance.
								
							

							What you've got?
							You'll be familiar with agile practices and have a highly technical background, comfortable discussing detailed technical aspects of system design and implementation, whilst remaining business driven. With 5+ years of systems analysis, technical analysis or business analysis experience, you'll have an expansive toolkit of communication techniques to enable shared, deep understanding of financial and technical concepts by diverse stakeholders with varying backgrounds and needs. In addition, you will have exposure to financial systems or accounting knowledge.

						

						[Apply Now](#)

						

						
							Sales Representative
						

						
Repudiandae quasi perspiciatis ea placeat nobis asperiores quod fuga ipsa facere enim ipsum expedita debitis, sit quia adipisci deserunt vitae hic obcaecati voluptates rerum nihil.

						

							Requirements
							
								
									
- B.Tech./ B.E / MCA degree in Computer Science, Engineering or a related stream.
									
- 3+ years of software development experience.
									
- 3+ years of Python / Java development projects experience.
									
- Minimum of 4 live project roll outs.
									
- Experience with third-party libraries and APIs.
									
- In depth understanding and experience  of either SDLC or PDLC.
									
- Good Communication Skills
									
- Team Player
								
							

							What we Expect from you?
							
								
									
- Design and build applications/ components using open source technology.
									
- Taking complete ownership of the deliveries assigned.
									
- Collaborate with cross-functional teams to define, design, and ship new features.
									
- Work with outside data sources and API's.
									
- Unit-test code for robustness, including edge cases, usability, and general reliability.
									
- Work on bug fixing and improving application performance.
								
							

							What you've got?
							You'll be familiar with agile practices and have a highly technical background, comfortable discussing detailed technical aspects of system design and implementation, whilst remaining business driven. With 5+ years of systems analysis, technical analysis or business analysis experience, you'll have an expansive toolkit of communication techniques to enable shared, deep understanding of financial and technical concepts by diverse stakeholders with varying backgrounds and needs. In addition, you will have exposure to financial systems or accounting knowledge.

						

						[Apply Now](#)

						

						
							Graphic Designer
						

						
Repudiandae quasi perspiciatis ea placeat nobis asperiores quod fuga ipsa facere enim ipsum expedita debitis, sit quia adipisci deserunt vitae hic obcaecati voluptates rerum nihil.

						

							Requirements
							
								
									
- B.Tech./ B.E / MCA degree in Computer Science, Engineering or a related stream.
									
- 3+ years of software development experience.
									
- 3+ years of Python / Java development projects experience.
									
- Minimum of 4 live project roll outs.
									
- Experience with third-party libraries and APIs.
									
- In depth understanding and experience  of either SDLC or PDLC.
									
- Good Communication Skills
									
- Team Player
								
							

							What we Expect from you?
							
								
									
- Design and build applications/ components using open source technology.
									
- Taking complete ownership of the deliveries assigned.
									
- Collaborate with cross-functional teams to define, design, and ship new features.
									
- Work with outside data sources and API's.
									
- Unit-test code for robustness, including edge cases, usability, and general reliability.
									
- Work on bug fixing and improving application performance.
								
							

							What you've got?
							You'll be familiar with agile practices and have a highly technical background, comfortable discussing detailed technical aspects of system design and implementation, whilst remaining business driven. With 5+ years of systems analysis, technical analysis or business analysis experience, you'll have an expansive toolkit of communication techniques to enable shared, deep understanding of financial and technical concepts by diverse stakeholders with varying backgrounds and needs. In addition, you will have exposure to financial systems or accounting knowledge.

						

						[Apply Now](#)

					

					

						
							Apply Now
						

						

							

							

								

								
									First Name *
									
								

								
									Last Name *
									
								

								

								
									Email *
									
								

								

								
									Position *
									
										-- Select Position --
										Customer Service Representative
										Sales Representative
										Graphic Designer
									
								

								

								
									Website (if any)
									
								

								
									Application *
									
								
								
									Upload CV
									
								
								

									
									

																
								
									
								
								
									Send Application
								

							

						

					

				

		
RrchaseMay 24, 2016

Fixed it!!!

For anyone else looking at this thread, the jobs.php script is returning plaintext by default, but it needs to return JSON success/error messages. I copied these from the contact form php script (sendemail.php).

Replace the messages at the bottom with this

				echo '{ "alert": "success", "message": "' . $message_success . '" }';
			else:
				echo '{ "alert": "error", "message": "Email <strong>could not</strong> be sent due to some Unexpected Error. Please try again later.<br /><br /><strong>Reason:</strong><br />' . $mail->ErrorInfo . '" }';
			endif;
		} else {
			echo '{ "alert": "error", "message": "<strong>Bot Detected.</strong> Email not sent." }';
		}
	} else {
		echo '{ "alert": "error", "message": "Please <strong>fill in</strong> the required fields and try again." }';
	}
} else {
	echo '{ "alert": "error", "message": "An <strong>Unexpected Error</strong> occured. Please try again later." }';
}```
SSemicolon WebSTAFFMay 25, 2016

Hello,

You are Absolutely Spot-On with this! We Really Apologize about this Bug. We will surely fix this in Our Next Update asap. 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.

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