Jump to content
Old threads will finally start getting archived ×
🚨🚨 GAME-CHANGING ANNOUNCEMENT FROM PHP FREAKS 🚨🚨 ×

auto submit form on page load


Perplexity 🤖

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
https://forums.phpfreaks.com/topic/65997-auto-submit-form-on-page-load/
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]

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.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.