Jump to content

set variable _SERVER["PHP_AUTH_USER"] using php


rambabuforu

Recommended Posts

<?php

$username = "username";

$password = "password";

if(($_POST['PHP_AUTH_USER'] == $username)&& ($_POST['PHP_AUTH_PW'] == $password))

{

echo apache_setenv("PHP_AUTH_USER",$username);

echo apache_setenv("PHP_AUTH_PW",$password);

echo putenv("PHP_AUTH_USER =$username");

echo putenv("PHP_AUTH_PW = $password");

$PHP_AUTH_USER =$username;

$PHP_AUTH_PW = $password;

$_SERVER['PHP_AUTH_USER'] =$username;

$_SERVER['PHP_AUTH_PW'] = $password;

}

?>

<form method="post">

<p>Username : <input type="textbox" name="PHP_AUTH_USER" id="PHP_AUTH_USER" /><br />

<p>Password : <input type="password" name="PHP_AUTH_PW" id="PHP_AUTH_PW" /><br />

<p> <input type="submit" name="submit" />

</form>

:confused:

I need to set the variables $_SERVER['PHP_AUTH_USER'] and $_SERVER['PHP_AUTH_PW'] using php, passing form values.

 

Please help me to sort out this......

Link to comment
Share on other sites

You just did, whats the problem?

 

There not going to persist requests however which is what I assume you want to do. For that to happen you would need to store the data submitted by your form within the $_SESSION array and then use that to populate the $_SERVER array on each request.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.