-2

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

<?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>

                    </td>


                </tr>
                <?php endforeach; ?>
            <?php else: ?>
                <tr>
                    <td colspan="7"><?php echo $lang['ADMIN_NO_STORES']; ?></td>
                </tr>
            <?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

mysite.com//admin/mail($v[

of course, no one actually got any email too. anyone have any idea?

myo
  • 19
  • 4
  • 1
    You can't do it like this. 1. `mail` needs to be between `` tags. 2. ` – Dharman Jan 14 '19 at 22:16
  • Possible duplicate of [How do you parse and process HTML/XML in PHP?](https://stackoverflow.com/questions/3577641/how-do-you-parse-and-process-html-xml-in-php) – Dharman Jan 14 '19 at 22:17
  • but then how would i put the button/link that would contain the function? – myo Jan 15 '19 at 15:37

1 Answers1

-1

You need to put all these variables in anchor tag inside <?= and ?>

<a href= 'mail('.<?= $v['email'] ?>.','. <?= sprintf("subject here") ?>.','.<?= 
    sprintf("email body here") ?>.',"From: Retailer@blablaba.com",'.<?= $headers ?>.');'> 
    <i class="icon-envelope"></i></a> 
Jayant
  • 280
  • 2
  • 6