hosteltrail Posted October 13, 2007 Share Posted October 13, 2007 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 = "info@email.com"; <?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! Quote Link to comment https://forums.phpfreaks.com/topic/73033-inserting-different-email-address-into-feedback-form/ Share on other sites More sharing options...
derwert Posted October 13, 2007 Share Posted October 13, 2007 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 = 'feedback@abc-corp.example.com'; break; case 'foo_bar': $mailto = 'feedback@foo-bar.example.com'; break; case 'lipsum': $mailto = 'feedback@lipsum.example.com'; break; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/73033-inserting-different-email-address-into-feedback-form/#findComment-368382 Share on other sites More sharing options...
yzerman Posted October 13, 2007 Share Posted October 13, 2007 <? $mailto = "info@email.com"; <?php include("file.php"); ?> ^^ thats your error Should be <?php $mailto = "info@email.com"; include("file.php"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/73033-inserting-different-email-address-into-feedback-form/#findComment-368396 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.