Request: Contact Form Mod.

Is there anyway to have the current Contact Form have a drop down and list all the staff members emails?

You would need to add your drop down to contact_form.tpl :

<select name="recipient">
<option value="[email protected]">Staff Member</option>
<select>

And in the php you would need to find the part where it mentions:

Util::SendEmail(ADMIN_EMAIL, $subject, $message);

and change to:

Util::SendEmail($this->post->recipient, $subject, $message);

where recipient is the name of your dropdown.

I think

1 Like

Guess what?  It worked 8) thanks again Tom

Chad C.

It appears the new contact_form.tpl doesn’t have the below PHP code so I wasn’t able to get this to work.  Any ideas on how to make it work with the new form code?

Util::SendEmail(ADMIN_EMAIL, $subject, $message);

You need to edit that part in the php, in core/modules/Contact/Contact.php

A big duh on my part.    I was looking for the php code in conact_form.tpl.

Got it working…

Thanks!

Ok Guys,

I Used this on the Old version, Before the release of 2.0 i think, well anyways it was about 1 week after this post was made and I used this without any problems, Now ive updated the contact form with the new version, The CURRENT 2.1.934 version as its been updated, But, For some random reason, it dont work, And i submitted a test one about 5 hrs ago and got nothing back :confused:

Yes ive updated the .tpl’s and also updated the Contact.php again but still, nothing!

Ive checked all of the files related to the contact.php and contact_form.tpl but to be quite honest i cant see any problems relating to the non-sending mail

Any Ideas?

-Thomas.

Ok Guys,

I Used this on the Old version, Before the release of 2.0 i think, well anyways it was about 1 week after this post was made and I used this without any problems, Now ive updated the contact form with the new version, The CURRENT 2.1.934 version as its been updated, But, For some random reason, it dont work, And i submitted a test one about 5 hrs ago and got nothing back :confused:

Yes ive updated the .tpl’s and also updated the Contact.php again but still, nothing!

Ive checked all of the files related to the contact.php and contact_form.tpl but to be quite honest i cant see any problems relating to the non-sending mail

Any Ideas?

-Thomas.

The new contact form uses reCAPTCHA and the old one did not. While I’m not sure if that is your problem it is something to look at. What I had to do was use the new contact_form.tpl from the current version and then modify it to include this mod. It now works fine for me.

Hmm, Ok Thanks, I think I’ll Probably just go back to the normal contact.php and contact_form.tpl, see what happens with them, If it works i will see what to do from there.

Thanks anyways

-Thomas.

Hi,

I have a problem with contact form. In fact, when I send a test mail via this form, it didn’t receive/send.

Code of Contact_form.tpl

<h3>Contactez-nous</h3>
<form method="post" action="<?php echo url('/contact'); ?>">
 <table width='100%' border='0'>
   <tr>
     <td><strong>Nom:</strong></td>
     <td>
	<?php
	if(Auth::LoggedIn())
	{
		echo Auth::$userinfo->firstname .' '.Auth::$userinfo->lastname;
		echo '<input type="hidden" name="name" 
				value="'.Auth::$userinfo->firstname 
						.' '.Auth::$userinfo->lastname.'" />';
	}
	else
	{
	?>
		<input type="text" name="name" value="" />
		<?php
	}
	?>
     </td>
   </tr>
   <tr>
	<td width="1%" nowrap><strong>Adresse e-mail:</strong></td>
	<td>
	<?php
	if(Auth::LoggedIn())
	{
		echo Auth::$userinfo->email;
		echo '<input type="hidden" name="name" 
				value="'.Auth::$userinfo->email.'" />';
	}
	else
	{
	?>
		<input type="text" name="email" value="" />
		<?php
	}
	?>
	</td>
</tr>

   <tr>
	<td><strong>Destinataire: </strong></td>
	<td><select name="recipient">
       	<option value="[email protected]">Le staff</option>
	<option value="[email protected]">La direction général</option>
	<option value="[email protected]">La direction des ressources humaines</option>
	<option value="[email protected]">La direction technique et des opérations</option>
       <select></td>

</tr>

<tr>
	<td><strong>Objet: </strong></td>
	<td><input type="text" name="subject" value="<?php echo $_POST['subject'];?>" /></td>

</tr>
   <tr>
     <td><strong>Message:</strong></td>
     <td>
	<textarea name="message" cols='45' rows='5'><?php echo $_POST['message'];?></textarea>
     </td>
   </tr>

	<td>
		<input type="hidden" name="loggedin" value="<?php echo (Auth::LoggedIn())?'true':'false'?>" />
	</td>
	<td>
         <input type="submit" name="submit" value='Send Message'>
	</td>
   </tr>
 </table>
</form>

