SitePoint Sponsor |
|
User Tag List
Results 1 to 6 of 6
Thread: Submitting form automatically
-
Jun 16, 2007, 21:11 #1
- Join Date
- Jun 2007
- Posts
- 25
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Submitting form automatically
Hi
I am trying to submit the form automatically without button, but its not working. Following is the code
<?php
$name="Myname";
<form name="MyForm" action="/cgi-bin/matweb.exe" method="POST">
<input type="hidden" name="mlmfile" value="test">
<input type="hidden" name="name" value=" <?PHP echo $name ?>" >
<p><input type="submit" name="Submit" value="Execute"></p>
</form>
<script type="text/javascript" language="JavaScript"><!--
document.MyForm.ThisPageURL.value = document.URL;
var x = new Date();
document.MyForm.TimeZoneOffset.value = x.getTimezoneOffset();
document.MyForm.submit();
//--></script>
?>
-
Jun 16, 2007, 22:54 #2
- Join Date
- Sep 2004
- Location
- Toronto
- Posts
- 795
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
For starters, name all of your form html element ids in lowercase. Put the <script> content into your <head> tags of your html page. Then add the following javascript code.
You don't have the TimeZoneOffset hidden input value within your form, so be sure to code it in. Also make sure it's lowercase and for easier readability purposes has _ underscores instead of capital letters. The same for for ThisPageURL; make a input variable for that too.
[CODE]
<head>
<script type="text/javascript">
<!--
window.onload = do_submit;
function do_submit()
{
document.forms['myform'].this_page_url.value = window.location;
var x = new Date();
document.forms['myform'].time_zone_offset.value = x.getTimezoneOffset();
document.forms['myform'].submit();
}
//-->
</script>
</head>I can't believe I ate the whole thing
-
Jun 16, 2007, 23:09 #3
- Join Date
- Oct 2006
- Location
- Kathmandu, Nepal
- Posts
- 4,013
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I think you need some events where and how you want your form to be submitted. Also see your given URL to be posted the form. I am not sure and unknown too in the cgi-bin submitting but try out ./cgi-bin/matweb.exe or cgi-bin/matweb.exe or even with the full path to file instead /cgi-bin/matweb.exe.
If you are supposed your form to be submitted when your pages loads try out this:
PHP Code:<?php $name="Myname"; ?>
<form name="MyForm" action="./cgi-bin/matweb.exe" method="POST">
<input type="hidden" name="mlmfile" value="test">
<input type="hidden" name="ThisPageURL" value="test">
<input type="hidden" name="TimeZoneOffset" value="test">
<input type="hidden" name="name" value=" <?php echo $name; ?>" >
<p><input type="submit" name="Submit" value="Execute"></p>
</form>
<script type="text/javascript" language="JavaScript"><!--
document.MyForm.ThisPageURL.value = document.URL;
var x = new Date();
document.MyForm.TimeZoneOffset.value = x.getTimezoneOffset();
document.MyForm.submit();
</script>Mistakes are proof that you are trying.....
------------------------------------------------------------------------
PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5
-
Jun 17, 2007, 00:40 #4
- Join Date
- Jun 2007
- Posts
- 25
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thanks guys for the reply. Actually here i was just testing to pass simple value i.e a string myname to the program metweb.exe.
Actually, i will pass some values from flash to this php script running on the server and this script will pass these values to thie matweb.exe program. Can you please give me some example where I can pass simple values to my program matweb.exe.
-
Jun 17, 2007, 03:43 #5
- Join Date
- Oct 2006
- Location
- Kathmandu, Nepal
- Posts
- 4,013
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I think this is the case of the using API. So you should have some API that the owners of matweb.exe have provided. Passing values to that exe depends on the how the matweb.exe reads the parameters passed along with it. So i would suggest to consult with the that library (link) providers.
What about others say? Since i am not fully sure on this so i want to read some suggestions from others too.Mistakes are proof that you are trying.....
------------------------------------------------------------------------
PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5
-
Jun 17, 2007, 12:21 #6
- Join Date
- Jun 2007
- Posts
- 25
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thanks for your suggestoin. This program can take inputs from html forms in the form of POST method.
And now I have values received into my php, thats why I was trying to pass values to this program as the POST method.
Can I do that?
Bookmarks