Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 72443

Send PHP email using Button instead of Input [closed]

$
0
0

So I've been pulling my hair out trying to figure this out...

At the moment I know how to send an email using "Input" but I was wondering if it can be done using "Button"

PHP:

if($_POST["submit"]) {
    $recipient="test@email.com";
    $subject="Free Consultation Form";
    $senderEmail="test2@email.com";

    $name=$_POST["name"];
    $email=$_POST["email"];
    $number=$_POST["number"];
    $service=$_POST["service"];

    $mailBody="Name: $name\nEmail: $email\nPhone Number: $number\nService: $service";

    mail($recipient, $subject, $mailBody, "From: $sender <$senderEmail>");

    $thankYou="<p>Thank you! We will be in touch with you shorthly.</p>";
}

Form:

<form method="post" action="index.php" id="test">
    <label>Name:</label>
    <input name="name"> 
    <label>Email:</label>
    <input name="email">    
    <label>Number:</label>
    <input name="number">   
    <label>Service:</label>
    <input name="service">  
    <input type="submit" name="submit" class="contact100-form-btn">
</form>

Can it somehow be done using something like this instead?

<button type="submit" name="submit" class="contact100-form-btn">
    <span>Submit
        <i class="fa fa-long-arrow-right m-l-7" aria-hidden="true"></i>
    </span>
</button>

Viewing all articles
Browse latest Browse all 72443

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>