Code of Contact.php :

<?php
/**
* phpVMS - Virtual Airline Administration Software
* Copyright (c) 2008 Nabeel Shahzad
* For more information, visit www.phpvms.net
*	Forums: http://www.phpvms.net/forum
*	Documentation: http://www.phpvms.net/docs
*
* phpVMS is licenced under the following license:
* Creative Commons Attribution Non-commercial Share Alike (by-nc-sa)
* View license.txt in the root, or visit http://creativecommons.org/licenses/by-nc-sa/3.0/
*
* @author Nabeel Shahzad
* @copyright Copyright (c) 2008, Nabeel Shahzad
* @link http://www.phpvms.net
* @license http://creativecommons.org/licenses/by-nc-sa/3.0/
*/

class Contact extends CodonModule 
{

public function index()
{
	if($this->post->submit)
	{
		$captcha = SessionManager::Get('captcha_sum');

		if($this->post->loggedin == 'false')
		{		


			# Make sure they entered an email address
			if(trim($this->post->name) == '' 
				|| trim($this->post->email) == '')
			{
				$this->set('message', 'You must enter a name and email!');
				$this->render('core_error.tpl');
				return;
			}
		}

		if($this->post->subject == '' || trim($this->post->message) == '')
		{
			$this->set('message', 'You must enter a subject and message!');
			$this->render('core_error.tpl');
			return;
		}

		$subject = 'New message from '.$this->post->name.' - "'.$this->post->subject.'"';
		$message = DB::escape($this->post->message) . PHP_EOL . PHP_EOL;

		foreach($_POST as $field=>$value)
		{
			$message.="-$field = $value".PHP_EOL;
		}

		Util::SendEmail($this->post->recipient, $subject, $message);

		$this->render('contact_sent.tpl');
		return;
	}		

	# Just a simple addition
	$rand1 = rand(1, 10);
	$rand2 = rand(1, 10);

	$this->set('rand1', $rand1);
	$this->set('rand2', $rand2);		

	$tot = $rand1 + $rand2;
	//echo "total: $tot <br />";
	SessionManager::Set('captcha_sum', $tot);

	//echo 'output of $_SESSION: <br />';
	//print_r($_SESSION);

	$this->render('contact_form.tpl');
}

}

Can you help me please ?

That is not the default contact tpl, have a search here there is the code for what you want to achieve.

Looks like you’re using a really old version of phpVMS/the template. I suggest updating.

Yes but with old or new version, we have same problem :

Contact.php :

<?php
/**
* phpVMS - Virtual Airline Administration Software
* Copyright (c) 2008 Nabeel Shahzad
* For more information, visit www.phpvms.net
*	Forums: http://www.phpvms.net/forum
*	Documentation: http://www.phpvms.net/docs
*
* phpVMS is licenced under the following license:
* Creative Commons Attribution Non-commercial Share Alike (by-nc-sa)
* View license.txt in the root, or visit http://creativecommons.org/licenses/by-nc-sa/3.0/
*
* @author Nabeel Shahzad
* @copyright Copyright (c) 2008, Nabeel Shahzad
* @link http://www.phpvms.net
* @license http://creativecommons.org/licenses/by-nc-sa/3.0/
*/

class Contact extends CodonModule 
{
public function index()
{
	require_once CORE_LIB_PATH.'/recaptcha/recaptchalib.php';


	if($this->post->submit)
	{
		if(Auth::LoggedIn() == false)
		{					
			# Make sure they entered an email address
			if(trim($this->post->name) == '' 
				|| trim($this->post->email) == '')
			{
				$this->set('message', 'You must enter a name and email!');
				$this->render('core_error.tpl');
				return;
			}
		}

		$resp = recaptcha_check_answer (Config::Get('RECAPTCHA_PRIVATE_KEY'),
			$_SERVER["REMOTE_ADDR"],
			$_POST["recaptcha_challenge_field"],
			$_POST["recaptcha_response_field"]);

		// Check the captcha thingy
		if(!$resp->is_valid)
		{
			$this->set('captcha_error', $resp->error);
			$this->set('message', 'You failed the captcha test!');
			$this->render('contact_form.tpl');
			return;
		}

		if($this->post->subject == '' || trim($this->post->message) == '')
		{
			$this->set('message', 'You must enter a subject and message!');
			$this->render('core_error.tpl');
			return;
		}

		$subject = 'New message from '.$this->post->name.' - "'.$this->post->subject.'"';
		$message = DB::escape($this->post->message) . PHP_EOL . PHP_EOL;

		unset($_POST['recaptcha_challenge_field']);
		unset($_POST['recaptcha_response_field']);

		foreach($_POST as $field=>$value)
		{
			$message.="-$field = $value".PHP_EOL;
		}

		$message = nl2br($message);
		$message = utf8_encode($message);
		Util::SendEmail($this->post->recipient, $subject, $message);

		$this->render('contact_sent.tpl');
		return;
	}		

	# Just a simple addition
	$rand1 = rand(1, 10);
	$rand2 = rand(1, 10);

	$this->set('rand1', $rand1);
	$this->set('rand2', $rand2);		

	$tot = $rand1 + $rand2;
	//echo "total: $tot <br />";
	SessionManager::Set('captcha_sum', $tot);

	//echo 'output of $_SESSION: <br />';
	//print_r($_SESSION);

	$this->render('contact_form.tpl');
}

}

