Jump to content

Inserting different email address into Feedback form


hosteltrail

Recommended Posts

PHP is certainly not my forte as so I have found myself in something of a pickle which hopefully someone out there can help me out with. 

 

I have a website which contains "profiles" for around 200 small hostels and tour companies in South America.  each profile has a feedback form inserted into it using SSI which allows backpackers to send emails direct to the hostel/company.  When the submit button is pressed, it executes a PHP script (which I got off thesitewizard.com) to mail the form back direct to the company.  Whilst the actual feedback form itself is one file, inserted into each profile, the PHP that executes is separate for each company - the only reason is because the email address differs for each company.

 

 

My main aim is to have the bulk of the PHP script as one file and somehow include the email address into the PHP script either using somekind of include() from a separate file or otherwise taking it as a variable in the profile page itself.

 

As I'm rubbish with PHP, I trawled the net and read through about a dozen tutorials regarding PHP include, but the script fails to execute when I do this.  The code I am using is:  <?php include("file.php"); ?>.

 

The include function definately works as I have tried creating a blank php file with just <?php include("file.php"); ?>  (where file.php is the FULL php script) in it and it executes perfectly.  However,  When I divide the script in two and put the first half in the document and follow it with <?php include("file.php"); ?>  eg...

 

<?

$mailto = "[email protected]";

<?php include("file.php"); ?>

 

I get an error message stating: Parse error: syntax error, unexpected '<' obviously because it can't handle the <? before the php include.

 

Is there a way in which you can insert plain text (ie an email address perhaps from a text file) into a PHP script?

 

All suggestions and assistance would be gratefully recieved- as you can see....I'm a bit lost to say the least!

 

 

I think you'd be better off using a switch and a variable in the URL and/or a hidden field in the form you submit.

 

Something like:

<input name="company" type="hidden" value="abc_corp"/>

 

and in the script you submit something along the lines of:

<?php
if(isset($_POST['company']) && is_scalar($_POST['company'])){
switch ($_POST['company']) {
case 'abc_corp':
	$mailto = '[email protected]';
	break;
case 'foo_bar':
	$mailto = '[email protected]';
	break;
case 'lipsum':
	$mailto = '[email protected]';
	break;
}
}
?>

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.