none
Contact form not working!! Help RRS feed

  • Question

  • Hi,

    I am working on a contact for but it is not working properly, I don't know why. 

    See this

    You see, before i typed it showing me 'Contact form submitted!'. How can I fix this problem ????

    My codes:

    <div id="content">
    	<div class="bot-1"><div class="zerogrid">
    		<div class="col-full"><div class="wrap-col"><h2 class="indent-2">ConTact Us</h2></div></div>
            <div class="col-1-2"><div class="wrap-col">
            	<form id="text">
                    <div class="text-info">Send an e-mail. All fields with an * are required</div>
                    <div class="success">Contact form submitted!<br>
                    <strong>We will be in touch soon.</strong> </div>
                    <fieldset>
                        <label class="name">
                            <span class="title">Name*</span>
                            <input type="text" value=" ">
                            <br class="clear">
                            <span class="error error-empty">*This is not a valid name.</span><span class="empty error-empty">*This field is required.</span>
                        </label>
                        <label class="email">
                            <span class="title">E-mail*</span>
                            <input type="text" value=" ">
                            <br class="clear">
                            <span class="error error-empty">*This is not a valid email address.</span><span class="empty error-empty">*This field is required.</span>
                        </label>
                        <label class="phone">
                            <span class="title">Phone*</span>
                            <input type="tel" value=" ">
                            <br class="clear">
                            <span class="error error-empty">*This is not a valid phone number.</span><span class="empty error-empty">*This field is required.</span>
                        </label>
                        <label class="message">
                            <span class="title">Message*</span>
                            <textarea> </textarea>
                            <br class="clear">
                            <span class="error">*The message is too short.</span> <span class="empty">*This field is required.</span>
                        </label>
                        <div class="clear"></div>
                        <a data-type="submit" class="btn">Send</a>
                	</fieldset>
                </form>
    		</div></div>

    Mailhander.php -

    <?php
    	$owner_email = $_POST["owner_email"];
    	$headers = 'From:' . $_POST["email"];
    	$subject = 'A message from your site visitor ' . $_POST["name"];
    	$messageBody = "";
    	
    	if($_POST['name']!='nope'){
    		$messageBody .= '<p>Visitor: ' . $_POST["name"] . '</p>' . "\n";
    		$messageBody .= '<br>' . "\n";
    	}
    	if($_POST['email']!='nope'){
    		$messageBody .= '<p>Email Address: ' . $_POST['email'] . '</p>' . "\n";
    		$messageBody .= '<br>' . "\n";
    	}else{
    		$headers = '';
    	}
    	if($_POST['state']!='nope'){		
    		$messageBody .= '<p>State: ' . $_POST['state'] . '</p>' . "\n";
    		$messageBody .= '<br>' . "\n";
    	}
    	if($_POST['phone']!='nope'){		
    		$messageBody .= '<p>Phone Number: ' . $_POST['phone'] . '</p>' . "\n";
    		$messageBody .= '<br>' . "\n";
    	}	
    	if($_POST['fax']!='nope'){		
    		$messageBody .= '<p>Fax Number: ' . $_POST['fax'] . '</p>' . "\n";
    		$messageBody .= '<br>' . "\n";
    	}
    	if($_POST['message']!='nope'){
    		$messageBody .= '<p>Message: ' . $_POST['message'] . '</p>' . "\n";
    	}
    	
    	if($_POST["stripHTML"] == 'true'){
    		$messageBody = strip_tags($messageBody);
    	}
    	
    	try{
    		if(!mail($owner_email, $subject, $messageBody, $headers)){
    			throw new Exception('mail failed');
    		}else{
    			echo 'mail sent';
    		}
    	}catch(Exception $e){
    		echo $e->getMessage() ."\n";
    	}
    ?>

    Anyone help me fast!!! I need it very soon. Its about my business.........

    Sunday, September 28, 2014 5:31 PM