Contact_form.tpl :

<center><h3>Formulaire de contact</h3></center>
<form method="post" action="<?php echo url('/contact'); ?>">
 <table width='100%' border='0'>
   <tr>
     <td><strong>Nom:</strong></td>
     <td>
	<?php
	if(Auth::LoggedIn())
	{
		echo Auth::$userinfo->firstname .' '.Auth::$userinfo->lastname;
		echo '<input type="hidden" name="name" 
				value="'.Auth::$userinfo->firstname 
						.' '.Auth::$userinfo->lastname.'" />';
	}
	else
	{
	?>
		<input type="text" name="name" value="" />
		<?php
	}
	?>
     </td>
   </tr>
   <tr>
	<td width="1%" nowrap><strong>Adresse e-mail:</strong></td>
	<td>
	<?php
	if(Auth::LoggedIn())
	{
		echo Auth::$userinfo->email;
		echo '<input type="hidden" name="name" 
				value="'.Auth::$userinfo->email.'" />';
	}
	else
	{
	?>
		<input type="text" name="email" value="" />
		<?php
	}
	?>
	</td>
</tr>

   <tr>
	<td><strong>Destinataire: </strong></td>
	<td><select name="recipient">
       <option value="[email protected]">Le staff</option>
	<option value="[email protected]">La direction général</option>
	<option value="[email protected]">La direction des ressources humaines</option>
	<option value="[email protected]">La direction technique et des opérations</option>
       <select></td>

</tr>

<tr>
	<td><strong>Objet: </strong></td>
	<td><input type="text" name="subject" value="<?php echo $_POST['subject'];?>" /></td>

</tr>
   <tr>
     <td><strong>Message:</strong></td>
     <td>
	<textarea name="message" cols='45' rows='5'><?php echo $_POST['message'];?></textarea>
     </td>
   </tr>

<tr>
	<td width="1%" nowrap><strong>Vérification</strong></td>
	<td>
	<?php
	echo recaptcha_get_html(Config::Get('RECAPTCHA_PUBLIC_KEY'), $captcha_error);
	?>
	</td>
</tr>

	<td>
		<input type="hidden" name="loggedin" value="<?php echo (Auth::LoggedIn())?'true':'false'?>" />
	</td>
	<td>
         <input type="submit" name="submit" value='Envoyer'>
	</td>
   </tr>
 </table>
</form>

Thanks in advance

This is what i use minus the addresses,

contact_form.tpl

<h3>Contact Us</h3>
<form method="post" action="<?php echo url('/contact'); ?>">
 <table width='100%' border='0'>
   <tr>
     <td><strong>Name:</strong></td>
     <td>
	<?php
	if(Auth::LoggedIn())
	{
		echo Auth::$userinfo->firstname .' '.Auth::$userinfo->lastname;
		echo '<input type="hidden" name="name" 
				value="'.Auth::$userinfo->firstname 
						.' '.Auth::$userinfo->lastname.'" />';
	}
	else
	{
	?>
		<input type="text" name="name" value="" />
		<?php
	}
	?>
     </td>
   </tr>
   <tr>
	<td width="1%" nowrap><strong>E-Mail Address:</strong></td>
	<td>
	<?php
	if(Auth::LoggedIn())
	{
		echo Auth::$userinfo->email;
		echo '<input type="hidden" name="name" 
				value="'.Auth::$userinfo->email.'" />';
	}
	else
	{
	?>
		<input type="text" name="email" value="" />
		<?php
	}
	?>
	</td>
</tr>

<tr>
	<td><strong>Subject: </strong></td>
	<td><input type="text" name="subject" value="<?php echo $_POST['subject'];?>" /></td>
<td></td>
</tr>
<td><strong>To whom:</strong></td>
<td><select name="recipient">
<option value="emailaddresses_here" selected="selected">Name to Here</option>
<option value="emailaddresses_here" selected="selected">Name to Here</option>
<option value="emailaddresses_here" selected="selected">Name to Here</option>
<option value="emailaddresses_here" selected="selected">Name to Here</option>
   </select>
