Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7017275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:53:35+00:00 2026-05-27T22:53:35+00:00

i have a new feature on my site that allow user to get vcard

  • 0

i have a new feature on my site that allow user to get vcard files. this feature reads data from my database (which this one works) and generate the vcard.

the file is: vcard.php and i pass the user id as GET

then i get all the information using that id

my problem is when i want to get the vcard, it display as text. here’s a simplified version of my code:

<?php

class Vcard {

  public function __construct() {
    $this->props = array();
  }

  public function setName($family, $first) {
    $name = $family . ';' . $first . ';';
    $this->props['N'] = $name;
    if(!isset($this->props['FN'])) {
      $display = $first . ' ';
      $display .= $family;
      $this->props['FN'] = trim($name);
    }
  }
  /* and all the rest of my props */
  public function get() {
    $text = 'BEGIN:VCARD' . "\r\n";
    $text.= 'VERSION:2.1' . "\r\n";
    foreach($this->props as $key => $value) {
      $text .= $key . ':' . $value . "\r\n";
    }
    $text.= 'REV:' . date("Y-m-d") . chr(9) . date("H:i:s") . "\r\n";
    $text.= 'MAILER:My VCard Generator' . "\r\n";
    $text.= 'END:VCARD' . "\r\n";
    return $text;
  }
}

$v = new Vcard();
$v->setName('Smith', 'John');
echo $v->get();

the code works, why it does not get it as vcard?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T22:53:36+00:00Added an answer on May 27, 2026 at 10:53 pm

    Given http://en.wikipedia.org/wiki/VCard

    You certainly need to add the following line before echo $v->get();

    header('Content-Type: text/vcard');
    

    in order to tell the client’s browser that it will receive a VCard file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm surprised that MS has implemented a new feature: Validation with INotifyDataErrorInfo I have
I have a free web site that streams real-time stock-options data. I want to
I have a new feature on my site, where users can submit any text
Background: I have a site that I deploy my content type too and this
I have some code that creates a new site in SharePoint. Upon browsing to
I have a working webview that i modify to load different urls. This site
I have been using the new feature of Spring 3.1.1 the java based configuration.
When we have new in C#, that personally I see only as a workaround
I am trying to implement an admin feature on my site that allows an
I am designing a standard ASP.Net site with a SQL database. I have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.