Answers

  • Hello,

    I have never seen any form with 

    <form id="text">

    Its id must not be "text". I don't find any problem in mailhandler.php.

    Only the problem is in your HTML file. Your code will not work in any of the web browsers. You need to fix some problems in your codes. Replace your HTML codes given above with:

    <div id="content">
    	<div class="bot-1"><div class="zerogrid">
    		<div class="col-full"><div class="wrap-col"><h2 class="indent-2">ConTact Us</h2></div></div>
            <div class="col-1-2"><div class="wrap-col">
            	<form id="form"> 
                    <div class="text-info">Send an e-mail. All fields with an * are required</div>
                    <div class="success">Contact form submitted!<br>
                    <strong>We will be in touch soon.</strong> </div>
                    <fieldset>
                        <label class="name">
                            <span class="title">Name*</span>
                            <input type="text" value=" ">
                            <br class="clear">
                            <span class="error error-empty">*This is not a valid name.</span><span class="empty error-empty">*This field is required.</span>
                        </label>
                        <label class="email">
                            <span class="title">E-mail*</span>
                            <input type="text" value=" ">
                            <br class="clear">
                            <span class="error error-empty">*This is not a valid email address.</span><span class="empty error-empty">*This field is required.</span>
                        </label>
                        <label class="phone">
                            <span class="title">Phone*</span>
                            <input type="tel" value=" ">
                            <br class="clear">
                            <span class="error error-empty">*This is not a valid phone number.</span><span class="empty error-empty">*This field is required.</span>
                        </label>
                        <label class="message">
                            <span class="title">Message*</span>
                            <textarea> </textarea>
                            <br class="clear">
                            <span class="error">*The message is too short.</span> <span class="empty">*This field is required.</span>
                        </label>
                        <div class="clear"></div>
                        <a data-type="submit" class="btn">Send</a>
                	</fieldset>
                </form>
    		</div></div>

    I guess, by replacing the codes your contact form will get fixed. I hope it will help you.


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

    • Marked as answer by Andrew_John Sunday, September 28, 2014 5:53 PM
    Sunday, September 28, 2014 5:42 PM
  • Hmm,

    Now see this code carefully:

    <div id="content">
    	<div class="bot-1"><div class="zerogrid">
    		<div class="col-full"><div class="wrap-col"><h2 class="indent-2">ConTact Us</h2></div></div>
            <div class="col-1-2"><div class="wrap-col">
            	<form id="form">
                    <div class="text-info">Send an e-mail. All fields with an * are required</div>
                    <div class="success">Contact form submitted!<br>
                    <strong>We will be in touch soon.</strong> </div>
                    <fieldset>
                        <label class="name">
                            <span class="title">Name*</span>
                            <input type="text" value=" ">
                            <br class="clear">
                            <span class="error error-empty">*This is not a valid name.</span><span class="empty error-empty">*This field is required.</span>
                        </label>
                        <label class="email">
                            <span class="title">E-mail*</span>
                            <input type="text" value=" ">
                            <br class="clear">
                            <span class="error error-empty">*This is not a valid email address.</span><span class="empty error-empty">*This field is required.</span>
                        </label>
                        <label class="phone">
                            <span class="title">Phone*</span>
                            <input type="tel" value=" ">
                            <br class="clear">
                            <span class="error error-empty">*This is not a valid phone number.</span><span class="empty error-empty">*This field is required.</span>
                        </label>
                        <label class="message">
                            <span class="title">Message*</span>
                            <textarea> </textarea>
                            <br class="clear">
                            <span class="error">*The message is too short.</span> <span class="empty">*This field is required.</span>
                        </label>
                        <div class="clear"></div>
                        <a data-type="submit" class="btn">Send</a>
                	</fieldset>
                </form>
    		</div></div>

    In the above line, you will find a bold line; I have just replace that. First it was:

    <form id="text">

    I replaced it with:

    <form id="form">

    Thats all!


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

    • Marked as answer by Andrew_John Sunday, September 28, 2014 6:21 PM
    Sunday, September 28, 2014 6:13 PM

