platypus
platypus

Reputation: 706

Sending message without input elements

I want to send a feedback message from one page to another without using input elements via POST method. Is that possible? Or is there other way around?

What i want is applying a value from one page to another page's variable.

i.e.: Sending "Yaba Daba Doo" string from 1.php to 2.php's variable, named $info.

1.php:

<?php
$info = "Yaba Daba Doo";
?>

2.php

<?php
$variable=$_POST['info'];
echo "The message is:".variable;
?>

How can i pass info variable to 2.php using POST method, without input elements?

Upvotes: 1

Views: 1017

Answers (3)

Ashwini Dhekane
Ashwini Dhekane

Reputation: 2290

you can use php curl to make a post request to 2.php from 1.php

Upvotes: 0

Shakti Singh
Shakti Singh

Reputation: 86476

You can use session variable to store data on server and access across the pages of your application.

If you want a secure way to send this variable you can use session so that end user can not see it An example

page1.php
session_start();
$_SESSION['mes']=$info;

page2.php

session_start();
echo $_SESSION['mes'];

And the another way is to pass variable in GET which I will not recommend user can see the value of your input variable

Upvotes: 3

Mark Mooibroek
Mark Mooibroek

Reputation: 7706

Use a session to store your data, then when ever you want to store is call upon the $_SESSION global.

Here is more info about sessions:
php.net
W3schools
Tutorial

Upvotes: 1

Related Questions