Scripts sur Programmation PHP
One.com





Infomaniak : Hébergement de sites internet

PROFITEZ DE NOTRE RUBRIQUE
DE PETITES ANNONCES GRATUITES
PASSER UNE ANNONCE GRATUITEMENT
CONSULTEZ LES ANNONCES


PHP method Post - how to simulate input by hardcoding the url? I need to compile an URL that will work with a php script. The idea is to create something like: http://www.mysite.com/script.php?user=00?

that will pass the data to script.php same as post form.


Hello,

If you want to deal with POST you need to use the $_POST variable in PHP to deal with that. But if you want to deal with the URL you posted you need the GET request method since hte variables are naked to the eye not hidden.

The following example will help you do what you want:

script.php?user=0001&data=something
===============
// Check if user presses submit
if( isset( $_GET['submit'] ) )
{
// Grab the POST variables
$user = $_GET['user'];
$data = $_GET['data'];

// Print them to the screen
echo 'USER=> ', $user, '
DATA => ', $data;
}
else
{
// set the Action for the form to script.php
// set the Request for the form to GET
$output = '<form action="script.php" method="get">';
$output .= '<input name="user" type="text" />';
$output .= '<textarea name="data"></textarea>';
$output .= '<<input name="submit" type="submit" />';
$output .= '</form>';
echo $output;
}

=============

The above will first print the form to the screen, if you pressed submit, it will check if that variable exists ( by using isset), if that variable "submit" (which is the name of the input submit), it means the form has been submitted to script.php using the GET request method!

Then you can manipulate the data from there.

Good Luck

=========
EDIT:
======================================?

As you stated a web-enabled hardware device, if you are sure the request comes from a POST, then you cannot send the request with http://mysite.com/script.php?user=001& data=whatever , in whatever language your using, you will need to place the POST variables in the header for that request.

But if you want to send a GET request similar to the one you provided, your PHP page should have the following:

============
// Check the request has user and data as a GET req method
if( isset( $_GET['user']) && isset( $_GET['data'] ) )
{
// Grab the POST variables
$user = $_GET['user'];
$data = $_GET['data'];

echo 'USER=> ', $user, 'DATA => ', $data;
}
else
{
echo 'Request is empty';
}

============

I assume your doing an asynchronous call, and your doing something which is similar to REST Services, your web -enabled device will grab what is echoed.

I hope that solves your problem




PHP Scripts


PHP Scripts for developers and programmers both free and commercial.

PHP Script & Programs | Hot Scripts


PHP Script & Programs from Hot Scripts. PHP Scripts and Programs. Search Hot Scripts for largest selection of PHP Scripts for your website today.

Scripts Directory of PHP, ASP, ASP.NET, Java, Javascript, Perl and ...


Scripts Directory at Scripts.com is a collection of web resources aimed at internet programmers and developers. Scripts.com maintains a huge list of ready to use Scripts and ...

PHP Script Tutorials | Hot Scripts


PHP Script Tutorials from Hot Scripts. PHP is a programming language for dynamically built web sites. PHP used to stand for Personal Home Page. At Hot Scripts you can find the ...

php scripts - learn php programming and download original php scripts


Learn PHP Programming ... TDavid's PHP Diary updates: Using mktime and date function to skip dates and create simple calendar functions ...

Free Php Scripts | Php Scripts Index - PHP Scripts


php/MySQL Free Scripts Index ... Gscripts.net is a fast growing directory of free php Scripts such as php forums, php photo galleries, CMS, php e-commerce solutions and many other ...

PHP Scripts


SiteScripts is the web developers script portal, containing PHP scripts, ASP scripts, Javascripts and resources for web masters, web developers and programmers. SiteScripts ...

Free PHP Scripts - DBScripts.net


Free PHP scripts, tutorials, and other resources for webmasters. scripts include an anti-spam guestbook, a poll script, and an image gallery script.

PHP - Wikipedia, the free encyclopedia


PHP, or PHP: Hypertext Preprocessor, is a widely used, general-purpose scripting language that was originally designed for web development, to produce dynamic web pages.

The PHP Resource Index


Site with complete script, code snippets, documentation and other PHP related resources. In affiliation with cgi-resources.com Around 700 entries



INDEX /TAG :
Programmation PHP - Samples - School - Script - Scripts - Scripts php - Serveur - Service - Services - Sms - Soap - Sondage - Source code - Sql - Statistiques - Stats - Succés de php - Succés du php - Sur - strncmp - Symfony - Strings - String - Sqlite - Sql - Spam - Sources - Solutions - Site - Simple - Sessions - Services - Serveur - Server - Scripts php - Scripts - Script -

Vous pouvez également consulter le guide pratique scripts qui vous proposera de nombreuses autres informations pratique concernant votre recherche surscripts