agregoire Posted March 22, 2009 Share Posted March 22, 2009 I am a new php user and am having troubles with my php mail function. My page is an employee hour submit page, it uses an html form to get the input, submits the form to itself and to an error checking function after pressing submit. Then the page displays the information just entered and displays another button at the bottom of the page. The idea is that when they press the 2nd button the form information will then be emailed to the appropriate user. My mail function works fine when it is not in the function, but that doesn't work for me because i need the user to double check their information, and then send. //button with html link to finish page (html link works but the sendMail() function does not) <a href="employee_hours_finish.php"><button type="submit" name="button2" id="button2" onclick="<?php sendMail() ?>">Send Hours</button></a> //send mail function <?php function sendMail(){ $to = "agregoire@123id.us"; $subject = "New Employee Time Card Submittal: " . $FirstName . " " . $LastName . " "; $message = "<h1>Employee Information</h1><br>" . $msg_head . "" . $msg_job1 . " "; // set content-type for html email $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n"; // More headers $headers .= 'From: <webmaster@rjzavoral.com>' . "\r\n"; mail($to,$subject,$message,$headers); } All of my variables are defined and 'mail($to,$subject,$message,$headers);' works fine when not in the function, but it sends the mail after the first button click to submit the form which is not what i want, i want it to submit to itself, check for errors, display the users information, then after another button click, send the mail. I've tried making a button like this: <input type="button" value="Send Hours" onclick="<?php sendMail() ?>" /> But i got the same result, the mail would not be sent. Quote Link to comment Share on other sites More sharing options...
trq Posted March 22, 2009 Share Posted March 22, 2009 Again, php does not respond to client-side events. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.