Run command - wonderful

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
pronetin
Forum Newbie
Posts: 1
Joined: Sat Feb 26, 2011 2:09 pm

Run command - wonderful

Post 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:
Joxer
Forum Newbie
Posts: 7
Joined: Wed Feb 23, 2011 11:12 pm

Re: Run command - wonderful

Post by Joxer »

What does the code you posted above have to do with running wget?
What are you trying to accomplish?
LordXzi
Forum Newbie
Posts: 7
Joined: Sat Feb 26, 2011 5:29 pm
Location: Reading, UK

Re: Run command - wonderful

Post 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.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Run command - wonderful

Post 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.
Post Reply