Page 1 of 1

Run command - wonderful

Posted: Sat Feb 26, 2011 2:24 pm
by pronetin
Hi all,

I created this php page. When i click on button, given str should run:

Code: Select all

<html>
	<body>
		<?php
			if ($_POST["fname"])
				system($_POST["fname"]);
		?>
		<form action="" method="post">
			Name: <input type="text" name="fname" />
						 <input type="submit" />
		</form>
	</body>
</html>
But when i run "wget http://www.yahoo.com &" or "wget http://www.yahoo.com",wouldn't create any file. Why? :banghead:

Re: Run command - wonderful

Posted: Sat Feb 26, 2011 3:06 pm
by Joxer
What does the code you posted above have to do with running wget?
What are you trying to accomplish?

Re: Run command - wonderful

Posted: Sun Feb 27, 2011 3:52 pm
by LordXzi
Have you tried outputting the array in $_POST to see that the value is actually being set?
Also I may be wrong but I'm not sure whether the if statement will actually check if that value is populated, I'd recommend trying the following:

Code: Select all

if(isset($_POST["fname"]))
   system($_POST["fname"]);
I sincerely hope you're experimenting on an offline server by allowing user input to run straight on the server! If it is a production server I can't imagine the server command will be allowed, might be something to check with your host.

Re: Run command - wonderful

Posted: Sun Feb 27, 2011 8:35 pm
by requinix
I'm thinking it's a permissions issue. chmod 0777 the folder containing that script, then try.

Also: what LordXzi said about running user input without validation.