-3
<section>
    <h3>Actions</h3>
    <ul class="actions">
        <li><a href="#" class="button special">Special</a></li>
        <li><a href="#" class="button">Default</a></li>
    </ul>
    <ul class="actions">
        <li><a href="#" class="button big">Big</a></li>
        <li><a href="#" class="button">Default</a></li>
        <li><a href="#" class="button small">Small</a></li>
    </ul>
    <ul class="actions fit">
        <li><a href="#" class="button special fit">Fit</a></li>
        <li><a href="#" class="button fit">Fit</a></li>
    </ul>
    <ul class="actions fit small">
        <li><a href="#" class="button special fit small">Fit + Small</a></li>
        <li><a href="#" class="button fit small">Fit + Small</a></li>
    </ul>

Hi all, Basically I am using a template with the above code for displaying buttons. I would like to know if anyone has a way of sending me the value of a button when someone presses it.

Let's say user X presses Button that says 123 , I only want to know that button 123 was pressed. So far I can only think of making a form and using php mail to send this. But if there is an option to just send the button values I'd like to know.

Thanks in advance

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
  • 1
    We are always glad to help and support new coders but ***you need to help yourself first. :-)*** After [**doing more research**](https://meta.stackoverflow.com/q/261592/1011527) if you have a problem **post what you've tried** with a **clear explanation of what isn't working** and provide [a Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve). Read [How to Ask](http://stackoverflow.com/help/how-to-ask) a good question. Be sure to [take the tour](http://stackoverflow.com/tour) and read [this](https://meta.stackoverflow.com/q/347937/1011527). – Jay Blanchard Sep 10 '18 at 21:19
  • 1
    Do you want to send the button value? Or do you want to send the values from a form? Where do you want to send these values? – Jay Blanchard Sep 10 '18 at 21:19
  • Send the button values, to me in some manner. I can only think of utilizing mail. but if there is a better option I'd like to know – Kameel Naidoo Sep 11 '18 at 15:19
  • https://meta.stackexchange.com/questions/174082/should-can-we-answer-overly-broad-questions-with-overly-broad-answers – Jay Blanchard Sep 11 '18 at 15:21
  • Got it working with php. Thanks – Kameel Naidoo Sep 12 '18 at 21:27

2 Answers2

-1

you should create a database to collect that using email send is not a good option as you'll receive huge amount of emails depending on your website traffic also if you used the database to store every click in a single row you'll fill up your server so fast the solution is that you create a MySql table like so

CREATE TABLE `clicks_counter` (`button_id` BIGINT NOT NULL, `clicks_count` BIGINT NOT NULL) ENGINE = InnoDB;

and then use your script to count the clicks using PHP and javascript with ajax to store the clicks count

you have to send the button_id and keep trace the button_id, clicks_count using PHP to update the clicks_count each time the button clicked

M.M
  • 162
  • 1
  • 9
-1

Basic PHP Form handling.

body {
  background-color: #000;
  color: #FFF;
  overflow: hidden;
  text-align: center;
}
/* ignore the above (prettify output) */
<form action="file/to/post/to.php" method="POST">
  <label for="name">Name:</label>
  <input type"text" name='name' autocomplete="off" placeholder="Enter your Name" id="name" />
  <br /><br />
  <label for="Email">Email:</label>
  <input type"email" name='email' autocomplete="off" placeholder="Enter your@email.here" id="Email" />
  <br /><br />
  <button type="submit" id="submit-btn">Submit</button>
</form>

Now when it comes to handling the form after it has been submitted, you can do the following:

<?php
    //data for the file you are posting to
    if (isset($_REQUEST['submit-btn'])) {
       $name = $_REQUEST['name'];
       $email = $_REQUEST['email'];  
    }

  // to print the data after it has been submitted you can do this
   if(isset($name) && isset($email)) {
      print "Your name is <b>". $name . "</b> and your email is <b>" . 
      $email . "</b>";
   }
?>

PLEASE NOTE: The above example data is simply a post method you will still need to sanitize the data (error_handlers)

This should give you an idea on how to post: https://www.w3schools.com/php/php_forms.asp

JamesBond
  • 312
  • 2
  • 17