Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11

Thread: mailto variable

  1. #1
    Regular Coder
    Join Date
    Mar 2005
    Posts
    248
    Thanks
    0
    Thanked 0 Times in 0 Posts

    mailto variable

    how do i do a mailto and get it to input 1 or 2 variables from the php script it's in like the users name.

    <a href="mailto:email">mailto</a>

    so when they click mailto it opens an email and has an auto message in it with there name as well $name ?
    services

  2. #2
    Regular Coder
    Join Date
    Feb 2005
    Location
    West Midlands, UK
    Posts
    623
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You can add the following arguments to mailto to add information into the email:

    Code:
    ?subject=Your subject
    ?&cc=email@address.com
    ?&bcc=email@address.com
    ?&body=Message body text
    So you could do something like:

    PHP Code:
    <?php
    $name 
    $_POST['name']; // or however you're collecting the user's name
    $subject "Website Reply";
    $message "$name sent the following message: Hi, this is a reply from the link on the website...";
    ?>

    <a href="mailto:email@address.com?subject=<?php echo $subject?>&body=<?php echo $message?>">Mail me!</a>

  3. #3
    Regular Coder
    Join Date
    Mar 2005
    Posts
    248
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Parse error: parse error in \\script.php on line 108

    am useing echo to display the html form i did it your way and i added it to the echo ''; and it still came with the error

    any ideas?
    services

  4. #4
    Regular Coder
    Join Date
    Feb 2005
    Location
    West Midlands, UK
    Posts
    623
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Maybe...
    PHP Code:
    echo '<a href="mailto:email@address.com?subject=' $subject '&body=' $message '">Mail me!</a>'

  5. #5
    Regular Coder
    Join Date
    Mar 2005
    Posts
    248
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hmmm no did not like that but i need it with in some text in the echo i already have

    like this

    echo '

    <form>

    </form>

    if you have problems please email BOB mailto ';
    services

  6. #6
    Regular Coder
    Join Date
    Feb 2005
    Location
    West Midlands, UK
    Posts
    623
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well, it's pretty straightforward, I'm sure you will figure it out if you play around with it a little - all the blocks are there they just need putting together

  7. #7
    Regular Coder
    Join Date
    May 2005
    Posts
    563
    Thanks
    0
    Thanked 3 Times in 3 Posts
    post the errors you are getting and the code you have so far and the line numbers if possible.

  8. #8
    Regular Coder
    Join Date
    Mar 2005
    Posts
    248
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for your help if i don't reply within 1 day I CAN'T DO IT!!!!!
    services

  9. #9
    Regular Coder
    Join Date
    Mar 2005
    Posts
    248
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by SeeIT Solutions
    post the errors you are getting and the code you have so far and the line numbers if possible.
    Notice: Undefined index: name in \\script.php on line 115

    line 115 error $name = $_POST['name']; // or however you're collecting the user's name


    and when i do open the mailto when i click on the link it just shows this <?php echo $message; ?>
    services

  10. #10
    Regular Coder
    Join Date
    May 2005
    Posts
    563
    Thanks
    0
    Thanked 3 Times in 3 Posts
    that error means name isn't a post variable

    Try this, then play around with it

    PHP Code:
    <?php 
    $name 
    "Name test";
    $subject "Website Reply"
    $message $name." sent the following message: Hi, this is a reply from the link on the website..."

    echo 
    '<a href="mailto:email@address.com?subject=' $subject '&body=' $message '">Mail me!</a>';  

    ?>
    Last edited by SeeIT Solutions; 05-25-2005 at 04:07 PM.

  11. #11
    Regular Coder
    Join Date
    Mar 2005
    Posts
    248
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thank you master yogda (copyright)

    i used $username

    and the problem was with mailto link but the one you shown me works

    <a href="mailto:email@address.com?subject=' . $subject . '&body=' . $message . '">Mail me!</a>
    services


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •