+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: email submit button

  1. #1
    mahlerwd is offline x10Hosting Member mahlerwd is an unknown quantity at this point
    Join Date
    Apr 2008
    Posts
    13

    email submit button

    hey

    how do i get my submit button to work? i want people to fill in the guestbook and then click submit and have it send to kate@mahler.x10hosting.com

    this is the link http://mahler.x10hosting.com/katemahler/guestbook.html

    thanks

  2. #2
    marshian's Avatar
    marshian is offline x10 Elder marshian is an unknown quantity at this point
    Join Date
    Jan 2008
    Location
    Belgium
    Posts
    526

    Re: email submit button

    There's no way to do this in one step, what you'll have to do is send the user input to a php page that then sends the mail.
    And you're missing form tags...

    replace
    HTML Code:
      <table width="575" border="0" cellpadding="3" cellspacing="2">
        <tr>
          <td width="250"><div align="right"><span class="style6">Name:</span></div></td>
          <td width="307"><label>
            <input name="Name" type="text" id="Name" size="35" maxlength="80">
          </label></td>
        </tr>
        <tr>
          <td><div align="right"><span class="style6">E-mail:</span></div></td>
          <td><input name="e-mail" type="text" id="e-mail" size="35" maxlength="80"></td>
        </tr>
    
        <tr>
          <td colspan="2"><hr></td>
        </tr>
        <tr>
          <td><div align="right"><span class="style6">What was your favorite part ? </span></div></td>
          <td><label>
            <select name="favorite" id="favorite">
              <option value="pictures">Pictures</option>
              <option value="Bio">Bio</option>
              <option value="school">School</option>
              <option value="trips">Trips</option>
            </select>
          </label></td>
        </tr>
        <tr>
          <td><div align="right"><span class="style6">Any comments? </span> </div></td>
          <td><label>
            <textarea name="comments" cols="35" rows="4" id="comments"></textarea>
          </label></td>
        </tr>
        <tr>
          <td colspan="2"><hr></td>
        </tr>
        <tr>
          <td><input name="email" type="hidden" id="email" value="kate@mahler.x10hosting.com"></td>
          <td><label>
            <input type="submit" name="Submit" value="Submit">
            </label>
            &nbsp;
            <label></label></td>
        </tr>
      </table>
    with the following:
    HTML Code:
    <form action="guestbookmail.php" method="post">
      <table width="575" border="0" cellpadding="3" cellspacing="2">
        <tr>
          <td width="250"><div align="right"><span class="style6">Name:</span></div></td>
          <td width="307"><label>
            <input name="Name" type="text" id="Name" size="35" maxlength="80">
          </label></td>
        </tr>
        <tr>
          <td><div align="right"><span class="style6">E-mail:</span></div></td>
          <td><input name="e-mail" type="text" id="e-mail" size="35" maxlength="80"></td>
        </tr>
    
        <tr>
          <td colspan="2"><hr></td>
        </tr>
        <tr>
          <td><div align="right"><span class="style6">What was your favorite part ? </span></div></td>
          <td><label>
            <select name="favorite" id="favorite">
              <option value="pictures">Pictures</option>
              <option value="Bio">Bio</option>
              <option value="school">School</option>
              <option value="trips">Trips</option>
            </select>
          </label></td>
        </tr>
        <tr>
          <td><div align="right"><span class="style6">Any comments? </span> </div></td>
          <td><label>
            <textarea name="comments" cols="35" rows="4" id="comments"></textarea>
          </label></td>
        </tr>
        <tr>
          <td colspan="2"><hr></td>
        </tr>
        <tr>
          <td><input name="email" type="hidden" id="email" value="kate@mahler.x10hosting.com"></td>
          <td><label>
            <input type="submit" name="Submit" value="Submit">
            </label>
            &nbsp;
            <label></label></td>
        </tr>
      </table>
    </form>
    And add a new file "guestbookmail.php" with the following content:
    PHP Code:
    <?php
    $name 
    $_POST["Name"];
    $email $_POST["e-mail"];
    $favourite $_POST["favourite"];
    $comments $_POST["comments"];
    $message "<html><body>";
    $message .= "<i>$name</i> has reacted to your site.<br>";
    $message .= "Favourite part: $favourite<br>";
    $message .= "Comments: <br>$comments";
    $message .= "</body></html>";
    mail("mahlerwd <kate@mahler.x10hosting.com>","Comment in your guestbook",$message,"From: guestbook <guestbook@mahler.x10hosting.com>");
    ?>
    If something doesn't work, just ask us for help again.
    Real programmers don't document their code - if it was hard to write, it should be hard to understand.

  3. #3
    woiwky is offline x10 Lieutenant woiwky is an unknown quantity at this point
    Join Date
    Mar 2008
    Posts
    390

    Re: email submit button

    I just see two problems with that. One, the receiver address in the html source might as well be deleted since it's hardcoded in the script. Leaving it there would only prove useful to spam bots. And two, since you're sending the message in html, you should provide the Content-type header.

    Also, I think the sender address should be put in some part of the message(or else why ask for it?). It could be used for the 'From' header, however it needs to be sanitized in that case. So I'd change it a little bit to this:

    HTML Code:
    <form action="guestbookmail.php" method="post">
      <table width="575" border="0" cellpadding="3" cellspacing="2">
        <tr>
          <td width="250"><div align="right"><span class="style6">Name:</span></div></td>
          <td width="307"><label>
            <input name="Name" type="text" id="Name" size="35" maxlength="80">
          </label></td>
        </tr>
        <tr>
          <td><div align="right"><span class="style6">E-mail:</span></div></td>
          <td><input name="e-mail" type="text" id="e-mail" size="35" maxlength="80"></td>
        </tr>
    
        <tr>
          <td colspan="2"><hr></td>
        </tr>
        <tr>
          <td><div align="right"><span class="style6">What was your favorite part ? </span></div></td>
          <td><label>
            <select name="favorite" id="favorite">
              <option value="pictures">Pictures</option>
              <option value="Bio">Bio</option>
              <option value="school">School</option>
              <option value="trips">Trips</option>
            </select>
          </label></td>
        </tr>
        <tr>
          <td><div align="right"><span class="style6">Any comments? </span> </div></td>
          <td><label>
            <textarea name="comments" cols="35" rows="4" id="comments"></textarea>
          </label></td>
        </tr>
        <tr>
          <td colspan="2"><hr></td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td><label>
            <input type="submit" name="Submit" value="Submit">
            </label>
            &nbsp;
            <label></label></td>
        </tr>
      </table>
    </form>
    PHP Code:
    <?php
    $name 
    $_POST["Name"];
    $email $_POST["e-mail"];
    $favourite $_POST["favourite"];
    $comments $_POST["comments"];
    $message "<html><body>";
    $message .= "<i>$name</i> has reacted to your site.<br>";
    $message .= "Email: $email<br>";
    $message .= "Favourite part: $favourite<br>";
    $message .= "Comments: <br>$comments";
    $message .= "</body></html>";
    $headers "From: guestbook <guestbook@mahler.x10hosting.com>\r\n";
    $headers .= 'Content-type: text/html; charset=utf-8';
    mail("mahlerwd <kate@mahler.x10hosting.com>","Comment in your guestbook",$message,$headers);
    ?>
    "But you have access to the greatest source of knowledge in the universe."
    "Well I do talk to myself sometimes, yes."

    "I'm back, and I'm bad! Obviously within certain, sensible, preset parameters"

  4. #4
    marshian's Avatar
    marshian is offline x10 Elder marshian is an unknown quantity at this point
    Join Date
    Jan 2008
    Location
    Belgium
    Posts
    526

    Re: email submit button

    Forgetting stuff is human... Why do I keep forgetting stuff?
    Real programmers don't document their code - if it was hard to write, it should be hard to understand.

  5. #5
    VPmase's Avatar
    VPmase is offline x10 Elder VPmase is an unknown quantity at this point
    Join Date
    Nov 2007
    Location
    Dixon, IL, USA
    Posts
    914

    Re: email submit button

    PLEASE DON'T PUT THAT ON YOUR SITE. Unless you want an SQL dump done through that code you need to add a simple function to it.
    Change
    PHP Code:
    $name $_POST["Name"];
    $email $_POST["e-mail"];
    $favourite $_POST["favourite"];
    $comments $_POST["comments"]; 
    to
    PHP Code:
    $name strip_tags($_POST["Name"]);
    $email strip_tags($_POST["e-mail"]);
    $favourite strip_tags($_POST["favourite"]);
    $comments strip_tags($_POST["comments"]); 

  6. #6
    kbjradmin's Avatar
    kbjradmin is offline x10 Elder kbjradmin is an unknown quantity at this point
    Join Date
    Feb 2008
    Location
    Washington State, USA
    Posts
    512

    Re: email submit button

    just do this:

    PHP Code:
    $name $_REQUEST['name'] ;
    $email $_REQUEST['email'] ;
    $favorite $_REQUEST['favorite'] ;
    $comment $_REQUEST['comment'] ;
    $message "$name
    $email
    $favorite
    $comment";
    $to "email@host.com";
    $subject "subject"
    $sent mail($to$subject$message);
    if(
    $sent)
    {
    echo 
    "CODE IF SEND IS SUCCESSFUL";
    }
    else
    {
    echo 
    "CODE IF SEND IS UNSUCCESSFUL";

    also, just a note, i seriously suggest against using a mailto link on your page like what you have at the bottom unless you really like reading spam.

  7. #7
    VPmase's Avatar
    VPmase is offline x10 Elder VPmase is an unknown quantity at this point
    Join Date
    Nov 2007
    Location
    Dixon, IL, USA
    Posts
    914

    Re: email submit button

    Don't use kbjardmin's script. The message will all be one line and he is missing a ;
    marshian's script is good if you add the strip_tags() function to the inputs.

  8. #8
    woiwky is offline x10 Lieutenant woiwky is an unknown quantity at this point
    Join Date
    Mar 2008
    Posts
    390

    Re: email submit button

    Mind explaining how an sql dump could be achieved through that? I could see that it is possible for someone to enter somewhat harmful html, but an sql dump seems unfathomable. In fact, I think she doesn't even have a db set up. Furthermore, she's just making the page for a class which probably doesn't even touch on php, so I don't think it's necessary to include validation really. If we were to start doing that, there's a lot more we should do than strip_tags(). But there's no harm in including that function I suppose ;-)
    "But you have access to the greatest source of knowledge in the universe."
    "Well I do talk to myself sometimes, yes."

    "I'm back, and I'm bad! Obviously within certain, sensible, preset parameters"

  9. #9
    marshian's Avatar
    marshian is offline x10 Elder marshian is an unknown quantity at this point
    Join Date
    Jan 2008
    Location
    Belgium
    Posts
    526

    Re: email submit button

    So if no more faults are discovered, the code is now:
    HTML Code:
    <form action="guestbookmail.php" method="post">
      <table width="575" border="0" cellpadding="3" cellspacing="2">
        <tr>
          <td width="250"><div align="right"><span class="style6">Name:</span></div></td>
          <td width="307"><label>
            <input name="Name" type="text" id="Name" size="35" maxlength="80">
          </label></td>
        </tr>
        <tr>
          <td><div align="right"><span class="style6">E-mail:</span></div></td>
          <td><input name="e-mail" type="text" id="e-mail" size="35" maxlength="80"></td>
        </tr>
    
        <tr>
          <td colspan="2"><hr></td>
        </tr>
        <tr>
          <td><div align="right"><span class="style6">What was your favorite part ? </span></div></td>
          <td><label>
            <select name="favorite" id="favorite">
              <option value="pictures">Pictures</option>
              <option value="Bio">Bio</option>
              <option value="school">School</option>
              <option value="trips">Trips</option>
            </select>
          </label></td>
        </tr>
        <tr>
          <td><div align="right"><span class="style6">Any comments? </span> </div></td>
          <td><label>
            <textarea name="comments" cols="35" rows="4" id="comments"></textarea>
          </label></td>
        </tr>
        <tr>
          <td colspan="2"><hr></td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td><label>
            <input type="submit" name="Submit" value="Submit">
            </label>
            &nbsp;
            <label></label></td>
        </tr>
      </table>
    </form>
    and
    PHP Code:
    <?php
    $name 
    strip_tags($_POST["Name"]);
    $email strip_tags($_POST["e-mail"]);
    $favourite strip_tags($_POST["favourite"]);
    $comments strip_tags($_POST["comments"]);
    $message "<html><body>";
    $message .= "<i>$name</i> has reacted to your site.<br>";
    $message .= "Email: $email<br>";
    $message .= "Favourite part: $favourite<br>";
    $message .= "Comments: <br>$comments";
    $message .= "</body></html>";
    $headers "From: guestbook <guestbook@mahler.x10hosting.com>\r\n";
    $headers .= 'Content-type: text/html; charset=utf-8';
    mail("mahlerwd <kate@mahler.x10hosting.com>","Comment in your guestbook",$message,$headers);
    ?>
    Real programmers don't document their code - if it was hard to write, it should be hard to understand.

  10. #10
    mahlerwd is offline x10Hosting Member mahlerwd is an unknown quantity at this point
    Join Date
    Apr 2008
    Posts
    13

    Re: email submit button

    thank you guys this is really great.
    but I'm completely new on all of this so i dont really get the php thing. i made a php page and i put that code in, and when i open it its blank. I'm sure I'm supposed to put some other stuff in, but i really just dont know what it is....i put the html code for the rest of my page on, but i dont even know if I'm supposed to put html on a php page...

    more help please? sorry for the inconvenience

+ Reply to Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. Gmail Vs. Others
    By porky101 in forum Crossfire
    Replies: 44
    Last Post: 11-05-2011, 08:14 AM
  2. email - submit button
    By mahlerwd in forum Free Hosting
    Replies: 1
    Last Post: 05-14-2008, 11:53 PM
  3. Flash button for 50 Credits:
    By satheesh in forum The Marketplace
    Replies: 4
    Last Post: 01-25-2008, 08:43 AM
  4. email settings - still having problem
    By Burnjob in forum Free Hosting
    Replies: 11
    Last Post: 10-21-2007, 07:56 AM
  5. AnyWhere Email V. 1.0 - RELEASED
    By Brandon in forum Scripts & 3rd Party Apps
    Replies: 24
    Last Post: 03-09-2006, 08:38 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers