Jump to content

Im a beginner and need help with using submit button and sending the text to my email

- - - - -

  • Please log in to reply
9 replies to this topic

#1
mbridges

mbridges

    Learning Programmer

  • Members
  • PipPipPip
  • 33 posts
I'm making a suggestions text box, and I want to get the text that the user types to forward to my email after pressing submit. Sorry, I'm new at this but thanks for your help in advance!

<form action="">

<font size="4">Suggestions:

<br><textarea name="comments" cols="50" rows="10">

</textarea><br>

<input type="submit" value="Submit" />

</form>


#2
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,118 posts
  • Location:Vancouver, Eh! Cleverness: 200
Hi,

You will most likely need a server side script such as PHP to handle the data and send it.

Can your server run PHP?
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#3
mbridges

mbridges

    Learning Programmer

  • Members
  • PipPipPip
  • 33 posts
Well I'm not sure yet, I'm just creating this in notepad right now. Should I use something else instead?

#4
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Java
Won't a <a href="mailto:whatever@dontcare.com"> be enough?

#5
mbridges

mbridges

    Learning Programmer

  • Members
  • PipPipPip
  • 33 posts
Thats just trying to link me to "whatever@dontcare.com"

#6
Roger

Roger

    If nothing goes right, go left.

  • Administrators
  • 718 posts
  • Programming Language:C, PHP
  • Learning:Python

mbridges said:

Thats just trying to link me to "whatever@dontcare.com"

<a href="mailto:whatever@dontcare.com">

This will actually open the user's desktop mail client for sending email. That way, they can compose an email to you directly.
Check out our update Guidelines/FAQ. When posting code, remember to use code tags - Posted Image.

#7
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Java
You can also set the body by doing

<a href="mailto:whatever@dontcare.com?body=Hi, you just received an email!">

And also the subject etc..
MailTo Syntax

That gives the user the option to still edit the email before sending but, as nullw0rm said. You'll need some serverside code to perform automatic emailing.

#8
mbridges

mbridges

    Learning Programmer

  • Members
  • PipPipPip
  • 33 posts
Oh okay! Thanks for the help!

#9
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,118 posts
  • Location:Vancouver, Eh! Cleverness: 200
Hi, just in case you wish to ensure compatibility with a PHP page, you can set it up as so:
suggestion.html:
<form method="post" action="suggestion.php">
<font size="4">Suggestions:<br>
<textarea name="comments" cols="50" rows="10">
</textarea><br>
<input type="submit" value="Submit" />
</form>
suggestion.php:
<?php
/* This will be your personal email */
$to = "john@someprovider.com";

if(isset($_POST['comments'])) {
    /* This is the static email subject to show where it is from */
    $subject = "This is from your suggestion box";
    /* This loads the contents of the written form */
    $body = $_POST['comments'];
    if (mail($to, $subject, $body)) {
        /* If email can be sent: */
        echo "<p>Message successfully sent!, please go back to our <a href='./'>index</a></p>";
    } else {
       /* If an error while sending: */
        echo "<p>Message delivery failed...</p>";
    }
}
?>
This method does not disclose your personal email like other methods if that is worth meaning to you.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#10
mbridges

mbridges

    Learning Programmer

  • Members
  • PipPipPip
  • 33 posts
Thanks Nullw0rm! That was a big help!




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users