MadnessRed Posted May 5, 2008 Share Posted May 5, 2008 I am sure this is possible. anyway my first script <?php $ip=$_SERVER['REMOTE_ADDR']; $victor=xxx.xxx.x.x $bella=xxx.xxx.x.x $matt=xxx.xxx.x.x $anthony=xxx.xxx.x.x if ($ip=$anthony) echo "Anthony"; elseif ($ip=$victory) echo "Victor"; elseif ($ip=$bella) echo "Bella"; elseif ($ip=$matt) echo "Matt"; else echo $ip; ?> <?php $myFile = $_GET["account"] . ".txt"; $fh = fopen($myFile, 'w') or die("Sorry, I messed up somewhere"); $stringData = "**~**"; fwrite($fh, $stringData); fclose($fh); ?> where it says **~** I want to add the first scripts output? How would I do that. Also is this script error free. Also I am sure that this is very open for hackers but as you can probably tell its just a simple script for a few friends where no-one will see it apart from us. Thanks Anthony Link to comment https://forums.phpfreaks.com/topic/104275-have-1-php-script-as-a-variable/ Share on other sites More sharing options...
DarkWater Posted May 5, 2008 Share Posted May 5, 2008 Don't echo it, just store it in a variable and use sessions. Link to comment https://forums.phpfreaks.com/topic/104275-have-1-php-script-as-a-variable/#findComment-533819 Share on other sites More sharing options...
GameYin Posted May 5, 2008 Share Posted May 5, 2008 <?php $ip=$_SERVER['REMOTE_ADDR']; $victor=xxx.xxx.x.x $bella=xxx.xxx.x.x $matt=xxx.xxx.x.x $anthony=xxx.xxx.x.x if ($ip=$anthony) echo "Anthony"; elseif ($ip=$victory) echo "Victor"; elseif ($ip=$bella) echo "Bella"; elseif ($ip=$matt) echo "Matt"; else echo $ip; ?> To <?php $ip=$_SERVER['REMOTE_ADDR']; $victor=xxx.xxx.x.x; $bella=xxx.xxx.x.x; $matt=xxx.xxx.x.x; $anthony=xxx.xxx.x.x; if ($ip=$anthony) { echo "Anthony"; } elseif ($ip=$victory) { echo "Victor"; } elseif ($ip=$bella) { echo "Bella"; } elseif ($ip=$matt) { echo "Matt";} else { echo $ip;} ?> Ha beat anyone else to it Link to comment https://forums.phpfreaks.com/topic/104275-have-1-php-script-as-a-variable/#findComment-533822 Share on other sites More sharing options...
benphp Posted May 5, 2008 Share Posted May 5, 2008 <?php $ip=$_SERVER['REMOTE_ADDR']; $victor=192.168.1.1; $bella=192.168.1.2; $matt=192.168.1.3; $anthony=192.168.1.4; if ($ip==$anthony) { $ipName = "Anthony"; } elseif ($ip == $victory) { $ipName = echo "Victor"; } elseif ($ip == $bella) { $ipName = "Bella"; } elseif ($ip == $matt) { $ipName = "Matt"; } else { $ipName = $ip; } $myFile = $_GET["account"] . ".txt"; $fh = fopen($myFile, 'w') or die("Sorry, I messed up somewhere"); $stringData = "$ipName"; fwrite($fh, $stringData); fclose($fh); ?> Link to comment https://forums.phpfreaks.com/topic/104275-have-1-php-script-as-a-variable/#findComment-533825 Share on other sites More sharing options...
MadnessRed Posted May 5, 2008 Author Share Posted May 5, 2008 thansk everyone $myFile = $_GET["account"] . ".txt"; is that line ok? Link to comment https://forums.phpfreaks.com/topic/104275-have-1-php-script-as-a-variable/#findComment-533852 Share on other sites More sharing options...
trq Posted May 5, 2008 Share Posted May 5, 2008 A simpler solution. <?php $users = array( '192.168.1.1' => 'victor', '192.168.1.2' => 'bella', '192.168.1.3' => 'matt', '192.168.1.4' => 'anthony' ); if (array_key_exists($_SERVER['REMOTE_ADDR'],$users)) { $myFile = $_GET["account"] . ".txt"; $fh = fopen($myFile, 'w') or die("Sorry, I messed up somewhere"); fwrite($fh, $users[$_SERVER['REMOTE_ADDR']]); fclose($fh); } ?> Link to comment https://forums.phpfreaks.com/topic/104275-have-1-php-script-as-a-variable/#findComment-533856 Share on other sites More sharing options...
trq Posted May 5, 2008 Share Posted May 5, 2008 thansk everyone $myFile = $_GET["account"] . ".txt"; is that line ok? There is nothing syntactically wrong with it. Link to comment https://forums.phpfreaks.com/topic/104275-have-1-php-script-as-a-variable/#findComment-533858 Share on other sites More sharing options...
MadnessRed Posted May 6, 2008 Author Share Posted May 6, 2008 way, good, that was the bit that I was unsure about mainly. thanks everyone Link to comment https://forums.phpfreaks.com/topic/104275-have-1-php-script-as-a-variable/#findComment-534379 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.