Jump to content

Recommended Posts

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Contact Us</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<!--
Template 2043 Pinky Flow
http://www.tooplate.com/view/2043-pinky-flow
-->
<link href="css/tooplate_style.css" rel="stylesheet" type="text/css" />

<link rel="stylesheet" type="text/css" href="css/ddsmoothmenu.css" />

<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/ddsmoothmenu.js">

/***********************************************
* Smooth Navigational Menu- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

</script>

<script type="text/javascript">

ddsmoothmenu.init({
	mainmenuid: "tooplate_menu", //menu DIV id
	orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
	classname: 'ddsmoothmenu', //class added to menu's outer DIV
	//customtheme: ["#1c5a80", "#18374a"],
	contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
})

</script>

<link rel="stylesheet" type="text/css" href="css/jquery.lightbox-0.5.css" />    
    
    <!-- Arquivos utilizados pelo jQuery lightBox plugin -->
    <script type="text/javascript" src="js/jquery.js"></script>
    <script type="text/javascript" src="js/jquery.lightbox-0.5.js"></script>
    <link rel="stylesheet" type="text/css" href="css/jquery.lightbox-0.5.css" media="screen" />
    <!-- / fim dos arquivos utilizados pelo jQuery lightBox plugin -->
    
    <!-- Ativando o jQuery lightBox plugin -->
    <script type="text/javascript">
    $(function() {
        $('#map a').lightBox();
    });
    </script>


</head>
<body>

<div id="tooplate_wrapper">
	<div id="tooplate_header">
       	<div id="site_title"><h1><a href="index.html">Rubi Noodle Studios</a></h1></div>
    	
        <div id="tooplate_menu" class="ddsmoothmenu">
                <ul>
                    <li><a href="index.html" class="selected"><span></span>Home</a></li>
                    <li><a href="gallery.html"><span></span>Galleries</a>
                        <ul>
							<li><a href="families.html">Families</a></li>
                            <li><a href="children.html">Children</a></li>
                            <li><a href="graduates.html">Graduates</a></li>
                             <li><a href="engagement.html">Engagement</a></li>
                            <li><a href="weddings.html">Weddings</a></li>
                            <li><a href="maternity.html">Maternity</a></li>
                      </ul>
                  </li>
                    <li><a href="information.html"><span></span>Information</a>
                        <ul>
                            <li><a href="announcements.html">Graduation Announcements</a></li>
                             <li><a href="pricing.html">Pricing</a></li>
                            <li><a href="hints.html">Helpful Hints</a></li>
                           
                      </ul>
                  </li>
                    <li><a href="client.html"><span></span>Client Viewing</a></li>
                    <li><a href="contact.html" class="selected"><span></span>Contact</a></li>
                     <li><a href="http://www.facebook.com">
                    <img src="images/facebook.png" alt="Facebook" style="width:33px;height:32px;border:0" />
                    </a></li>
                </ul>
                <br style="clear: left" />
            </div> <!-- end of tooplate_menu -->
            
            <div id="tooplate_main">
            	
                <div id="tooplate_content">
                
                <h2>Contact Information</h2>
                    <p><em>Have a question about a session or want to set up a session? Please feel free to contact me.</em></p>
                	<div class="h30"></div>
                	<div class="col_w420 float_l">
                        <div id="contact_form">
                    
                            <h3>Quick Contact Form</h3>
                            
                            
<?php  
      
        if (isset($_POST['submit'])) {  
      
            if ($_POST['author'] != "") {  
                $_POST['author'] = filter_var($_POST['author'], FILTER_SANITIZE_STRING);  
                if ($_POST['author'] == "") {  
                    $errors .= 'Please enter a valid name.<br/><br/>';  
                }  
            } else {  
                $errors .= 'Please enter your name.<br/>';  
            }  
      
            if ($_POST['email'] != "") {  
                $email = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL);  
                if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {  
                    $errors .= "$email is <strong>NOT</strong> a valid email 		address.<br/><br/>";  
                }  
            } else {  
                $errors .= 'Please enter your email address.<br/>';  
            }  
                 if ($_POST['subject'] != "") {  
                $email = filter_var($_POST['subject'], FILTER_SANITIZE_EMAIL);  
                if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {  
                    $errors .= 'Please enter a subject.<br/></br>'; 
                }  
            } else {  
                $errors .= 'Please enter your subject.<br/>';  
            }  
            if ($_POST['text'] != "") {  
                $_POST['text'] = filter_var($_POST['text'], FILTER_SANITIZE_STRING);  
                if ($_POST['text'] == "") {  
                    $errors .= 'Please enter a message to send.<br/>';  
                }  
            } else {  
                $errors .= 'Please enter a message to send.<br/>';  
            }  
      
           if (!$errors) {  
         $author=$_POST['author'];
		$email=$_POST['email'];
		$subject = 'Vistor:Email'; 
		$text=$_POST['text'];

		mail("myemail@yahoo.com","$subject",
		$text,"From: $author <$email>"); 
      
		header("Location:contact.php?thankyou");
		exit();
            } else {  
                echo '<div style="color: red">' . $errors . '<br/></div>';  
            }  
        }  
    ?>  

<?php
//Then outside the processing script add 
if (isset($_GET['thankyou'])){
echo "Thank you for your email!<br/><br/>";
}
?>
    

                          <form method="post" name="form1" action="contact.php" />
							
								<label for="author">* Name:</label> <input type="text" id="author" name="author" class="required input_field" value="<?php echo $_POST['author']; ?>"/>
								<div class="cleaner h10"></div>
													
								<label for="email">* Email:</label> <input type="text" class="validate-email required input_field" name="email" id="email" value="<?php echo $_POST['email']; ?>" />
								<div class="cleaner h10"></div>
											
								<label for="subject">* Subject:</label> <input type="text" class="validate-subject required input_field" name="subject" id="subject" value="<?php echo $_POST['subject']; ?>" />				               
								<div class="cleaner h10"></div>
							
								<label for="text">* Message:</label> <textarea id="text" name="text" rows="0" cols="0" class="required" value="<?php echo $_POST['text']; ?>" ></textarea>
								<div class="cleaner h10">
								</div>
								
												<input type="submit" value="Send" id="submit" name="submit" class="submit_btn float_l" />
								<input type="reset" value="Reset" id="reset" name="reset" class="submit_btn float_r" />
                            
                            </form>						
                    
                        </div> 
                    </div>
                        
                    <div class="col_w420 float_r">
                        <h3>Location</h3>
                        <div id="map">
                            <a href="images/map_big.png" title="Our Location">
                                <img width="300" height="150" src="images/map_thumb.png" alt="Location" class="image_wrapper" />
                            </a>
                        </div>                
                        <div class="cleaner h30"></div>
                        
                        <h3>Mailing Address</h3>
                        <h6>Address</h6>
                        Address <br />
                        <br />
                         <br /><br />
                        <strong>Phone:</strong> 020-054-1520<br />
            			<strong>Email:</strong> <a href="mailto:info@company.com">info@company.com</a>   
                    </div>
                    
                
                	<div class="cleaner"></div>
                </div>
				
                <div class="cleaner"></div>
            </div> <!-- end of tooplate_main -->
            
            <div id="tooplate_footer">
                Copyright © 2014 <a href="index.html">Rubi Noodle Studios</a> | Design: <a href="http://www.tooplate.com">tooplate</a>
                <div class="cleaner"></div>
            </div>
        
    </div> <!-- end of forever header -->
</div> <!-- end of forever wrapper -->

</body>
</html>

When I run my contact form on my webserver and fill it out completely and submit it, I get my error message saying "Please enter a subject." when I have a subject.

 

 

Link to comment
https://forums.phpfreaks.com/topic/293096-contact-form-not-working/
Share on other sites

     if ($_POST['subject'] != "") {  
                $email = filter_var($_POST['subject'], FILTER_SANITIZE_EMAIL);  
                if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {  
                    $errors .= 'Please enter a subject.<br/></br>'; 
                }  
            } else {  
                $errors .= 'Please enter your subject.<br/>';  
            } 

So, I just need to take out:


if ($_POST['subject'] != "") {
$_POST['subject'] = filter_var($_POST['subject'], FILTER_SANITIZE_STRING);
if ($_POST['subject'] == "") {
$errors .= 'Please enter a valid subject.<br/><br/>';
}
} else {
$errors .= 'Please enter your subject.<br/>';
}
<?php  
      
        if (isset($_POST['submit'])) {  
      
            if ($_POST['author'] != "") {  
                $_POST['author'] = filter_var($_POST['author'], FILTER_SANITIZE_STRING);  
                if ($_POST['author'] == "") {  
                    $errors .= 'Please enter a valid name.<br/><br/>';  
                }  
            } else {  
                $errors .= 'Please enter your name.<br/>';  
            }  
      
            if ($_POST['email'] != "") {  
                $email = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL);  
                if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {  
                    $errors .= "$email is <strong>NOT</strong> a valid email 		address.<br/><br/>";  
                }  
            } else {  
                $errors .= 'Please enter your email address.<br/>';  
            }  
            
              if ($_POST['subject'] != "") {  
                $_POST['subject'] = filter_var($_POST['subject'], FILTER_SANITIZE_STRING);  
                if ($_POST['subject'] == "") {  
                    $errors .= 'Please enter a valid subject.<br/><br/>';  
                }  
            } else {  
                $errors .= 'Please enter your subject.<br/>';  
            }  
                if ($_POST['text'] != "") {  
                if (!strlen(trim($_POST['text'])));
                $_POST['text'] = filter_var($_POST['text'], FILTER_SANITIZE_STRING);  
                if ($_POST['text'] == "") {  
                    $errors .= 'Please enter a message to send.<br/>';  
                }  
            } else {  
                $errors .= 'Please enter a message to send.<br/>';  
            }
           if (!$errors) {  
         $first_name=$_POST['author'];
		$email_address=$_POST['email'];
		$subject = $_POST['subject'];
		$text=$_POST['text'];

		mail("myemailaddress@yahoo.com","$subject",
		$text,"From: $first_name <$email_address>"); 
      
		header("Location:contact.php?thankyou=1");
		exit();
            } else {  
                echo '<div style="color: red">' . $errors . '<br/></div>';  
            }  
        }  
    ?>  

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Contact Us</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<!--
Template 2043 Pinky Flow
http://www.tooplate.com/view/2043-pinky-flow
-->
<link href="css/tooplate_style.css" rel="stylesheet" type="text/css" />

<link rel="stylesheet" type="text/css" href="css/ddsmoothmenu.css" />

<script type="text/javascript" src="../js/jquery.min.js"></script>
<script type="text/javascript" src="../js/ddsmoothmenu.js">

/***********************************************
* Smooth Navigational Menu- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

</script>

<script type="text/javascript">

ddsmoothmenu.init({
	mainmenuid: "tooplate_menu", //menu DIV id
	orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
	classname: 'ddsmoothmenu', //class added to menu's outer DIV
	//customtheme: ["#1c5a80", "#18374a"],
	contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
})

</script>

<link rel="stylesheet" type="text/css" href="css/jquery.lightbox-0.5.css" />    
    
    <!-- Arquivos utilizados pelo jQuery lightBox plugin -->
    <script type="text/javascript" src="../js/jquery.js"></script>
    <script type="text/javascript" src="../js/jquery.lightbox-0.5.js"></script>
    <link rel="stylesheet" type="text/css" href="css/jquery.lightbox-0.5.css" media="screen" />
    <!-- / fim dos arquivos utilizados pelo jQuery lightBox plugin -->
    
    <!-- Ativando o jQuery lightBox plugin -->
    <script type="text/javascript">
    $(function() {
        $('#map a').lightBox();
    });
    </script>


</head>
<body>

<div id="tooplate_wrapper">
	<div id="tooplate_header">
       	<div id="site_title"><h1><a href="index.html">Rubi Noodle Studios</a></h1></div>
    	
        <div id="tooplate_menu" class="ddsmoothmenu">
                <ul>
                    <li><a href="index.html" class="selected"><span></span>Home</a></li>
                    <li><a href="gallery.html"><span></span>Galleries</a>
                        <ul>
							<li><a href="families.html">Families</a></li>
                            <li><a href="children.html">Children</a></li>
                            <li><a href="graduates.html">Graduates</a></li>
                             <li><a href="engagement.html">Engagement</a></li>
                            <li><a href="weddings.html">Weddings</a></li>
                            <li><a href="maternity.html">Maternity</a></li>
                      </ul>
                  </li>
                    <li><a href="information.html"><span></span>Information</a>
                        <ul>
                            <li><a href="announcements.html">Graduation Announcements</a></li>
                             <li><a href="pricing.html">Pricing</a></li>
                            <li><a href="hints.html">Helpful Hints</a></li>
                           
                      </ul>
                  </li>
                    <li><a href="client.html"><span></span>Client Viewing</a></li>
                    <li><a href="contact.html" class="selected"><span></span>Contact</a></li>
                     <li><a href="http://www.facebook.com">
                    <img src="images/facebook.png" alt="Facebook" style="width:33px;height:32px;border:0" />
                    </a></li>
                </ul>
                <br style="clear: left" />
            </div> <!-- end of tooplate_menu -->
            
            <div id="tooplate_main">
            	
                <div id="tooplate_content">
                
                <h2>Contact Information</h2>
                    <p><em>Have a question about a session or want to set up a session? Please feel free to contact me.</em></p>
                	<div class="h30"></div>
                	<div class="col_w420 float_l">
                	<h3>Quick Contact Form</h3>
                	<?php
//Then outside the processing script add 
If (isset($_GET['thankyou'])){
echo "Thank you for your email!<br/><br/>";
}
?>
                        <div id="contact_form">
                          <form action="contact.php"  name="form1" method="post">
							
								<label for="author">* Name:</label> <input type="text" id="author" name="author" class="required input_field" value="<?php echo $_POST['author']; ?>"/>
								<div class="cleaner h10"></div>
													
								<label for="email">* Email:</label> <input type="text" class="validate-email required input_field" name="email" id="email" value="<?php echo $_POST['email']; ?>" />
								<div class="cleaner h10"></div>
											
								<label for="subject">* Subject:</label> <input type="text" class="validate-subject required input_field" name="subject" id="subject" value="<?php echo $_POST['subject']; ?>" />				               
								<div class="cleaner h10"></div>
							
								<label for="text">* Message:</label> <textarea id="text" name="text" rows="0" cols="0" class="required"><?php echo $_POST['text']; ?></textarea>
								<div class="cleaner h10">
								</div>
								
												<input type="submit" value="Send" id="submit" name="submit" class="submit_btn float_l" />
								<input type="reset" value="Reset" id="reset" name="reset" class="submit_btn float_r" />
                            
                            </form>
              					
                    
                        </div> 
                    </div>
                        
                    <div class="col_w420 float_r">
                        <h3>Location</h3>
                        <div id="map">
                            <a href="images/map_big.png" title="Our Location">
                                <img width="300" height="150" src="images/map_thumb.png" alt="Location" class="image_wrapper" />
                            </a>
                        </div>                
                        <div class="cleaner h30"></div>
                        
                        <h3>Mailing Address</h3>
                        <h6>Address</h6>
                        Address <br />
                        <br />
                         <br /><br />
                        <strong>Phone:</strong> 020-054-1520<br />
            			<strong>Email:</strong> <a href="mailto:info@company.com">info@company.com</a>   
                    </div>
                    
                
                	<div class="cleaner"></div>
                </div>
				
                <div class="cleaner"></div>
            </div> <!-- end of tooplate_main -->
            
            <div id="tooplate_footer">
                Copyright © 2014 <a href="index.html">Studios</a> | Design: <a href="http://www.tooplate.com">tooplate</a>
                <div class="cleaner"></div>
            </div>
        
    </div> <!-- end of forever header -->
</div> <!-- end of forever wrapper -->

</body>
</html>

My webserver supports php 5.2.12 and I've made sure that my file is saved as .php, now when I upload it to my webserver, the php shows in my name, email, and subject fields. Not sure what've I've done, since I am getting no errors in my console or localhost. Any help is much appreciated.

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.