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
Share on other sites

Thanks interpim...but it doesn't work. The receiver file doesn't print out the hello word.

 

you have $_POST['hi'];

 

are you trying to send data from 1 php file to the other so the second php file can run some tasks with the POST ?

Yes.

Link to comment
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

Link to comment
Share on other sites

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.