i need help making an email button inside a table with data pulled from database

the mail() function

Moderators: egami, macek, gesf

Post Reply
New php-forum User
New php-forum User
Posts: 4
Joined: Tue Jan 15, 2019 6:23 am

Tue Jan 15, 2019 6:25 am

hello i have a page with table with content pulled from database. id like that for each row, there'd be a button that sends email to that user

the initial page with the form is in separate page, this is for the admin page. below is the code for the table on the admin side

this si the code for the table

Code: Select all

<?php if(!empty($stores)): ?>
                <?php foreach($stores as $k=>$v): ?>
                <tr class='<?php echo ($k%2==0) ? 'odd':'even'; ?>'>
                    <td><?php echo $v['name']; ?></td>
                    <td><?php echo $v['address']; ?></td>

                    <td><?php echo $v['telephone']; ?></td>
                    <td><?php echo $v['email']; ?></td>
                    <td><?php echo $v['website']; ?></td>
                    <td class="acenter"><?php echo ($v['approved']) ? 'Yes' : 'No' ; ?></td>
                    <td class="actions">
                        <a href='./stores_edit.php?id=<?php echo $v['id']; ?>'><i class="icon-pencil"></i></a>
                        <a href='javascript:delItem(<?php echo $v['id']; ?>)' class="confirm_delete"><i class="icon-trash"></i></a>
                        <?php if(!$v['approved']) : ?>
                        <a href='?action=approve&amp;&id=<?php echo $v['id']; ?>&search=<?php if(isset($_REQUEST['search'])) { echo $_REQUEST['search']; } ?><?php if(isset($_REQUEST['page'])) { echo "&page=".$_REQUEST['page']; } ?><?php if(isset($_REQUEST['sort'])) { echo "&sort=".$_REQUEST['sort']; } ?><?php if(isset($_REQUEST['filter'])) { echo "&filter=".$_REQUEST['filter']; } ?>'><?php echo $lang['ADMIN_APPROVE']; ?></a>
                        <?php endif; ?>
                        <a href= 'mail($v['email'], sprintf("subject here"), sprintf("email body here"),"From: Retailer@blablaba.com", $headers);><i class="icon-envelope"></i></a>


                <?php endforeach; ?>
            <?php else: ?>
                    <td colspan="7"><?php echo $lang['ADMIN_NO_STORES']; ?></td>
            <?php endif; ?>

so i get the mail icon to work, but when i click it the link just redirects to homepage and the URL has double slash like so

Code: Select all

of course, no one actually got any email too. anyone have any idea?
New php-forum User
New php-forum User
Posts: 3
Joined: Thu Jan 17, 2019 5:14 am

Thu Jan 17, 2019 6:55 am

The href inside the <a> tag has to be "mailto:"
Post Reply