</td>
   <tr>
     <td><strong>Message:</strong></td>
     <td>
	<textarea name="message" cols='45' rows='5'><?php echo $_POST['message'];?></textarea>
     </td>
   </tr>

   <tr>
	<td width="1%" nowrap><strong>Captcha</strong></td>
	<td>
<script type="text/javascript">
        var RecaptchaOptions = {
           theme : 'white'
        };
        </script>
	<?php
	echo recaptcha_get_html(Config::Get('RECAPTCHA_PUBLIC_KEY'), $captcha_error);
	?>
	</td>
</tr>

   <tr>
	<td>
		<input type="hidden" name="loggedin" value="<?php echo (Auth::LoggedIn())?'true':'false'?> Pilot ID = <?php echo Auth::PilotID(); ?>" />
	</td>
	<td>
       <input type="hidden" name="ip" value="<?php echo $_SERVER['REMOTE_ADDR'] ?>">
         <input type="submit" name="submit" value='Send Message'>
	</td>
   </tr>
 </table>
</form></div>
</div>
	</div>

Contact.php

<?php
/**
* phpVMS - Virtual Airline Administration Software
* Copyright (c) 2008 Nabeel Shahzad
* For more information, visit www.phpvms.net
*	Forums: http://www.phpvms.net/forum
*	Documentation: http://www.phpvms.net/docs
*
* phpVMS is licenced under the following license:
* Creative Commons Attribution Non-commercial Share Alike (by-nc-sa)
* View license.txt in the root, or visit http://creativecommons.org/licenses/by-nc-sa/3.0/
*
* @author Nabeel Shahzad
* @copyright Copyright (c) 2008, Nabeel Shahzad
* @link http://www.phpvms.net
* @license http://creativecommons.org/licenses/by-nc-sa/3.0/
*/

class Contact extends CodonModule 
{
public function index()
{
	require_once CORE_LIB_PATH.'/recaptcha/recaptchalib.php';


	if($this->post->submit)
	{
		if(Auth::LoggedIn() == false)
		{					
			# Make sure they entered an email address
			if(trim($this->post->name) == '' 
				|| trim($this->post->email) == '')
			{
				$this->set('message', 'You must enter a name and email!');
				$this->render('core_error.tpl');
				return;
			}
		}

		$resp = recaptcha_check_answer (Config::Get('RECAPTCHA_PRIVATE_KEY'),
			$_SERVER["REMOTE_ADDR"],
			$_POST["recaptcha_challenge_field"],
			$_POST["recaptcha_response_field"]);

		// Check the captcha thingy
		if(!$resp->is_valid)
		{
			$this->set('captcha_error', $resp->error);
			$this->set('message', 'You failed the captcha test!');
			$this->render('contact_form.tpl');
			return;
		}

		if($this->post->subject == '' || trim($this->post->message) == '')
		{
			$this->set('message', 'You must enter a subject and message!');
			$this->render('core_error.tpl');
			return;
		}

		$subject = 'New message from '.$this->post->name.' - "'.$this->post->subject.'"';
		$message = DB::escape($this->post->message) . PHP_EOL . PHP_EOL;

		unset($_POST['recaptcha_challenge_field']);
		unset($_POST['recaptcha_response_field']);

		foreach($_POST as $field=>$value)
		{
			$message.="-$field = $value".PHP_EOL;
		}

		$message = nl2br($message);
		$message = utf8_encode($message);
		Util::SendEmail($this->post->recipient, $subject, $message);

		$this->render('contact_sent.tpl');
		return;
	}		

	# Just a simple addition
	$rand1 = rand(1, 10);
	$rand2 = rand(1, 10);

	$this->set('rand1', $rand1);
	$this->set('rand2', $rand2);		

	$tot = $rand1 + $rand2;
	//echo "total: $tot <br />";
	SessionManager::Set('captcha_sum', $tot);

	//echo 'output of $_SESSION: <br />';
	//print_r($_SESSION);

	$this->render('contact_form.tpl');
}

}

I got it working perfectly in 2.1.934.

It works Thanks

No problem.

How do I get this to show up on my website if it is included in the phpvms package that I downloaded and loaded onto my server?

Hi guys ;

I have a big prob with my contact form! I need to change the defult encoding to UTF-8

there is a line in Contact.php =[$message = utf8_encode($message);] …

but it’s NOT working !?

< for your info : I changed the coding for Coctact_form.tpl and Contact.php to UTF-8 ,But it does NOT work! >

thanks guys for helping me…

One way is to go to your local.config file and go to line 97 where it says:

Config::Set('PAGE_ENCODING', 'ISO-8859-1');

and change it to:

Config::Set('PAGE_ENCODING', 'UTF-8');