Jump to content
MakeWebGames

Send Mail


ashbow97

Recommended Posts

Hey, it's me again with another problem that i can't seem to solve :/ I have tried various different things, but none have worked. What happens, is when you click send, it can register and tell you if there is anything wrong with it, but when you try and send it, it gets stuck processing it (it shows a little rotating circle) and never does anything.

I'm sorry the script is really messy, I'm using a template that seems to have gone crazy with DIV tags xD This is only the actual send mail part of the script and as I said, I've tried things, but I've put it all how it was to start with. Here's the actual page:

http://www.dphgardenservices.co.uk/contact.php

Contact.php:

 

<div class="contform"> 
               <p>Required fields are marked <span class="yellow">*</span></p>
               <form action="#" method="post" name="contactform" id="contactform">
                 <div class="form_info"> 
                   <div class="form_error defaulterror">You forgot to enter your 
                     name.</div>
                   <div class="form_error shorterror">Entered name should not 
                     be shorter than 3 characters.</div>
                   <div class="form_error longerror">Entered name should not 
                     be longer than 30 characters.</div>
                   <p class="fl"> 
                     <label for="name">Name <span class="yellow">*</span></label>
                   </p>
                   <div class="inp_l"> 
                     <div class="inp_r"> 
                       <input type="text" name="name" id="name" value="" size="22" tabindex="3" />
                     </div>
                   </div>
                 </div>
                 <div class="cl"></div>
                 <div class="form_info"> 
                   <div class="form_error defaulterror">You forgot to enter your 
                     email address.</div>
                   <div class="form_error invaliderror">You entered an invalid 
                     email address.</div>
                   <p class="fl"> 
                     <label for="email">Email <span class="yellow">*</span></label>
                   </p>
                   <div class="inp_l"> 
                     <div class="inp_r"> 
                       <input type="text" name="email" id="email" value="" size="22" tabindex="4" />
                     </div>
                   </div>
                 </div>
                 <div class="cl"></div>
                 <div class="form_info"> 
                   <p class="fl"> 
                     <label for="url">Website</label>
                   </p>
                   <div class="inp_l"> 
                     <div class="inp_r"> 
                       <input type="text" name="url" id="url" value="" size="22" tabindex="5" />
                     </div>
                   </div>
                 </div>
                 <div class="cl"></div>
                 <div class="form_info"> 
                   <div class="form_error defaulterror">You forgot to enter the 
                     subject of your message.</div>
                   <div class="form_error shorterror">Entered subject should 
                     not be shorter than 3 characters.</div>
                   <div class="form_error longerror">Entered subject should not 
                     be longer than 100 characters.</div>
                   <p class="fl"> 
                     <label for="subject">Subject <span class="yellow">*</span></label>
                   </p>
                   <div class="inp_l"> 
                     <div class="inp_r"> 
                       <input type="text" name="subject" id="subject" value="" size="22" tabindex="6" />
                     </div>
                   </div>
                 </div>
                 <div class="cl"></div>
                 <div class="form_info"> 
                   <div class="form_error defaulterror">You forgot to enter the 
                     text of your message.</div>
                   <div class="form_error shorterror">Entered message should 
                     not be shorter than 3 characters.</div>
                   <p class="fl"> 
                     <label for="message">Message <span class="yellow">*</span></label>
                   </p>
                   <table>
                     <tbody>
                       <tr> 
                         <td class="text_t_l"></td>
                         <td class="text_t"></td>
                         <td class="text_t_r"></td>
                       </tr>
                       <tr> 
                         <td class="text_l"></td>
                         <td class="text_m"><textarea name="message" id="message" cols="28" rows="6" tabindex="7"></textarea></td>
                         <td class="text_r"></td>
                       </tr>
                       <tr> 
                         <td class="text_b_l"></td>
                         <td class="text_b"></td>
                         <td class="text_b_r"></td>
                       </tr>
                     </tbody>
                   </table>
                 </div>
                 <div> 
                   <input type="hidden" value="[email protected]" id="contactemail" name="contactemail" />
                 </div>
                 <div> 
                   <input type="hidden" value="php/sendmail.php" id="contacturl" name="contacturl" />
                 </div>
                 <div class="cl"></div>
                 <div class="loading"></div>
                 <div><a href="#" class="but_styled" id="formsend" tabindex="8"><span><span class="check">Send
                   Message</span></span></a></div>
               </form>
             </div>

 

sendmail.php:

 

<?php
if(isset($_POST['contactemail'])){ $mailTo = $_POST['contactemail']; }
if(isset($_POST['name'])){ $mailFromName = $_POST['name']; }
if(isset($_POST['email'])){ $mailFromEmail = $_POST['email']; }
if(isset($_POST['subject'])){ $subject = $_POST['subject']; }
if(isset($_POST['message'])){ $message = $_POST['message']; }

mail($mailTo, $subject, $message, "From: ".$mailFromName.", ".$mailFromEmail);
?>
Link to comment
Share on other sites

Not really has a good look through it, but you have a <br /> straight after teh <?php which would defintelly cause one form of error. Secondly, you cant use HTML whithin PHP code without using it the proper way if you know what I mean. You would have to use echo "<br />";. Heres a sendmail.php which would work :

 

<?php
echo "<br />";
   if(isset($_POST['contactemail'])){ $mailTo = $_POST['contactemail']; } echo "<br />";
   if(isset($_POST['name'])){ $mailFromName = $_POST['name']; } echo "<br />";
   if(isset($_POST['email'])){ $mailFromEmail = $_POST['email']; } echo "<br />";
   if(isset($_POST['subject'])){ $subject = $_POST['subject']; } echo "<br />";
   if(isset($_POST['message'])){ $message = $_POST['message']; } echo "<br />";
echo "<br />";
   mail($mailTo, $subject, $message, "From: ".$mailFromName.", ".$mailFromEmail); echo "<br />";
?>
<br />
Link to comment
Share on other sites

I was going to say, there weren't any breaks in it before :L Anyone had any luck finding the problem? I've posted this on another site as well and they haven't found anything wrong with it and when I compare it to other templates like mine... there is no difference apart from the email address which I know is right :S But I can't see their sendmail.php so it's more than likely something on that file...

Link to comment
Share on other sites

<form action="#" method="post" name="contactform" id="contactform">

shouldnt the # be the link to the page that is sending the info to the database?

Maybe change it to sendmail.php ?

Is there such a value such as value="php/sendmail.php"??

Just sticks out those two things...

Link to comment
Share on other sites

the <br /> is a bug, not only chrome apparently ...

@OP: try what lucky3809 said, if that doesn't work, make a temporary file and test whether you can send a mail via php to yourself. It wouldn't be the first time that mail() doesn't work.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...