Jump to content

[SOLVED] Executing another php from a php


sd9sd

Recommended Posts

Hi,

I'm trying to execute a PHP file from another PHP file. I've tried writing my own code (below) but it didn't work. Also tried using the exec command, but couldn't get it to work.

Could I have some guidance of how to make it work/

 

Sender PHP (the 'done sending message' also has to work)

<?php
$hello="yo";
echo "sending message<br>";
echo "receiverPHP.php?hi=$hello";
echo "done sending message<br>";
?>

Receiver PHP

<?php
$mssg = $_POST['hi'];
echo "The message is $mssg<br>";
?>

Link to comment
https://forums.phpfreaks.com/topic/112534-solved-executing-another-php-from-a-php/
Share on other sites

no problem.

 

POST is used for forms.

 

example:

<form method="post" action="blah.php">
<input type="text" name="text">
<input type="submit" value="submit">
</form>

 

then in blah.php you can have this:

<?php
if(isset($_POST['text'])) {
echo $_POST['text'];
}
?>

 

GET can be used in forms and in the URL.

 

Example:

<a href="www.somewebsite.com/page.php?text=text">submit some text</a>

 

page.php:

<?php
if(isset($_GET['text'])) {
echo $_GET['text'];
}
?>

 

Also POST is used when you have a large amount of data to send to another page. GET is also used for things such as 'news' on your website or whatever so people are able to bookmark the page(bookmarking the exact news article by the GET in the URL).

 

Regards ACE

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.