Problem with testing my email.php

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Problem with testing my email.php

Postby Chico Felipe » 31. May 2013 14:03

Hello everyone! This is my first post here so I wanted to kindly ask all of you for patience as I am very new to both, PHP and XAMPP. I am quite sure this is a basic question for most of you but I am cracking my head to solve it and still didn't find the answer. So, I hope you can help me solve this problem.

Well, I installed XAMPP 1.8.1. yesterday and I tried to test my web form and email.php file which is supposed to forward the message of the people who want to contact me - directly into my inbox. However, that doesn't happens and I can't figure out why.

Here is my HTML code:
Code: Select all
<!DOCTYPE html>
<html>
<head>
   <title>Slide Down Contact Form</title>
   <script type='text/javascript' src='http://code.jquery.com/jquery-1.9.1.min.js'></script>
        <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js"></script>
   <link rel='stylesheet' type='text/css' href='http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css'/>
   <script type='text/javascript' src='dropbox.js'></script>
   <link rel="stylesheet" type="text/css" href="main.css" />
</head>

<body>
   <div class="container">

      <div id="button" class="title">
         <h6>Contact</h6>
      </div>
      
      <div id="dropbox">
         <header class="title">
            <h6>Whats up?</h6>
         </header>
         
         <div class="contact-form">
            <form action="email.php" action="post">
                  <h6><img src="img/person.png" alt="" /> Name</h6>
               <input type="text" placeholder="Please enter your full name here" required />
                  <h6><img src="img/email.png" alt="" /> E-mail</h6>
               <input type="email" placeholder="Please enter your e-mail address" required/>
                  <h6><img src="img/message.png" alt="" /> Message</h6>
               <textarea placeholder="Type your message..." required/></textarea>
               
               <input type="submit" value="Submit">
            </form>
         </div>
      </div>
      
   </div>

<script src="dropbox.js"></script>

</body>
</html>


Here is my CSS code:
Code: Select all
@import url("reset.css");

#button {
    position: absolute;
    top: 0;
    right: 10%;
    color: #eee;
    z-index: 2;
    width: 175px;
    background: #c20000;
    text-align: center;
    height: 40px;
    -webkit-border-radius: 0px 0px 2x 2px;
    border-radius: 0px 0px 2px 2px;
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 1em;
    text-transform: uppercase;
}
#button:hover {
    background: #da0000;
    cursor: pointer;
}
#button > h6{
    line-height: 40px;
    margin: 0px;
    padding-top: 0px;
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 0.8em;
    text-transform: uppercase;
}
#dropbox {
    position: absolute;
    top: 0px;
    right: 10%;
    color: #eee;
    z-index: 1;
    background: #222222;
    width: 350px;
    display: none;
    -webkit-box-shadow: 0px 0px 16px rgba(50, 50, 50, 0.75);
    -moz-box-shadow: 0px 0px 16px rgba(50, 50, 50, 0.75);
    box-shadow: 0px 0px 16px rgba(50, 50, 50, 0.75);
}
#dropbox .title {
    height: 40px;
    background: #414141;
}
#dropbox .title > h6{
    line-height: 40px;
    padding-left: 58px;
    margin-top: 0px;
}
#dropbox {
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 1em;
    text-transform: uppercase;
}
#dropbox .contact-form {
    margin: 10px;
}
#dropbox .contact-form h6{
    margin: 5px;
}
#dropbox input {
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 0.9em;
    outline: none;
    border: none;
    width: 320px;
    max-width: 330px;
    padding: 5px;
    margin: 10px 0px;
    background: #444444;
    color: #eee;
}
#dropbox textarea {
    height: 70px;
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 0.9em;
    outline: none;
    border: none;
    width: 320px;
    max-width: 320px;
    padding: 5px;
    margin: 10px 0px;
    background: #444444;
    color: #eee;
}
#dropbox input[type=submit] {
    margin: 0px;
    width: 330px;
    cursor: pointer;
    color: #999;
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 0.8em;
    text-transform: uppercase;
    font-weight: bold;
}
#dropbox input[type=submit]:hover {
    color: #eee;
    background: #c20000;
}


