Having issues with php code for a contact form.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ham1
    New Member
    • May 2010
    • 4

    Having issues with php code for a contact form.

    I have been trying to resolve this problem for weeks now (i am an novice), i have tried everything. Nothing i do seems to fix the problem.

    My host is site5
    The code im using on my contact.php page is :

    Code:
    <?php
    
    
    if(isset($_POST['SUBMIT'])){
    	
    		$naslov   = htmlspecialchars($_POST['subject'], ENT_QUOTES);
           	$lastname = htmlspecialchars($_POST['name'], ENT_QUOTES);
           	$mail 	  = htmlspecialchars($_POST['email'], ENT_QUOTES);
           	$message  = htmlspecialchars($_POST['text'], ENT_QUOTES);
           	 	$emaile = explode('@', $mail);
           	if($emaile[0] != '' && $emaile[1] != ''){
    
    		  $to = 'info@precision-clean.co.uk';
              $subj = 'enquiry'; 
              
             
              $headers = 'From: '.$to.'' . "\r\n"; 
              $headers  .= 'Reply-To: '.$to.'' . "\r\n";
    		  $headers  .= 'MIME-Version: 1.0' . "\r\n";
              $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
    		  
              
             
              
              $mess = '<html><head><title>CONTACT</title></head><body><p>';	
              
              $mess .= '<p><b>CONTACT</b></p><br />';
              $mess .= '<b>Title: </b>'.$subject.'<br />';
              $mess .= '<b>Name: </b>'.$lastname.'<br />';
              $mess .= '<b>E-mail: </b>'.$mail.'<br />';
    		  $mess .= '<b>Message: </b>'.$message.'<br />';
              $mess .= '</p></body></html>';
              
              
              $mailsend = mail($to,$subj,$mess, $headers);
           		
           		
           		unset($_POST['name'],$_POST['subject'],$_POST['name'],$_POST['email'],$_POST['text']);
           	}else{
           		$error = 'Ivalid e-mail. Please try again. Thank you';
           	}
    	
    }
    if (isset($error)) {
    	print '<div>'.$error.'</div>';
    }
    ?>
    please any help would be appreciated!
    Last edited by Niheel; May 6 '10, 12:23 AM. Reason: Removed hi
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    You forgot to tell us what the problem is :)

    Comment

    • ham1
      New Member
      • May 2010
      • 4

      #3
      lol right! sorry its just driving me crazy! it just doesnt work, ive tried all kinds of edits while looking around on the net but nothing works, it just doesnt seem to want to send any emails out!

      the website is www.precision-clean.co.uk, if you would like to have a look. I could also send the actual file to you maybe that could help you better with your assessment.

      thank you so much! any help would be greatly appreciated!

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        so, what about your problem …?

        Comment

        • ham1
          New Member
          • May 2010
          • 4

          #5
          i dont understand, am i not saying it properly lol.

          Basically everytime i go on the contacts page and fill in the form and send, i dont receive any emails! ive tested site5 and i know php is active and it does work! but there seems to be a problem with the code!

          Comment

          • Markus
            Recognized Expert Expert
            • Jun 2007
            • 6092

            #6
            Sorry about the wait.

            Anyway, at the very beginning of your page, stick this:
            Code:
            error_reporting(-1);
            It'll show any errors that are in your code.

            Secondly, I really dislike PHP's mail function and we rarely recommend it. Instead, we often recommend using SwiftMailer. However, for some people, this library can seem a bit intimidating. If you do not feel comfortable using it, have a look at PHPMailer. This library is smaller and easier to use, for simple emails.

            If you need help getting either of the libraries set up, let us know.

            Comment

            • ham1
              New Member
              • May 2010
              • 4

              #7
              its okay! thank you for helping :)

              ill have a look now and hopefully figure out whats wrong :)

              EDIT:

              i tried the code you gave me but to no avail.

              I went onto SwiftMailer, i downloaded the library and installed the /lib folder onto my hosting server. Im going to mess around with it and see if i can get it going if not ill be back here :D

              thanks for the help :)

              Comment

              • Markus
                Recognized Expert Expert
                • Jun 2007
                • 6092

                #8
                No problem :)

                Comment

                Working...