Jump to content


Photo

PHP variable within a form


  • Please log in to reply
4 replies to this topic

#1 pacman99

pacman99
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 29 April 2006 - 05:02 PM

Hi,
I'm not sure this is possible and I'm no expert php programmer so hopefully this question isn't too stupid.

Basically what I want to do is use a php variable within a form.

<form>
<input type="hidden" name="blah" value=(PHPVARIABLEHERE) > 
</form>

the PHP variable i'm trying to use is PHP_AUTH_USER and PHP_AUTH_PW but not sure how to go about doing it? If I use
value=<?php $_SERVER['PHP_AUTH_USER'] ?>
it doesn't work.

Any ideas?

Basically i'm trying to get the username and password data from the server (used to access the page using .htaccess) and implementing it so it automatically logs someone into the phpBB2 forum I have.

Thanks~

#2 Hooker

Hooker
  • Members
  • PipPipPip
  • Advanced Member
  • 193 posts
  • LocationWales, UK

Posted 29 April 2006 - 05:36 PM

value=<?php echo $_SERVER['PHP_AUTH_USER'];  ?>


#3 pacman99

pacman99
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 30 April 2006 - 01:14 AM

^the textbox ends up saying
<?php
when I put that.

<input type="text" class="post" name="username" value=<?php echo $_SERVER['PHP_AUTH_USER']; ?>
This is what i'm putting.

#4 michaellunsford

michaellunsford
  • Members
  • PipPipPip
  • Advanced Member
  • 1,023 posts
  • LocationLouisiana, USA

Posted 30 April 2006 - 01:26 AM

sounds like your web host has PHP turned off on your account. That, or your file is named with the ".html" extension instead of ".php"

#5 pacman99

pacman99
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 30 April 2006 - 04:40 AM

[!--quoteo(post=370002:date=Apr 29 2006, 09:26 PM:name=michaellunsford)--][div class=\'quotetop\']QUOTE(michaellunsford @ Apr 29 2006, 09:26 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
sounds like your web host has PHP turned off on your account. That, or your file is named with the ".html" extension instead of ".php"
[/quote]

nevermind, hooker's code works fine. Thanks a lot. Just a minor stupid error on my part (I named the file with an .html extension rather than php...yep that was stupid)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users