Here is my jQuery saved as dropbox.js:
Code: Select all
$(document).ready(function () {
   $('#button').mouseenter(function() {
      if($('#dropbox').is(':hidden')) {
         $('#dropbox').slideDown('fast', function() {
            // slidedown animation
         });
      } else {
         $('#dropdox').hide();
      }
   });
   
   $('#dropbox').mouseleave(function() {
      $('#dropbox').slideUp('fast', function() {
         // slide back up
      });
   });
   
});


And here is my PHP code saved as email.php:
Code: Select all
<?php
  $name= $_REQUEST['name'] ;
  $email = $_REQUEST['email'] ;
  $message = $_REQUEST['message'] ;

  mail( "myemail@domain.com", "Feedback Form Results",
    $message, "From: $email" );
  header( 'Location: Index.html' );
?>


Finally, here is my problem:
1. I copy-pasted all of the above files into:
file:///C:/xampp/htdocs
2. I started all servers at XAMPP control panel and checked their status which says:
MySQL database ACTIVATED
PHP ACTIVATED
HTTPS (SSL) ACTIVATED
Common Gateway Interface (CGI) ACTIVATED
Server Side Includes (SSI) ACTIVATED
SMTP Service ACTIVATED
FTP Service ACTIVATED
Tomcat Service ACTIVATED
3. In C:/xampp/htdocs there is an index.html document. When I click on it it opens (I use Mozilla Firefox) and it says: IT WORKS!
4. Still, when I open my web form (which is located in C:/xampp/htdocs) and when I fill it and submit the message for testing, the e-mail is never forwarded to my inbox???

Now, I am not sure if maybe my PHP code is not good (feel free to fix it, please) or there are some settings with XAMPP that I have to fix in order to make it work!

What are the servers that I need to start in order to forward the message to my e-mail address???

I apologize for such a lengthy question but I wanted to give you as much info as I could about my problem in order to make it easier for you to help me solve it.

Many thanks in advance to all of you!!!
Chico Felipe
 
Posts: 22
Joined: 31. May 2013 13:30
XAMPP Version: 5.6.3
Operating System: Windows 7

Re: Problem with testing my email.php

Postby Chico Felipe » 31. May 2013 14:18

I forgot to mention that I downloaded XAMPP 1.8.1 ZIP version and extracted it in a top level folder "C:\".

Hope this helps.
Chico Felipe
 
Posts: 22
Joined: 31. May 2013 13:30
XAMPP Version: 5.6.3
Operating System: Windows 7

Re: Problem with testing my email.php

Postby Altrea » 31. May 2013 14:33

Hi Chico Felipe,

First of all let me welcome you to our board and thank you very much for your very detailed error reporting :D

I haven't took a deeper look into your source code yet, because I'm on my way back home from work surfing from my tablet.
But I wouldn't use mail() any more because it is not that bullet proof.
I would use the PHPMailer class or SwiftMailer for sending mails with php.
Both are very powerful and less frustrating than mail().

http://sourceforge.net/projects/phpmailer/
http://swiftmailer.org

Best wishes,
Altrea
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 6609
Joined: 17. August 2009 13:05
XAMPP Version: 5.5.19
Operating System: W7Ux64

Re: Problem with testing my email.php

Postby Chico Felipe » 31. May 2013 14:44

Hi Altrea,

Thank you for your reply. I will definitely check the links you sent me.

I planned (as a next step) to insert CAPTCHA to my webform but first I wanted to test it, as it is, and I couldn't make it work. Well, I still can't. So I hope someone can help me to find out whether a problem is in my PHP code or more likely I don't know how to setup my XAMPP correctly.

My PHP knowledge is very humble but if there is a mistake in my php code then I would like to understand it. I don't mind using the PHPMailer class or SwiftMailer for sending mails with php, as you suggested, but i first have to read the links you sent me.

