Ask a Question related to PHP Development, Design and Development.
-
Matthew Nicoll #1
form submit from PHP code
I am new to PHP, but am an experienced programmer.
I am having trouble understanding how to
transfer control from one php/html script
to another. I know how to let the user do it:
with links, and HTML form submits, but how do I
do it from PHP code?
e.g. if I am in script A.php , and I want script B.php to
fire up just as if it had been activated through a
form submit, with POST variables set, how do I
do it?
Matthew Nicoll
Matthew Nicoll Guest
-
Form does not submit in Mac
Hi all, I am using the submitForm() on my submit button. I have set the URL to "/Save.aspx" which will get the submitted information and doing... -
Need Help With Submit Form
I have DW 3 and designing my own site. I would like my customer to be able to fill out a form. I know how to create a form, I don't know how to get... -
Submit form
I am creating a control which will upload files. The problem I am having is the button event I have created does not seem to see the files getting... -
what in the code makes a .gif a submit button
How do I make a normal .gif into a submit button that will hold action? ie. <input type='submit' name='Submit' value='Submit'> when I put the src... -
Form Field/ Form Submit Problems (probably an easy answer...)
Hey Everyone.. I have a form that has approximately 7 text fields and 1 checkbox. Generally when this form is submitted(to itself BTW) it works... -
Janwillem Borleffs #2
Re: form submit from PHP code
Matthew Nicoll wrote:
Very basic question for which the answer can be found on php.net:> I am new to PHP, but am an experienced programmer.
> I am having trouble understanding how to
> transfer control from one php/html script
> to another. I know how to let the user do it:
> with links, and HTML form submits, but how do I
> do it from PHP code?
>
> e.g. if I am in script A.php , and I want script B.php to
> fire up just as if it had been activated through a
> form submit, with POST variables set, how do I
> do it?
>
A.php:
<html>
<body>
<form method="post" action="B.php">
Name:
<input type="text" name="name" />
<input type="submit" />
</form>
</body>
</html>
B.php:
<?
if (isset($_POST['name'])) {
print "Hello {$_POST['name']}";
}
?>
JW
Janwillem Borleffs Guest
-
Colin McKinnon #3
Re: form submit from PHP code
Matthew Nicoll spilled the following:
Short answer: you can't - PHP is a server-side language.>
> e.g. if I am in script A.php , and I want script B.php to
> fire up just as if it had been activated through a
> form submit, with POST variables set, how do I
> do it?
>
Longer answer: If you mean you want to simulate a submit of a form to
scriptB, then it's fairly easy to do with the file(...) function (assuming
URL wrappers are enabled) e.g.
$output=get("http://server.name.com/scriptB.php?param1=something¶m2=somethingelse" );
It's a bit more tricky to do a POST (AFAIK this is not supported directly by
PHP so you need to roll your own HTTP protocol handler and open and close
sockets from your PHP code. Acutally it's not that hard (even I can do it).
HTH
C.
Colin McKinnon Guest
-
Matthew Nicoll #4
Re: form submit from PHP code
Thanks Colin.
I was hoping I could mess with the values of <input type="hidden"...>
form variables after the submit button is clicked and before the form
action was invoked, by having the form action invoke an intermediary
php script. I don't fancy diving into HTTP protocol handlers just
now!
.... Matthew
On Sun, 05 Sep 2004 20:01:03 GMT, Colin McKinnon
<colin.thisisnotmysurname@ntlworld.deletemeunlessU RaBot.com> wrote:
>Matthew Nicoll spilled the following:
>>>>
>> e.g. if I am in script A.php , and I want script B.php to
>> fire up just as if it had been activated through a
>> form submit, with POST variables set, how do I
>> do it?
>>
>Short answer: you can't - PHP is a server-side language.
>
>Longer answer: If you mean you want to simulate a submit of a form to
>scriptB, then it's fairly easy to do with the file(...) function (assuming
>URL wrappers are enabled) e.g.
>$output=get("http://server.name.com/scriptB.php?param1=something¶m2=somethingelse" );
>
>It's a bit more tricky to do a POST (AFAIK this is not supported directly by
>PHP so you need to roll your own HTTP protocol handler and open and close
>sockets from your PHP code. Acutally it's not that hard (even I can do it).
>
>HTH
>
>C.
>Matthew Nicoll Guest
-
Manuel Lemos #5
Re: form submit from PHP code
Hello,
On 09/05/2004 06:12 PM, Matthew Nicoll wrote:If you want to alter the submitted form values, just change the $_POST> I was hoping I could mess with the values of <input type="hidden"...>
> form variables after the submit button is clicked and before the form
> action was invoked, by having the form action invoke an intermediary
> php script. I don't fancy diving into HTTP protocol handlers just
> now!
array values in the beggining of the script you want to alter.
If you want to alter the values and submit them another page, you may
want to try this HTTP client class. It lets you emulate form post
submission at will, including uploading files if necessary:
[url]http://www.phpclasses.org/httpclient[/url]
--
Regards,
Manuel Lemos
PHP Classes - Free ready to use OOP components written in PHP
[url]http://www.phpclasses.org/[/url]
PHP Reviews - Reviews of PHP books and other products
[url]http://www.phpclasses.org/reviews/[/url]
Metastorage - Data object relational mapping layer generator
[url]http://www.meta-language.net/metastorage.html[/url]
Manuel Lemos Guest
-
Janwillem Borleffs #6
Re: form submit from PHP code
Matthew Nicoll wrote:
Even if you would use the HTTP protocol handlers, all that you get is the> Thanks Colin.
> I was hoping I could mess with the values of <input type="hidden"...>
> form variables after the submit button is clicked and before the form
> action was invoked, by having the form action invoke an intermediary
> php script. I don't fancy diving into HTTP protocol handlers just
> now!
>
response from the other page on the page that applies them.
If you only want to change form values before submission, you could use
javascript or apply session vars to store (some keys/values of) the $_POST
array and unwrap them on the other page.
JW
Janwillem Borleffs Guest
-
Arg #7
Re: form submit from PHP code
Javascript is the way to go for this, I use it all the time on our Intranet
for form verification and to update hidden variables in a form.
The submitform script can be fired by any number of methods: onload,
onunload, onclick, onmouseover, onmousedown, onmouseout, etc.
<SCRIPT language="JavaScript">
var misses=0;
function submitform()
{
var nm = document.getElementById('val1').value;
if(nm==''){
misses++;
document.getElementById('val2').value='Failed to follow instructions
'+misses+' time(s)';
alert('You must enter a value');
}else{
document.myform.submit();
}
}
</SCRIPT>
<form name=myform method=post action=postit.php>
<input type=text id=val name=val1 size=50><br>
<input type=text id=val name=val2 size=50>
</form>
<input type=button onClick="submitform();" value="submit">
The submit button can be placed anywhere on the page and does not even have
to be a button, it could be text or an image, or just an area on the page
defined by a span or div. I code for IE on our intranet so if this does not
work in all browsers then you'll have to fix it. :)
"Matthew Nicoll" <menicoll@mars.ark.com> wrote in message
news:413b56a9.5267875@news.ark.com...>I am new to PHP, but am an experienced programmer.
> I am having trouble understanding how to
> transfer control from one php/html script
> to another. I know how to let the user do it:
> with links, and HTML form submits, but how do I
> do it from PHP code?
>
> e.g. if I am in script A.php , and I want script B.php to
> fire up just as if it had been activated through a
> form submit, with POST variables set, how do I
> do it?
>
> Matthew Nicoll
>
>
Arg Guest



Reply With Quote

