Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.