Jump to content

Request: Contact Form Mod.


piper338

Recommended Posts

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

<select name="recipient">
<option value="staffmember@website.com">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 :)

  • Like 1
Link to comment
Share on other sites

  • 2 months later...
  • 3 months later...

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 :/

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.

Link to comment
Share on other sites

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 :/

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.

Link to comment
Share on other sites

  • 11 months later...

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="info@worldskyairline.com">Le staff</option>
	<option value="executif@worldskyairline.com">La direction général</option>
	<option value="rh@worldskyairline.com">La direction des ressources humaines</option>
	<option value="thomas.nouyer@worldskyairline.com">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 ?

Link to comment
Share on other sites

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="info@worldskyairline.com">Le staff</option>
	<option value="executif@worldskyairline.com">La direction général</option>
	<option value="rh@worldskyairline.com">La direction des ressources humaines</option>
	<option value="thomas.nouyer@worldskyairline.com">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 :)

Link to comment
Share on other sites

  • Moderators

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');
}

}

Link to comment
Share on other sites

  • 3 weeks later...
  • 1 year later...

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... ;)

Link to comment
Share on other sites

  • 4 weeks later...

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');

[my problem SOLVED]

thanks Mr.bean ;

but i had a problem when i recieved an email from my Contact Form!

In other words , i had problem when i tried to read mails in Yahoo or Gmail!

I just remove this line $message = utf8_encode($message); from my CONTACT module and the problem SOLVED.

I think the prob was that my CONTACT page was already UTF-8 and my CONTACT module was also encoding the DATA to UTF-8 , and we had 2 process for encoding!

Link to comment
Share on other sites

  • 4 years later...
On 09/04/2011 at 1:52 PM, Tomgis34 said:

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="info@worldskyairline.com">Le staff</option>
	<option value="executif@worldskyairline.com">La direction général</option>
	<option value="rh@worldskyairline.com">La direction des ressources humaines</option>
	<option value="thomas.nouyer@worldskyairline.com">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 ?

 

On mine working only to email i added in admin panel , i add in form another two and dont send to them , 

Link to comment
Share on other sites

  • 3 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...