CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 23
  1. #1
    Join Date
    Apr 2006
    Location
    Kolkata, India
    Posts
    278

    [RESOLVED] How to email from WEBpage?

    Dear Friends,

    I have built a website with a Page named Contact.html, here the viewer will enter all his data Like
    Name |__________|
    Email |__________|
    Sub: |___________|
    Msg |______________________________________________________|

    | Submit| < when he clicks the Submit button the msg will be mailed to the email address mentioned already in the Contact.html page.

    I tried a lot of combinations, but failed..Can you guys help me ?

    Thanks
    Rahul
    Attached Files Attached Files

  2. #2
    Join Date
    May 2002
    Posts
    10,943

    Re: How to email from WEBpage?

    PHP has to be run through a web server or else it won't be interpreted. I'm guessing you're just trying to link to the PHP page in the form's action.

    For example: The URL will have to be http://servername/page and note file://c:/page. If you don't even have a web server, then you need something like Xampp.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  3. #3
    Join Date
    Apr 2006
    Location
    Kolkata, India
    Posts
    278

    Resolved Re: How to email from WEBpage?

    Dear Peejavery,
    Thanks for replying , I dont have the faintest idea how to mail from webpage,
    I just googled some forms downloaded them & tried but failed.

    I have a website http://www.cormed.co.in , there I have this Contactfrm.html & email_form.php files , I just did whatever was mentioned in that page how to do it.

    But nothing worked out it only says You mail is sent successfully , we will contact you later.( This is a string already inserted at the page it self.!!
    Please tell me the steps in order so I can make it work
    Thank you once again
    Rahul

  4. #4
    Join Date
    May 2002
    Posts
    10,943

    Re: How to email from WEBpage?

    PHP's mail() function will not return an error to the PHP console. That's why it says it's successful. And since you have no idea what I'm talking about concerning PHP...you need to contact the server admins of that domain.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  5. #5
    Join Date
    Apr 2006
    Location
    Kolkata, India
    Posts
    278

    Re: How to email from WEBpage?

    Dear PeejAvery,

    After much fiddling with all this stuff, I am completely lost.I am attaching the Contact.html page to you please rectify the problem & send back.The Server Company says , their side is OK, but i have some errors in the code.
    Attached Files Attached Files

  6. #6
    Join Date
    May 2002
    Posts
    10,943

    Re: How to email from WEBpage?

    I've already told you...it has nothing to do with client-side HTML. Do some research! This will help you.

    http://www.w3schools.com/php/php_mail.asp
    Last edited by PeejAvery; October 6th, 2012 at 01:08 PM.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  7. #7
    Join Date
    Apr 2006
    Location
    Kolkata, India
    Posts
    278

    Re: How to email from WEBpage?

    Dear PeejAvery,

    The More I see the braces "}" I get more confused & dizzy..Lets comeback to normal html email sending page, Which I have uploaded to you yesterday.
    Please see the mistake & let me know.
    The Domain people are saying ,that their side is OK, but I might have some Coding problems(Although I did not Code it ! ) Please rectify the page & send back , I will have it working

    Thanks
    Rahul

  8. #8
    Join Date
    May 2002
    Posts
    10,943

    Re: How to email from WEBpage?

    I already told you...you cannot do it with HTML. And, if you aren't willing to use PHP...then quite simply you cannot have a mailer.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  9. #9
    Join Date
    Apr 2006
    Location
    Kolkata, India
    Posts
    278

    Re: How to email from WEBpage?

    Dear PeejAvery,

    Ok , I surrender to you.!! Please help me with the Contact.php page..Give me steps like 1.do this
    2. do this... like so....
    I know i can not learn PHP in a day..You have to help me Buddy.

    Thanks
    Rahul

  10. #10
    Join Date
    Apr 2006
    Location
    Kolkata, India
    Posts
    278

    Re: How to email from WEBpage?

    Anyway PeejAvery,

    I did some research ,& come up with these two files..Made by me one work Properly but the other says "error" & the mail is not sent.Pls check them & let me know

    Thank you
    Rahul
    Attached Files Attached Files

  11. #11
    Join Date
    May 2002
    Posts
    10,943

    Re: How to email from WEBpage?

    The very first line of contact.php needs to be removed. There is no PHP on that page at all...so you wouldn't open a PHP tag (and it's invalid anyway).

    In your send_contact.php file...

    • $from address as listed as a posted variable. Make it plain text. It isn't from the POST data in the form.
    • $from_name has a space in the $_POST variable call
    • $body is empty...so the e-mail won't have any text
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  12. #12
    Join Date
    Apr 2006
    Location
    Kolkata, India
    Posts
    278

    Re: How to email from WEBpage?

    Dear PeejAvery,

    But the Contact.php shows all the boxes & msgbox properly along with submit button.
    I can not use it???? !!!
    /q $body is empty...so the e-mail won't have any text /q>

    What has to be done in the $body part?

    Thanks
    Rahul

  13. #13
    Join Date
    May 2002
    Posts
    10,943

    Re: How to email from WEBpage?

    Quote Originally Posted by dsrahul View Post
    Dear PeejAvery,

    But the Contact.php shows all the boxes & msgbox properly along with submit button.
    I can not use it???? !!!
    I never said that at all. Do you honestly never read the posts?

    Quote Originally Posted by dsrahul View Post
    $body is empty...so the e-mail won't have any text

    What has to be done in the $body part?
    Opposite of empty = fill. So...fill the variable with text!

    In the past I have given up on you simply because you put no effort into your work at all. You expect everyone else to do everything for you. That is not why CodeGuru exists! So...here is a completely functional example of PHP mailer (which I have already linked too as well). If you cannot figure it out from this...then you need to research and learn.

    mailer.php (You only need 1 file...not two)
    PHP Code:
    <html>
    <body>

    <?php
    if (isset($_POST['email'])) {
      
    $email $_POST['email'] ;
      
    $subject $_POST['subject'] ;
      
    $message $_POST['message'] ;
      if (
    mail("your_email_address@domain.com"$subject$message"From:" $email)) {
        echo 
    'E-mail sent';
      }
    }
    else {
    ?>
    <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
      Email: <input type="text" name="email" /><br />
      Subject: <input type="text" name="subject" /><br />
      Message:<br />
      <textarea name="message" cols="40" rows="15"></textarea><br />
      <input type="submit" value="Send" />
    </form>
    <?php ?>

    </body>
    </html>
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  14. #14
    Join Date
    Apr 2006
    Location
    Kolkata, India
    Posts
    278

    Re: How to email from WEBpage?

    Dear PeejAvery,

    Thank you so much, You are a real friend.I am eager to learn, the Books , confuse me. Programmers like you, they know the subject well, I can always learn from them, but when you need to learn from them, they are either offline or they do not reply. The problem with me is , I learn the first line, then When i Study the 2nd line, I forget the first line., after a few days I forget the whole thing.have pity on me.

    Anyway I am now trying the thing with your code.If anything comes across, can I seek help from you ?

    Thanks & Regards
    Rahul

  15. #15
    Join Date
    Apr 2006
    Location
    Kolkata, India
    Posts
    278

    Exclamation Re: How to email from WEBpage?

    Dear PeejAvery,

    I modified your code ,only the part where I need to input "contactus@cormed.co.in" (My Domain ),
    Uploaded the file clicked on Contact Page , The Boxes appeared, Then I filled up the boxes,Clicked submit.
    The page became white.No Error Message, No "Your mail is sent".
    & the Mail was also not seen in the inbox of contactus@cormed.co.in !!!

    Please help
    I have tried with Validation also See:
    PHP Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
        "http://www.w3.org/TR/REC-html40/loose.dtd">
    <html>
    <body>

    <?php
    if (isset($_POST['email'])) {
      
    $email $_POST['email'] ;
      
    $subject $_POST['subject'] ;
      
    $message $_POST['message'] ;
      if (
    mail('contactus@cormed.co.in'$subject$message"From:" $email)) {
        echo 
    'Your E-mail has been sent.';
      }
    }
    else {
    ?>
    <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
      Email: <input type="text" name="email" /><br />
      Subject: <input type="text" name="subject" /><br />
      Message:<br />
      <textarea name="message" cols="40" rows="15"></textarea><br />
      <input type="submit" value="Send" />
    </form>
    <?php ?>

    </body>
    </html>
    Last edited by PeejAvery; October 10th, 2012 at 10:04 AM.

Page 1 of 2 12 LastLast

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured