Jump to content

auto submit form on page load


bradkenyon

Recommended Posts

i have a cronjob to run a php file at a certain time of the day.

 

it originally was suppose to run the php mail function, easy enough, right?? but no, the php mail function is not enabled on the server - just my luck.

 

all i need to do is send two values from a database table within an email.

 

i was thinking, i could probably create a form which plugs the two values into fields, and use the mail cgi file to send it that way, but I'd need to submit the form on page load (without someone actually clicking the submit button). I could use javascript, but the cronjob would ignore the javascript.

 

any ideas?

Link to comment
Share on other sites

Try this.

<html>
<head>
<script type="text/javascript">
function submit(form){
document.form.submit();
}
</script>
</head>
<body onLoad="javascript:submit(myForm)">
<form action="script.php" method="post" name="myForm">
Name: <input type="text" name="Name" value="Predefined"/>
Password: <input type="text" name="Password" value="Predefined"/>
<input type="submit" name="submit"/>
</form>
</body>
</html>/code]

Link to comment
Share on other sites

Actually, I don't think the form tag has the onLoad event. NArc0t1c's code should work, though it seems a unnecessarily indepth. Wouldn't this work?

<body onLoad="myForm.submit()">
<form name="myForm">
...

 

Mine is a little bit long..

Yes your's would also work.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.