thankqwerty Posted August 21, 2008 Share Posted August 21, 2008 Hi I'm a beginner at writing website and everything. I have the following problem. I want to write a very simple page which the users will input their I.P. address using html form. And i can do that with the code below. <form action="update.php" method="post" > IP: <input type="text" name="IP" > <input type="submit" value="submit"> </form> Now i want it to have different default value. I know i can set a default value for the input box by : IP: <input type="text" name="IP" value="128.243.0.0"> But i don't know how to make the default IP as a variable. For example if i want the default value to be the user's IP. (I know i can get the user's IP with $_SERVER['REMOTE_ADDR']). Is there any way that i can define a string in php then call it in the input tag? Thank you. Link to comment https://forums.phpfreaks.com/topic/120742-html-form-with-different-pre-set-value/ Share on other sites More sharing options...
Dada78 Posted August 21, 2008 Share Posted August 21, 2008 Try this.... <form action="update.php" method="post" > IP: <input type="text" name="IP" value="<?php echo $ip=$_SERVER['REMOTE_ADDR']; ?>"> <input type="submit" value="submit"> </form> test example http://www.mesquitechristmas.com/development/form.php Keep in mind your file will need to be .php and not .html Link to comment https://forums.phpfreaks.com/topic/120742-html-form-with-different-pre-set-value/#findComment-622279 Share on other sites More sharing options...
thankqwerty Posted August 21, 2008 Author Share Posted August 21, 2008 Thanks a million didn't know i can use echo that way! Link to comment https://forums.phpfreaks.com/topic/120742-html-form-with-different-pre-set-value/#findComment-622309 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.