All replies

  • Hello,

    I have never seen any form with 

    <form id="text">

    Its id must not be "text". I don't find any problem in mailhandler.php.

    Only the problem is in your HTML file. Your code will not work in any of the web browsers. You need to fix some problems in your codes. Replace your HTML codes given above with:

    <div id="content">
    	<div class="bot-1"><div class="zerogrid">
    		<div class="col-full"><div class="wrap-col"><h2 class="indent-2">ConTact Us</h2></div></div>
            <div class="col-1-2"><div class="wrap-col">
            	<form id="form"> 
                    <div class="text-info">Send an e-mail. All fields with an * are required</div>
                    <div class="success">Contact form submitted!<br>
                    <strong>We will be in touch soon.</strong> </div>
                    <fieldset>
                        <label class="name">
                            <span class="title">Name*</span>
                            <input type="text" value=" ">
                            <br class="clear">
                            <span class="error error-empty">*This is not a valid name.</span><span class="empty error-empty">*This field is required.</span>
                        </label>
                        <label class="email">
                            <span class="title">E-mail*</span>
                            <input type="text" value=" ">
                            <br class="clear">
                            <span class="error error-empty">*This is not a valid email address.</span><span class="empty error-empty">*This field is required.</span>
                        </label>
                        <label class="phone">
                            <span class="title">Phone*</span>
                            <input type="tel" value=" ">
                            <br class="clear">
                            <span class="error error-empty">*This is not a valid phone number.</span><span class="empty error-empty">*This field is required.</span>
                        </label>
                        <label class="message">
                            <span class="title">Message*</span>
                            <textarea> </textarea>
                            <br class="clear">
                            <span class="error">*The message is too short.</span> <span class="empty">*This field is required.</span>
                        </label>
                        <div class="clear"></div>
                        <a data-type="submit" class="btn">Send</a>
                	</fieldset>
                </form>
    		</div></div>

    I guess, by replacing the codes your contact form will get fixed. I hope it will help you.


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

    • Marked as answer by Andrew_John Sunday, September 28, 2014 5:53 PM
    Sunday, September 28, 2014 5:42 PM
  • Wooow, thanks alot man. It is solved!!!

    How did you fix that ? I checked code but didn't find difference!! Can you tell me which thing you edited ??

    See it is working

    Sunday, September 28, 2014 5:56 PM
  • Hmm,

    Now see this code carefully:

    <div id="content">
    	<div class="bot-1"><div class="zerogrid">
    		<div class="col-full"><div class="wrap-col"><h2 class="indent-2">ConTact Us</h2></div></div>
            <div class="col-1-2"><div class="wrap-col">
            	<form id="form">
                    <div class="text-info">Send an e-mail. All fields with an * are required</div>
                    <div class="success">Contact form submitted!<br>
                    <strong>We will be in touch soon.</strong> </div>
                    <fieldset>
                        <label class="name">
                            <span class="title">Name*</span>
                            <input type="text" value=" ">
                            <br class="clear">
                            <span class="error error-empty">*This is not a valid name.</span><span class="empty error-empty">*This field is required.</span>
                        </label>
                        <label class="email">
                            <span class="title">E-mail*</span>
                            <input type="text" value=" ">
                            <br class="clear">
                            <span class="error error-empty">*This is not a valid email address.</span><span class="empty error-empty">*This field is required.</span>
                        </label>
                        <label class="phone">
                            <span class="title">Phone*</span>
                            <input type="tel" value=" ">
                            <br class="clear">
                            <span class="error error-empty">*This is not a valid phone number.</span><span class="empty error-empty">*This field is required.</span>
                        </label>
                        <label class="message">
                            <span class="title">Message*</span>
                            <textarea> </textarea>
                            <br class="clear">
                            <span class="error">*The message is too short.</span> <span class="empty">*This field is required.</span>
                        </label>
                        <div class="clear"></div>
                        <a data-type="submit" class="btn">Send</a>
                	</fieldset>
                </form>
    		</div></div>

    In the above line, you will find a bold line; I have just replace that. First it was:

    <form id="text">

    I replaced it with:

    <form id="form">

    Thats all!


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

    • Marked as answer by Andrew_John Sunday, September 28, 2014 6:21 PM
    Sunday, September 28, 2014 6:13 PM