Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

cant get this to work...

  • 17-11-2011 11:16AM
    #1
    Registered Users, Registered Users 2 Posts: 459 ✭✭


    I have a contact form (contact.php) that only allows it's content to be sent to one address, the address is defined in a sub directory in config.php

    If I add:
    [PHP]include('../contact.php');[/PHP]
    To the beginning of config.php

    and I add a new form value in contact.php:
    [PHP] <label for=to><span class="mandatory">* </span>To:</label>
    <input type="text" name="to" id="to" value="" class="textfield" autocomplete="off"/>[/PHP]

    and change config.php $mailTo from static $mailTo = "sara@mydomain.ie";
    $mailTo .= "".$_POST."@mydomain.ie"";
    does not work.

    Peter, Sara etc all have accounts @mydomain.ie, so I want to be able to simply put 'Peter' in the To: field of the form and the result being that config.php will get peter@mydomain.ie inserted into the $mailTo.

    I don't 100% understand the "".$_POST."" part as it is used in mail.php (code that sends the mail) to add a suffix to form fields ie.
    [PHP]$message .= "nessage: ".$_POST."";[/PHP]
    What I want to do is add a prefix...
    works --> $message .= "message: ".$_POST."";
    won't work --> $mailTo .= "".$_POST."@mydomain.ie"";


Comments

  • Registered Users, Registered Users 2 Posts: 459 ✭✭CSU


    :(

    require_once was breaking the script so I include('../contact.php'); and gives error:

    Warning: include(../contact.php) [function.include]: failed to open stream: No such file or directory in E:\www\contact_lib\config.php on line 2


    Anyone got a mail script that has the ability to choose recipient?


  • Registered Users, Registered Users 2 Posts: 6,131 ✭✭✭jhegarty


    The post isn't too clear.

    Which folders are the two files in ?


  • Registered Users, Registered Users 2 Posts: 459 ✭✭CSU


    [WWW Root]
    contact.php
    ..[contact_lib]
    ..config.php

    E;

    sorry post is a mess - all I need to do is have the ability to:
    1. choose recipient (add form field To)
    2. insert recipient into config.php ($mailTo)
    3. Add prefix to $mailTo from form To field ($mailTo .= "".$_POST."@mydomain.ie""; )
    ^^ above code wont work :(
    ...

    any info on the interwebs always talks of a static $to string when sending mail...why can't I find info on dynamic mail $to string...


Advertisement