NEED HELP ASAP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

NEED HELP ASAP

Post by nickman013 »

Hello,

I need help getting an IP Address.

I have a HTML form and I would like the person who is visiting the page's IP Address in a text area. I cannot get the PHP to work though, I put the tags and closed them. This is my script.

Code: Select all

<FORM METHOD="POST" ACTION="feedback.php3">
Name: &nbsp;&nbsp;&nbsp;<INPUT TYPE="text" NAME="name" SIZE="30"><br>
Comments: <TEXTAREA NAME="comments" ROWS=6 COLS=30>
</TEXTAREA><br>
IP: <textarea name="ip" rows="1" cols="20" readonly>
<? 
$ip = $_SERVER['REMOTE_ADDR'];
?>
</textarea>
<br>
<INPUT TYPE="submit">
<INPUT TYPE="reset">
</form>
Any help would be great. Thanks!
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

Check out the server variable

Code: Select all

echo '<HR><PRE>'; print_r($_SERVER); echo '</PRE>';
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

Sorry, didn't read the whole post.....

Code: Select all

<FORM METHOD="POST" ACTION="feedback.php3">
Name: &nbsp;&nbsp;&nbsp;<INPUT TYPE="text" NAME="name" SIZE="30"><br>
Comments: <TEXTAREA NAME="comments" ROWS=6 COLS=30>
</TEXTAREA><br>
IP: <textarea name="ip" rows="1" cols="20" readonly>
<?
$ip = $_SERVER['REMOTE_ADDR'];
?>
</textarea>
<br>
<INPUT TYPE="submit">
<INPUT TYPE="reset">
</form>
echo out

Code: Select all

echo $_SERVER['REMOTE_ADDR'];
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Post by nickman013 »

What do you mean by echo out.

Thank you for your help!
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

replace

Code: Select all

<?
$ip = $_SERVER['REMOTE_ADDR']; 
?>
with:

Code: Select all

<?php
echo $_SERVER['REMOTE_ADDR'];
?>
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Post by nickman013 »

Thank You both for helping me, It works!
Post Reply