473,396 Members | 1,770 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

About "posting" forms


Is it possible to use the post method to send a form from PHP without
having to put the form in a html page?

<form action="https://www.mysite.com/cgi/incoming.php" method="post">
<input type="hidden" name="data01" value="12">
<input type="hidden" name="data02" value="rejected">
<input type="hidden" name="star" value="sirius">
<input type="image" src="https://www.mysite.com/grid001/image1.gif"
border="0" name="submit" alt="send data">
</form>

What I would like to do is make the use of this form as invisible to the
user as possible by

1. getting rid of the image (but then how do I "post" it)
2. putting PHP variables into the value fields
3. send the form

The PHP variables are set up as in
$data01 = 12;
$data02 = 'rejected'
etc
then

after just including it as in "include_once('senddata.php'); the form
above is in senddata.php and just gets posted

I've been looking at this and can't see how without having to include the
form on a html page. I looked at document.write but that again is
javascript.

Can this be done with just PHP?

thanks

tony
Jun 7 '06 #1
6 1641
to**@tony.com wrote:
Is it possible to use the post method to send a form from PHP without
having to put the form in a html page?

<form action="https://www.mysite.com/cgi/incoming.php" method="post">
<input type="hidden" name="data01" value="12">
<input type="hidden" name="data02" value="rejected">
<input type="hidden" name="star" value="sirius">
<input type="image" src="https://www.mysite.com/grid001/image1.gif"
border="0" name="submit" alt="send data">
</form>

What I would like to do is make the use of this form as invisible to the
user as possible by

1. getting rid of the image (but then how do I "post" it)
2. putting PHP variables into the value fields
3. send the form

The PHP variables are set up as in
$data01 = 12;
$data02 = 'rejected'
etc
then

after just including it as in "include_once('senddata.php'); the form
above is in senddata.php and just gets posted

I've been looking at this and can't see how without having to include the
form on a html page. I looked at document.write but that again is
javascript.

Can this be done with just PHP?

thanks

tony


Tony,

A form is an html construct - so not being in an html page is meaningless.

Maybe if you tell us exactly what you're trying to accomplish we can give you
other ideas.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jun 7 '06 #2
to**@tony.com wrote:
Is it possible to use the post method to send a form from PHP without
having to put the form in a html page?

<form action="https://www.mysite.com/cgi/incoming.php" method="post">
<input type="hidden" name="data01" value="12">
<input type="hidden" name="data02" value="rejected">
<input type="hidden" name="star" value="sirius">
<input type="image" src="https://www.mysite.com/grid001/image1.gif"
border="0" name="submit" alt="send data">
</form>

What I would like to do is make the use of this form as invisible to
the user as possible by

1. getting rid of the image (but then how do I "post" it)
2. putting PHP variables into the value fields
3. send the form

The PHP variables are set up as in
$data01 = 12;
$data02 = 'rejected'
etc
then

after just including it as in "include_once('senddata.php'); the form
above is in senddata.php and just gets posted

I've been looking at this and can't see how without having to include
the form on a html page. I looked at document.write but that again is
javascript.

Can this be done with just PHP?

thanks

tony


The POST method is used to send data from a web page to the server so that
you can use it in things like php variables.
You don't need an image or even a button to submit a form. A text input box
will work to submit a form just by pressing the enter key.
What you need to do is to explain what you ultimately want to happen.
Jun 7 '06 #3
Tom

<to**@tony.com> wrote in message
news:MP************************@news-text.blueyonder.co.uk...

Is it possible to use the post method to send a form from PHP without
having to put the form in a html page?


Unless I've failed to understand what you're after, you could use the CURL
library.
It allows you to call any web page (not necessarily a PHP page) from within
your PHP.
Make sure the "extension=php_curl.dll" is uncommented in your PHP.ini.

Something like this (which uses buffering to stop the returned web page
being displayed)...
ob_start();
$ch = curl_init('https://www.mysite.com/cgi/incoming.php');
curl_setopt( $ch, CURLOPT_POST, true );
curl_setopt( $ch, CURLOPT_POSTFIELDS, 'data01=12&data02=rejected');
curl_exec($ch);
$getinfo_results = curl_getinfo($ch);
curl_close( $ch );
$return_page = ob_get_contents();
ob_end_clean();

