Hi Everyone,
I'm new and i'm looking for a solution for my problem.
There is an external website returning a value after the compilation of a two inputs form. I want to catch the page sending a value in my PHP page.
My purpose is to verify if the external website says "true" or "false" to a request. I have already created something like that for GET results checking every word of the external page in order to find "True" or "false".
How can i do the same thing with a POST request?

...And (another request) how can i do the same thing with a form that use SESSIONS where it saves the fields of the form?

Thanks in advance and sorry for my "english" (i'm italian ;) )

If you want to use POST instead of GET, you form needs to be set to method="POST" and when you are capturing the data on the other side you need to use something like the following.

<?PHP

$somevar = $_POST['name'];

print " Hi my name is $somevar";

// If the user entered their name as Leviathan185 it would print 
// Hi my name is Leviathan185

?>

Sessions are a little different. Iu use them a little like this:

<?php
session_start(); //needs to be called before you set or call any session variables.

if(username and password are correct) {
        $_SESSION['auth'] = "yes";
} esle {
        session_destroy();
        print " username and password incorrect";
}

// in your next page you would have session_start(); and something to the effect of:

if(!isset($_SESSION['auth'])) { // notice the ! at the start meaning not set
       // take user to login screen
} esle {
        // user can continue with ccurrent script
}

There may be a better way but I have only been learning for about 2 months myself. but it should be a start for you.

The problem is that this variables ($_POST and $_SESSION) are from an external website.. I want to create a script compiling that form in order to have the result page of this external site... In this way i can analyse the result page of this external website...
For $_POST somebody told me tu use CURL function... How?
And for $_SESSION??
Thanks

Sorry mate i am at a loss then :-(

use cURL, the documentation on php.net is pretty good

use cURL, the documentation on php.net is pretty good

I used curl and this is my function:

function doPost($number) {
	$post_data = "&num_tel=023774657";

	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, "http://www.siadsl.it/verifica_adsl/copertura_adsl.asp?AR=2" );
	curl_setopt($ch, CURLOPT_POST, 1 );
	curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	$postResult = curl_exec($ch);

	if (curl_errno($ch)) {
		print curl_error($ch);
	}
	curl_close($ch);
	print $postResult; }

For example i tried with the form of this page: http://www.siadsl.it/verifica_adsl/copertura_adsl.asp?AR=2
Why my function doesn't work?
It returns the page with the form not submitted. Why?!

Thanks for your help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.