Board index   FAQ   Search  
Register  Login
Board index PHP PHP General

cat random file on the server (total n00b)

General discussions related to php

Moderators: macek, egami, gesf

cat random file on the server (total n00b)

Postby then00b » Tue Aug 14, 2012 5:56 am

Hi all :)

I'm running apache2 webserver on Ubuntu machine. I want to do something like this example but when the button is pressed instead of displaying the date I want to (for example) to cat some file from the server (like: cat /proc/version).

I did something like this (index.php content):
Code: Select all
<?php
echo exec('cat /proc/version');
?>
<form action="index.php" method="post">
<input type="submit" value="go!"/>
</form>


1: the above works but is this a correct way to do this kind of stuff? It's like a loop...

2: when I click button "go!" a new page is loaded. How can I avoid this? Is there a way to do this like in the example in w3c above? I mean to have the result displayed on the same page...

3: if I have two files HTML and PHP and the HTML uses form to submit request to the server (PHP part) how to obtain the data from the PHP part in the HTML? In this case the value of "/proc/version"? Something like call PHP function and get the return result in HTML (don't know if I can explain it better...).


Of course I Googled it a bit but can't find what I want :(

Obviously I'm really not in the web development so excuse my really stupid questions :(
Pleas explain like I'm an idiot :)
then00b
New php-forum User
New php-forum User
 
Posts: 1
Joined: Tue Aug 14, 2012 5:34 am

Return to PHP General

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron