We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,401 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Help with PHP form to use variable as email address

Hi, im new to PHP programming and ive tried a few forums on the net with this question and so far no answers.

I have a php form that is working fine with a pre-determined email address, part of the code is as follows:

    $data_email_sender->AddToAddr("name<name@website.com>");

I also have a variable that displays fine on the page: (shows an email address passed via previous page)

    <?php echo $_GET['ID']; ?>

So what i am trying to do is combine the two so that it would use the 'ID' as the <name@website.com>. Something like:

    $data_email_sender->AddToAddr("name<?php echo $_GET['ID']; ?>");

I know this is incorrect, but it shows what i am trying to do. Ive tried various ways and so far no success!

Hope someone on daniweb can help. Thanks in advance!

2
Contributors
3
Replies
1 Day
Discussion Span
7 Months Ago
Last Updated
4
Views
david.f.smith.351
Newbie Poster
18 posts since Oct 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0
$data_email_sender->AddToAddr("name<" .$_GET['ID']. ">");

You don't need to echo the GET var as you are already in a PHP block.
Or for tidiness, you can build the string separately -

$str = "name<";
$str.= $_GET['id'];
$str.= ">";
$data_email_sender->AddToAddr($str);

Hope this helps.

adam.adamski.96155
Junior Poster
189 posts since Oct 2012
Reputation Points: 43
Solved Threads: 40
Skill Endorsements: 4

Hi, thanks for that input, works great!

david.f.smith.351
Newbie Poster
18 posts since Oct 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

Hey, you are welcome :)

adam.adamski.96155
Junior Poster
189 posts since Oct 2012
Reputation Points: 43
Solved Threads: 40
Skill Endorsements: 4

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0612 seconds using 2.71MB