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
nickman013
Forum Regular
Posts: 764 Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York
Post
by nickman013 » Thu Nov 24, 2005 2:27 am
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: <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!
hawleyjr
BeerMod
Posts: 2170 Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA
Post
by hawleyjr » Thu Nov 24, 2005 2:53 am
Check out the server variable
Code: Select all
echo '<HR><PRE>'; print_r($_SERVER); echo '</PRE>';
hawleyjr
BeerMod
Posts: 2170 Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA
Post
by hawleyjr » Thu Nov 24, 2005 2:58 am
Sorry, didn't read the whole post.....
Code: Select all
<FORM METHOD="POST" ACTION="feedback.php3">
Name: <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
nickman013
Forum Regular
Posts: 764 Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York
Post
by nickman013 » Thu Nov 24, 2005 3:05 am
What do you mean by echo out.
Thank you for your help!
Jenk
DevNet Master
Posts: 3587 Joined: Mon Sep 19, 2005 6:24 am
Location: London
Post
by Jenk » Thu Nov 24, 2005 4:39 am
replace
Code: Select all
<?
$ip = $_SERVER['REMOTE_ADDR'];
?>
with:
Code: Select all
<?php
echo $_SERVER['REMOTE_ADDR'];
?>
nickman013
Forum Regular
Posts: 764 Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York
Post
by nickman013 » Thu Nov 24, 2005 10:46 am
Thank You both for helping me, It works!