Link to home
Start Free TrialLog in
Avatar of yahya
yahya

asked on

how do I read environment variable passed in C++

I am trying trying to read the user name and password passed from a form in a web page in my c++ program.

Ho doea httpheader work in c++
Avatar of Roshan Davis
Roshan Davis
Flag of United States of America image

Please give more details..
1. Which type of c++ program u r using ISAPI . or any type of dll ?
2. In which format u r getting the value, as a form , or a paramater list from a POST/GET ?

Roshmon
Avatar of yahya
yahya

ASKER

1. I am using  dll
2. as a form and as a parameter list POST

thankx
 
U getting the parameter list ?
And u want, just extract the user name & password ...

OR

U want to know how to get this parameter list

Roshmon
Avatar of yahya

ASKER

i want to know how to get it please
ASKER CERTIFIED SOLUTION
Avatar of Roshan Davis
Roshan Davis
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of yahya

ASKER

This q is changed now

I am getting the HTTP header however , when I extract the value I cant find the cookie header. any idea why.

I am using w2k and VC++ v6
 thanx
Avatar of jkr
See http://hoohoo.ncsa.uiuc.edu/cgi/env.html
as a reference.

The following example will render this data as HTML:

#include <stdio.h>
#include <strings.h>
#include <stdlib.h>

/* Compile:
   gcc  -Wall -pedantic -pipe -O5 -o user-data user-data.c
*/  

#include <stdio.h>
#include <strings.h>
#include <stdlib.h>

int main(void) {

char* pszUser = getenv ("REMOTE_USER"); // user name
char* pszAuth = getenv ("REMOTE_AUTH"); // auth info


  puts("Content-type: text/html\n");
  puts("<HTML><HEAD><TITLE>USER DATA</TITLE></HEAD>");
  puts("<CENTER><H1 ALIGN=CENTER> Here's your user data:</H1>%s %s<HR><H2>", pszUser, pszAuth);
  puts("</H2></BODY></HTML>");
}
Dear yahya

I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. You can always request to keep this question open. But remember, experts can only help you if you provide feedback to their questions.
Unless there is objection or further activity,  I will suggest to split between

     "roshmon and jkr"

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
Force accepted.

jkr, I will post a separate question with points for your help.

** Mindphaser - Community Support Moderator **