matleeds Posted October 5, 2011 Share Posted October 5, 2011 I suspect I’m trying to achieve this in a cack handed way but my HTML/PHP experience is extremely rusty at the moment. I want a button on a web page ‘SEND REMINDERS’. When the user clicks it I want to call do_send_reminders() that lives in ot.php on my webserver. I suspect some sort of javascript is the best option so if you can help on that then greta but I’m also looking at using forms to do it to. Here’s my admin page..the bit about forms is near the bottom... <?php $appointments = ot::db('appointment')->fetch_all('status > 0'); ?> <div style="border-bottom: 1px dotted #AAA"> <?php if ($appointments):?> <table class="appointment_table"> <thead> <th>Patient</th> <th></th> <th>Date</th> <th></th> <th>Treatment</th> </thead> <?php foreach($appointments as $a):?> <?php $p = ot::db('patient')->fetch('id = ?', array($a->pid)); $patient = $p->fname.' '.$p->lname; $t = ot::db('treatment')->fetch('id = ?', array($a->tid)); $treatment = $t->description; $date = date('l F jS, Y', $a->time).' at '.date('g:ia', $a->time); ?> <tr> <td><?php echo $patient?></td> <td> </td> <td><?php echo $date?></td> <td> </td> <td><?php echo $treatment?></td> </tr> <?php endforeach?> </table> </div> <form action='<?php echo $_SERVER['REQUEST_URI']?>' method='post' > <p>Email:<br/><input type='text' name='email' /></p> <p>Password:<br/><input type='password' name='pwd' /></p> <p><input type='submit' name='do_send_reminders' value='Send reminders' /> </form> <?php else:?> <p>There are currently no appointments where reminders have not been sent.</p> <?php endif?> As you can probably guess I’ve just copied the code from the login in page and tried to amend it. I don’t want any text boxes appearing re. email/password. When I click oon the button at the moment nothing appears to happen..the do_send_reminders() isn’t called. thanks. Quote Link to comment https://forums.phpfreaks.com/topic/248464-call-a-php-function-using-forms/ Share on other sites More sharing options...
Buddski Posted October 5, 2011 Share Posted October 5, 2011 You can use javascript but the easiest way would be to post the form as you already are and pick up if the form was submitted.. <?php if (isset($_POST['do_send_reminders'])) { // Run your send reminders code here } $appointments = ot::db('appointment')->fetch_all('status > 0'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/248464-call-a-php-function-using-forms/#findComment-1275926 Share on other sites More sharing options...
matleeds Posted October 5, 2011 Author Share Posted October 5, 2011 thanks bud that's worked! Quote Link to comment https://forums.phpfreaks.com/topic/248464-call-a-php-function-using-forms/#findComment-1275930 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.