What would be the use of it? No user had a chance to enter data, so it must be you to prefill the form. The data for prefilling are already known to you, so why send them?
Btw - you can call the function in your body tag:
<body onload="submitForm()">
This would only work (using the code of your function), if the name attribute of your form is name="form"...
Cheers - Pit
Edit: sorry, when pasting your function call, I grabbed a "{" which had to be removed...
Hey guys, hope you don't mind me jumping on the back of your little discussion there- however long ago it might have been!
In answer to Pittiman's question:
"What would be the use of it? No user had a chance to enter data, so it must be you to prefill the form. The data for prefilling are already known to you, so why send them?"
...my response is this:
I'm using a thrid-party web-service for auto-response e-mail and newsletter services.
Normally a user enters their info into a form and clicks submit. This gets sent to the third-party who send my user back to my site to a pre-defined landing page set by me (i.e.
Code:
thankyou.php
)
Thing is, I'm trying to take my data-collection to another level!
I have a new-user registration form, part of which is the classic 'Tick here to get our newsletter'
When they submit the form, all of their data is inserted into MY database for my use for everything my web-system is doing, but if 'optIN' is set to 1, I send them to an invisible page that sends their name and e-mail to the third-party, who then sends the usr back invisibly... nice!
For anyone who wants it, my invisible auto-submitted form looks like this:
PHP Code:
<?
// initialise the session:
session_start();
// I set $_session['optIn'] when they first entered their info,
// as well as email and names (see below)
// ...I call it now!
if (($_SESSION['optIn']==0)||(!isset($_SESSION['optIn'])))
{
// user requested to NOT be added to the newsletter
// send them to the page the 3rd-party service provider sends them to:
header("Location: editPersonal.php");
}
else {
// run the page!
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>You're Not Gonna See This!</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body onload="submitForm()">
<form method="post" action="http://www.thirdPartyServiceProvider.whatever" name="myForm" id="myForm">
<!--
IMPORANT NOTE: DO NOT re-name the form- it is called by the name 'myForm'!
-->
<input type="hidden" name="whatever" value="1234" />
<input type="hidden" name="redirect" value="http://www.backtomysite.com/editPersonal.php" />
<input type="hidden" name="meta_required" value="from,name" />
<input type="hidden" name="meta_forward_vars" value="0" />
<input type="hidden" name="name" value="<? echo $_SESSION['firstname']; ?><? echo $_SESSION['lastname']; ?>" />
<input type="hidden" name="from" value="<? echo $_SESSION['email']; ?>" />
</form>
<!-- now send the form! -->
<script type='text/javascript'>document.myForm.submit();</script>
</body>
</html>
<?
}
?>
Hey guys I saw your thread in online without being a member of the forum but the replies were so good that I had to sign up and thank you for the information. Thanks for the script COOS the scenario you described is almost exactly the same as mine.
Here is a working auto-submit method: when page is loaded, it will the form will be immediately autosubmited (the values can be inserted with php variables).
Please administrator, delete my above posts, and leave this current one:
Here is a working auto-submit method: when page is loaded, it will the form will be immediately autosubmited (the values can be set with php variables).
for example, the $_POST['something1'] value is received from the previous real-user submited Form, and this form can add another input with ANOTHER_YOUR_VALUE.
Bookmarks