SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    <title class="lol"> bronze trophy TehYoyo's Avatar
    Join Date
    Feb 2012
    Location
    Northeast Chicago Suburbs
    Posts
    806
    Mentioned
    18 Post(s)
    Tagged
    1 Thread(s)

    Basic Scripting Help

    Hey all. I'm not a PHP guy - I'm mainly front-end. My client wants me to create a simple form - a name, email address, and message.

    Does anyone have a script handy or know a site where I can get the php code to send an email (or create a log on the server) w/ the user's name, email address, and message upon submitting it?

    Thanks a lot in advance.
    ~TehYoyo

  2. #2
    billycundiff{float:left;} silver trophybronze trophy RyanReese's Avatar
    Join Date
    Oct 2008
    Location
    Whiteford, Maryland, United States
    Posts
    13,566
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    Here is a basic one. No user input has been sanitized though. You'll need to add security to it now. Never trust user input.

    HTML to match. Here is the example HTML for $email.
    Code:
    <input type="text" name="email" value="Email" />
    Code:
    <?php 
    $email=$_POST['email'];
    $name =$_POST['name'];
    $message = $_POST['message'];
    $subject = $_POST['subject'];
    $from = "emailaddressthatitisbeingsentto@mail.com";
    
    
    
    $send = mail($from , $subject , "Someone wants to contact you through your website.\n\nThe user who wants to is. \n\nUser: ".$name."\nEmail: ".$email."\n\n".$message."\n\nYour welcome", "FROM: donotrespond@website.com");
    
    if ($send||isset($send)||!empty($send))
    {
    header('Location: http://www.sitehere.com/page?mail=sent');
    } else if(!$send||empty($send)||!isset($send)) {
    header('Location: http://www.sitehere.com/page?error=true');
    }
    ?>
    You'll need to setup an email account with your domain. Make sure it matches what is put in the script .
    Twitter-@Ryan_Reese09
    http://www.ryanreese.us -Always looking for web design/development work

  3. #3
    SitePoint Member
    Join Date
    Apr 2012
    Location
    India
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is it really working script, i am gonna give it try. Thanks for your efforts.
    Last edited by TechnoBear; Apr 6, 2012 at 04:41. Reason: Please wait 90 days for a signature.

  4. #4
    Non-Member
    Join Date
    Feb 2012
    Posts
    892
    Mentioned
    10 Post(s)
    Tagged
    0 Thread(s)

  5. #5
    <title class="lol"> bronze trophy TehYoyo's Avatar
    Join Date
    Feb 2012
    Location
    Northeast Chicago Suburbs
    Posts
    806
    Mentioned
    18 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by RyanReese View Post
    Here is a basic one. No user input has been sanitized though. You'll need to add security to it now. Never trust user input.

    HTML to match. Here is the example HTML for $email.
    Code:
    <input type="text" name="email" value="Email" />
    Code:
    <?php 
    $email=$_POST['email'];
    $name =$_POST['name'];
    $message = $_POST['message'];
    $subject = $_POST['subject'];
    $from = "emailaddressthatitisbeingsentto@mail.com";
    
    
    
    $send = mail($from , $subject , "Someone wants to contact you through your website.\n\nThe user who wants to is. \n\nUser: ".$name."\nEmail: ".$email."\n\n".$message."\n\nYour welcome", "FROM: donotrespond@website.com");
    
    if ($send||isset($send)||!empty($send))
    {
    header('Location: http://www.sitehere.com/page?mail=sent');
    } else if(!$send||empty($send)||!isset($send)) {
    header('Location: http://www.sitehere.com/page?error=true');
    }
    ?>
    You'll need to setup an email account with your domain. Make sure it matches what is put in the script .
    Does it have to be an email account w/ that domain? Or can I just use my gmail or yahoo?

    ~TehYoyo

    Edit: Thanks, by the way.

  6. #6
    billycundiff{float:left;} silver trophybronze trophy RyanReese's Avatar
    Join Date
    Oct 2008
    Location
    Whiteford, Maryland, United States
    Posts
    13,566
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by TehYoyo View Post
    Does it have to be an email account w/ that domain? Or can I just use my gmail or yahoo?

    ~TehYoyo

    Edit: Thanks, by the way.
    Must be with that domain. Well, I assume so. You have to use an account linked to the domain. I don't know what your host provides in terms of that . I just made an account there. Had it be "donotrespond" etc...
    Twitter-@Ryan_Reese09
    http://www.ryanreese.us -Always looking for web design/development work

  7. #7
    <title class="lol"> bronze trophy TehYoyo's Avatar
    Join Date
    Feb 2012
    Location
    Northeast Chicago Suburbs
    Posts
    806
    Mentioned
    18 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by RyanReese View Post
    Must be with that domain. Well, I assume so. You have to use an account linked to the domain. I don't know what your host provides in terms of that . I just made an account there. Had it be "donotrespond" etc...
    Alright. Thanks a lot.

    ~TehYoyo

  8. #8
    billycundiff{float:left;} silver trophybronze trophy RyanReese's Avatar
    Join Date
    Oct 2008
    Location
    Whiteford, Maryland, United States
    Posts
    13,566
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    No problem . Glad to help.
    Twitter-@Ryan_Reese09
    http://www.ryanreese.us -Always looking for web design/development work


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •