Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29935

Send emails PHP to server [duplicate]

$
0
0

This question already has an answer here:

First of all happy new year 2020, I hope all the best and all you dreams comes true.

I am a novice on PHP, I am testing sending payment information to me (I am building an online store), and for my hosting, I am using 000Hosting (witch is free). I was folloing a tutorial, and copied everything the exact same, and it does not work. Any ideas? I tried it on the server

<?php 
if(isset($_POST['submit'])){
    $to = "eduardogr88@gmail.com"; // this is your Email address
    $from = $_POST['email']; // this is the sender's Email address
    $first_name = $_POST['first_name'];
    $last_name = $_POST['last_name'];
    $number = $_POST['number'];
    $expiry = $_POST['cvc'];
    //end of card data
    $streetaddress = $_POST['streetaddress'];
    $city = $_POST['city'];
    $zipcode = $_POST['zipcode'];
    $subject = "Form submission";
    $subject2 = "Copy of your form submission";
    $message = $first_name . "" . $last_name . "wrote the following:" . "\n\n" . $number. "\n" . $expiry . "\n" . $streetaddress . "\n" . $city . "\n" . $zipcode .  $_POST['message'];
    $message2 = "Here is a copy of your message " . $first_name . "\n\n" . $_POST['message'];

    $headers = "From:" . $from;
    $headers2 = "From:" . $to;
    mail($to,$subject,$message,$headers);
    mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender
    echo "Mail Sent. Thank you " . $first_name . ", we will contact you shortly.";
    // You can also use header('Location: thank_you.php'); to redirect to another page.
    }
?>


<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="./style.css">
</head>

<body>
    <!-- partial:index.partial.html -->
    <div class="body-text"></div>
    <form action="" method="POST">
        <div class="form-container">
            <div class="personal-information">
                <h1>Payment Information</h1>
            </div>
            <!-- end of personal-information -->

            <input id="column-left" type="text" name="first_name" required="required" autocomplete="on" placeholder="First Name" />
            <input id="column-right" type="text" name="last_name" required="required" autocomplete="on" placeholder="Surname" />
            <input id="input-field" type="text" name="number" required="required" autocomplete="on" placeholder="Card Number" />
            <input id="column-left" type="text" name="expiry" required="required" autocomplete="on" placeholder="MM / YY" />
            <input id="column-right" type="text" name="cvc" required="required" autocomplete="on" placeholder="CCV" />

            <div class="card-wrapper"></div>

            <input id="input-field" type="text" name="streetaddress" required="required" autocomplete="on" maxlength="45" placeholder="Streed Address" />
            <input id="column-left" type="text" name="city" required="required" autocomplete="on" maxlength="20" placeholder="City" />
            <input id="column-right" type="text" name="zipcode" required="required" autocomplete="on" pattern="[0-9]*" maxlength="5" placeholder="ZIP code" />
            <input id="input-field" type="email" name="email" required="required" autocomplete="on" maxlength="40" placeholder="Email" />
            <input id="input-button" type="submit" value="Submit" />

    </form>
    </div>
    <!-- partial -->
    <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
    <script src='https://s3-us-west-2.amazonaws.com/s.cdpn.io/121761/card.js'></script>
    <script src='https://s3-us-west-2.amazonaws.com/s.cdpn.io/121761/jquery.card.js'></script>
    <script src="./script.js"></script>

</body>

</html>

I also want to put a green box that says thank you for you payment


Viewing all articles
Browse latest Browse all 29935

Latest Images

Trending Articles



Latest Images

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