Again, thanks for your answer!
Chico Felipe
 
Posts: 22
Joined: 31. May 2013 13:30
XAMPP Version: 5.6.3
Operating System: Windows 7

Re: Problem with testing my email.php

Postby Altrea » 31. May 2013 14:57

Okay, some more time for some more information.

You haven't said anything about how you open your email.php file in the browser.
php is a serverside programming language. That means PHP files can't simply get processed by double-clicking or dragging and droping it in the browser. PHP files need to be requested from a webserver.

So, for example if your php file is C:\xampp\htdocs\email.php you can request it with the URL http://localhost/email.php
If it would be C:\xampp\htdocs\subfolder\email.php it can be requested with URL http://localhost/subfolder/email.php

Next information: XAMPP 1.8.1 uses a new mailtodisk script to dump all mails which get generated by the mail() function to a folder inside your xampp folder (AFAIK C:\xampp\mailoutput\).
If you want to use the mail() function to send emails you need to configure it to use fake sendmail or as i would prefer use the class PHPMailer or SwiftMailer.

Servers that needed to be started to send Mails is just Apache.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 6609
Joined: 17. August 2009 13:05
XAMPP Version: 5.5.19
Operating System: W7Ux64

Re: Problem with testing my email.php

Postby Chico Felipe » 31. May 2013 15:16

Thanks for getting back here with more answers. Appreciate it very much!

As I am very new to XAMPP and PHP I am not sure what you mean by "PHP files need to be requested from a webserver". I tried to request it (as you suggested) with the URL http://localhost/email.php but I get the following message:

Object not found!
The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error.
If you think this is a server error, please contact the webmaster.
Error 404
localhost
Apache/2.4.3 (Win32) OpenSSL/1.0.1c PHP/5.4.7

What I was actually doing so far was next:
1. I copied all of the above files (html, css, js and php) into my XAMPP/htdocs folder.
2. from there, I opened my html file in mozilla firefox and filled out the web form
3. when I press the SUBMIT button of my web form I don't receive the message in my inbox. All I get is a completely blank (white) page with the following URL:
file:///C:/xampp/htdocs/email.php

I am really not sure if that's correct procedure or I am doing something wrong.

If you think my PHP code is weak, please feel free to update it. In the meantime I will try to read the links you sent me in your first mail and see if I can figure it out by myself.

Thanks for your patience!!!
Chico Felipe
 
Posts: 22
Joined: 31. May 2013 13:30
XAMPP Version: 5.6.3
Operating System: Windows 7

Re: Problem with testing my email.php

Postby Chico Felipe » 31. May 2013 15:19

Do I maybe need to download PHP separately (and what version) or it came with XAMPP???
Chico Felipe
 
Posts: 22
Joined: 31. May 2013 13:30
XAMPP Version: 5.6.3
Operating System: Windows 7

Re: Problem with testing my email.php

Postby Altrea » 31. May 2013 15:25

Chico Felipe wrote:I tried to request it (as you suggested) with the URL http://localhost/email.php but I get the following message:

Object not found!
The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error.
If you think this is a server error, please contact the webmaster.
Error 404
localhost
Apache/2.4.3 (Win32) OpenSSL/1.0.1c PHP/5.4.7

That simply means you are successfully running an Apache webserver and that the file does not exist under this URL / the path Apache is searching for it.
So please doublecheck if you have an email.php file inside your C:\xampp\htdocs\ folder.
Which program do you use to create your php files?
Is there maybe a hidden .txt file extension at this file?

Chico Felipe wrote:2. from there, I opened my html file in mozilla firefox and filled out the web form
3. when I press the SUBMIT button of my web form I don't receive the message in my inbox. All I get is a completely blank (white) page with the following URL:
file:///C:/xampp/htdocs/email.php

This can't work. If you are referencing a php file in a html form relatively (means not with a full absolute URL), the html file itself needs also to be requested and not simply opened in the browser.

