Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Want to send html code from forms on site


aldaffodil

Recommended Posts

Ok, I would like a form from my site (a modification of the contact us form already included with osCommerce) to send me an email that includes html code. I will try to explain without being too brief or too complicated.

 

Let's just stick to an URL example.

 

The url variable is $url and the input should be something like www.mysite.com.

 

I am building the message text as $listing_info.

 

This is what I currently have:

$listing_info = "Website:  " . $url;

 

When I receive the email, it says:

Website:  www.mysite.com

 

What i would like it to say in my email is:

Website:  <a href="www.mysite.com">www.mywebsite.com</a>

 

I would think something like this would work (but it doesn't!)

$listing_info = "Website:  http://\"" . $url . "\">" . $url . "</a>";

 

Anyone know how to code my $listing_info so that it will print html code in the email it sends?

 

Sorry if this doesn't make since, I explained best I know how.

Link to comment
Share on other sites

Ok, I would like a form from my site (a modification of the contact us form already included with osCommerce) to send me an email that includes html code. I will try to explain without being too brief or too complicated.

 

Let's just stick to an URL example.

 

The url variable is $url and the input should be something like www.mysite.com.

 

I am building the message text as $listing_info.

 

This is what I currently have:

$listing_info = "Website:  " . $url;

 

When I receive the email, it says:

Website:  www.mysite.com

 

What i would like it to say in my email is:

Website:  <a href="www.mysite.com">www.mywebsite.com</a>

 

I would think something like this would work (but it doesn't!)

$listing_info = "Website:  http://\"" . $url . "\">" . $url . "</a>";

 

Anyone know how to code my $listing_info so that it will print html code in the email it sends?

 

Sorry if this doesn't make since, I explained best I know how.

You'd have to edit the actual email class to get it to create html emails, as there are mime format entries that have to be included to tell the email readers that it's text/html, and possibly some things I'm not thinking of, but just creating the anchor tag in the email won't do anything except make it output out well, it won't actually hyperlink the text...

 

Richard.

Richard Lindsey

Link to comment
Share on other sites

I'm actually not trying to have it hyperlink in the email. I want it to print the HTML code (because I'm going to insert it into a description field just as it is emailed to me), if that makes sense.

 

So, what I want to send is an email that has html code that doesn't process, but prints as html code.

Link to comment
Share on other sites

I'm actually not trying to have it hyperlink in the email. I want it to print the HTML code (because I'm going to insert it into a description field just as it is emailed to me), if that makes sense.

 

So, what I want to send is an email that has html code that doesn't process, but prints as html code.

Oh, well in that case it's easy :D Just do something like this (copying and pasting from your original post), change this from your original post:

 

$listing_info = "Website:  http://\"" . $url . "\">" . $url . "</a>";

Into this:

 

$listing_info = "Website:  <a href=\"http://" . $url . "\">" . $url . "</a>";

Richard.

Richard Lindsey

Link to comment
Share on other sites

Not to be totally anal, but you can use single quotes since PHP parses them faster and in this case they improve readability (in my opinion):

$listing_info = 'Website:  <a href="http://' . $url . '">' . $url . '</a>';

 

Alternately, there's no reason to close the double quotes if you want to use them:

$listing_info = "Website:  <a href=\"http://$url\">$url</a>";

 

I'm not trying to nitpick or disrespect the previous poster's advice, just putting the thought out there.

Link to comment
Share on other sites

Thank so much for your help guys. I tried your suggestions, but the email is just ignoring the html tags. I am wondering if there is some other tag I need to use to print the tags in the email. I will post a solution if I find one.

 

Thanks again!

Link to comment
Share on other sites

Thank so much for your help guys. I tried your suggestions, but the email is just ignoring the html tags. I am wondering if there is some other tag I need to use to print the tags in the email. I will post a solution if I find one.

 

Thanks again!

Check the code that formats that email, it might be running it through a strip_tags call or a regex to strip out any html that's embedded in it...

 

Richard.

Richard Lindsey

Link to comment
Share on other sites

Check the code that formats that email, it might be running it through a strip_tags call or a regex to strip out any html that's embedded in it...

 

Richard.

 

That worked perfectly! Thank you all so much, this has made my life so much easier - you have no idea!

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...