"$getinfo_results" will give an array of information telling you if the page
request was successful or not, and "$return_page" will contain the full HTML
of the request.

Tom
Jun 7 '06 #4
In article <4e*************@individual.net>, pa**********@btinternet.com
says...
to**@tony.com wrote:
Is it possible to use the post method to send a form from PHP without
having to put the form in a html page?

<form action="https://www.mysite.com/cgi/incoming.php" method="post">
What you need to do is to explain what you ultimately want to happen.


I'm sorry I assumed you could see what I want to do by looking at the
form action I posted

I want to send the data to another web server as if it had been posted
using the forms post method without having the form appear in the source
of the clients web page.

Looking at it another way I want to "post" the data without using the
form but it MUST be using the "post" method because thats how the
reciever is set up and I cant control that.

I already have the data I just want to use the post method to send it
without the client getting it as well.

I hope that explains it - I can't think of a way to say it any clearer.

tony


Jun 8 '06 #5
In article <44***********************@ptn-nntp-reader01.plus.net>,
to**************@ETHISgmail.com says...

<to**@tony.com> wrote in message
news:MP************************@news-text.blueyonder.co.uk...

Is it possible to use the post method to send a form from PHP without
having to put the form in a html page?


Unless I've failed to understand what you're after, you could use the CURL
library.
It allows you to call any web page (not necessarily a PHP page) from within
your PHP.
Make sure the "extension=php_curl.dll" is uncommented in your PHP.ini.

Something like this (which uses buffering to stop the returned web page
being displayed)...
ob_start();
$ch = curl_init('https://www.mysite.com/cgi/incoming.php');
curl_setopt( $ch, CURLOPT_POST, true );
curl_setopt( $ch, CURLOPT_POSTFIELDS, 'data01=12&data02=rejected');
curl_exec($ch);
$getinfo_results = curl_getinfo($ch);
curl_close( $ch );
$return_page = ob_get_contents();
ob_end_clean();

"$getinfo_results" will give an array of information telling you if the page
request was successful or not, and "$return_page" will contain the full HTML
of the request.

Tom


Hi Tom - I think you do get the idea (from your buffering comment)
I've never heard of curl (I'm just getting over wasting loads of my time
with that pear rubbish)

I'll take a look at curl (assuming my service provider allows its use -
these people are very daft about what they do and dont allow sometimes)

thanks for the idea

tony
Jun 8 '06 #6

It turns out that you can use the Post method to send data as if it came
from a form easy enough - no other libraries etc are needed.

Just create a php script that writes a "POST" header then url encode what
would have been the form items names and values as the body and then use
PHP's fsockopen to send the data.

The remote end thinks it came from a form which is exactly what I needed.

Hope this helps anyone reading this.

tony
Jun 12 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: | last post by:
so i am using Dreamweaver; and I need to be able to have multiple pages post to a page called page6_1.asp from there; i give people the ability to either '1 - save definition as new report'; '2...
32
by: Indrid Colt | last post by:
Thank's for your help ! Indrid
26
by: Chris Potter | last post by:
Hello everyone. I am taking my first course in C and in one of my assignments i need to print out an array that could have anywhere from 0 to 100 positive integers in it (a negative integer is...
3
by: C# Learner | last post by:
I'm working on an app which uses a background thread to read data from a socket. At the moment I'm doing something a bit "naughty" -- I'm firing an event after reading from the socket, and this...
7
by: lintolawrance | last post by:
hello, i am a student trying to learn php.i have a doubt about a sentence written in the textbook.the sentence is "upload the file to your web server", for that what i have to done.
3
by: jpa770 | last post by:
3 employee's will be responsible for installing and maintaining IBM product set to include but not limited to Tivoli Access Manager 6.0, IBM Websphere Application Server, IBM MQ Server, and IBM DB2...
7
by: Abhinay | last post by:
hi, sorry for asking this question in this forum, but i did't found any contact of concern person. My que is still unanswered so i wanted to post a message to my thread as per Posting...
4
by: webandwe | last post by:
Hi I have a field box that will be used for GPS co-ordinates. But the " and ' mess my mysql query up. My code work like this. $a1=$_POST; query = "INSERT INTO information VALUES...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.