Chico Felipe wrote:Do I maybe need to download PHP separately (and what version) or it came with XAMPP???

No. XAMPP already comes with a preconfigured php version implemented and configured with Apache.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 6609
Joined: 17. August 2009 13:05
XAMPP Version: 5.5.19
Operating System: W7Ux64

Re: Problem with testing my email.php

Postby Chico Felipe » 31. May 2013 16:21

Hi again and sorry for delay. We have a thunderstorm with heavy rain and hail here so I was away from my computer for a while.

I just double checked and my php file is fine. It is inside my C:\xampp\htdocs\ folder. It is named email.php and when I right click on properties I can see it is saved as type: PHP File (.php). Btw, I created it in notepad and saved it as email.php and then I chose All Files option. So this should be fine.

Altrea wrote: "This can't work. If you are referencing a php file in a html form relatively (means not with a full absolute URL), the html file itself needs also to be requested and not simply opened in the browser".


I am afraid I didn't understand this part. How can I correct it???
Chico Felipe
 
Posts: 22
Joined: 31. May 2013 13:30
XAMPP Version: 5.6.3
Operating System: Windows 7

Re: Problem with testing my email.php

Postby Altrea » 31. May 2013 17:18

Let's start at the very beginning.
Please create a new subfolder named email in c:\xampp\htdocs\
Create a new file index.php with the following content
Code: Select all
<?php echo 'xampp with php is working'; ?>

Try to execute it with URL http://localhost/email/index.php

If this is working move your files to that folder and try to request http://localhost/email/email.php
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 6609
Joined: 17. August 2009 13:05
XAMPP Version: 5.5.19
Operating System: W7Ux64

Re: Problem with testing my email.php

Postby Chico Felipe » 31. May 2013 17:44

I followed your instruction and managed to execute the code you sent me.

But when I later copied my files to the newly created email subfolder and filled the form it seems like everything works good besides I didn't receive any e-mail in my inbox???

Anyway, seems like a step closer to final solution.

Maybe my PHP code is wrong?
Chico Felipe
 
Posts: 22
Joined: 31. May 2013 13:30
XAMPP Version: 5.6.3
Operating System: Windows 7

Re: Problem with testing my email.php

Postby Altrea » 31. May 2013 17:50

How did you request the file which contains the form?
Do you have a new file in C:\xampp\mailoutput\?
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 6609
Joined: 17. August 2009 13:05
XAMPP Version: 5.5.19
Operating System: W7Ux64

Re: Problem with testing my email.php

Postby Chico Felipe » 31. May 2013 17:55

I requested the file which contains the form following the link http://localhost/email/email.php

Yes I do have a new file in C:\xampp\mailoutput\ which is (I guess) automatically created when I tried to fill and submit my webform. Inside the file there is:
To: mymail@gmail.com
Subject: Feedback Form Results
From:

Actually, there is more than one file in C:\xampp\mailoutput\ as I was trying several times to fill and submit the webform.

Still, nothing was forwarded to my inbox :(
Chico Felipe
 
Posts: 22
Joined: 31. May 2013 13:30
XAMPP Version: 5.6.3
Operating System: Windows 7

Re: Problem with testing my email.php

Postby Chico Felipe » 31. May 2013 18:03

Btw, on my XAMPP controll panel I started only Apache server, as you said it is the only one needed to send emails.
Chico Felipe
 
Posts: 22
Joined: 31. May 2013 13:30
XAMPP Version: 5.6.3
Operating System: Windows 7

Re: Problem with testing my email.php

Postby Altrea » 31. May 2013 18:12

That's okay. That's what I told you the mailtodisk script.
Now you know how to request your script and that your script is working.
Now you are ready for the next step. You have the choice to:
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 6609
Joined: 17. August 2009 13:05
XAMPP Version: 5.5.19
Operating System: W7Ux64

Next

Return to XAMPP for Windows

Who is online

Users browsing this forum: JJ_Tagy and 61 guests