pepsi_two Posted July 10, 2012 Share Posted July 10, 2012 hi guys, i am 100% php newb, so please be patience with me this code was used to get contact info and submit it via email .. i added "number" field, and the field shows up under the webpage, but for some reason it does not show up when user actually type in the digits and submits the form any advise? thanks in advance!!! <?php /* Template Name: Contact */ ?> <?php $numberError=''; $nameError=''; $emailError=''; $commentError=''; if(isset($_POST['submitted'])) { if(trim($_POST['contactName']) === '') { $nameError = 'Please enter your name.'; $hasError = true; } else { $name = trim($_POST['contactName']); } if(trim($_POST['email']) === '') { $emailError = 'Please enter your email address.'; $hasError = true; } else if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", trim($_POST['email']))) { $emailError = 'You entered an invalid email address.'; $hasError = true; } else { $email = trim($_POST['email']); } if(trim($_POST['comments']) === '') { $commentError = 'Please enter a message.'; $hasError = true; } else { if(function_exists('stripslashes')) { $comments = stripslashes(trim($_POST['comments'])); } else { $comments = trim($_POST['comments']); } } if(!isset($hasError)) { $emailTo = get_option('tz_email'); if (!isset($emailTo) || ($emailTo == '') ){ $emailTo = get_option('admin_email'); } $subject = '[Appointment Request] From '.$name; $body = "Name: $name \n\nEmail: $email \n\nComments: $comments \n\nNumber: $number "; $headers = 'From: '.$name.' <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email; mail($emailTo, $subject, $body, $headers); $emailSent = true; } } ?> <?php get_header(); ?> <!--Start Content Grid--> <div class="grid_24 content contact"> <div class="grid_16 alpha"> <div class="content-wrap"> <div class="content-info"> <?php if (function_exists('inkthemes_breadcrumbs')) inkthemes_breadcrumbs(); ?> </div> <!--Start Blog Post--> <div class="contact"> <h2> <?php the_title(); ?> </h2> <ul> <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?> <li> <?php if(isset($emailSent) && $emailSent == true) { ?> <div class="thanks"> <p><?php _e('Thanks, your request was sent successfully.','colorway'); ?></p> </div> <?php } else { ?> <?php the_content(); ?> <?php if(isset($hasError) || isset($captchaError)) { ?> <p class="error"><?php _e('Sorry, an error occured.','colorway'); ?> <p> <?php } ?> <form action="<?php the_permalink(); ?>" id="contactForm" method="post"> <ul class="contactform"> <li> <label for="contactName"><?php _e('Name:','colorway'); ?></label> <input type="text" name="contactName" id="contactName" value="<?php if(isset($_POST['contactName'])) echo $_POST['contactName'];?>" class="required requiredField" /> <?php if($nameError != '') { ?> <span class="error"> <?php echo $nameError;?> </span> <?php } ?> </li> <li> <label for="email"><?php _e('Email:','colorway'); ?></label> <input type="text" name="email" id="email" value="<?php if(isset($_POST['email'])) echo $_POST['email'];?>" class="required requiredField email" /> <?php if($emailError != '') { ?> <span class="error"> <?php echo $emailError;?> </span> <?php } ?> </li> <li> <label for="contactNumber"><?php _e('Phone Number:','colorway'); ?></label> <input type="text" name="number" id="contactNumber" value="<?php if(isset($_POST['number'])) echo $_POST['number'];?>" class="required requiredField" /> <?php if($numberError != '') { ?> <span class="error"> <?php echo $numberError;?> </span> <?php } ?> </li> <li> <label for="commentsText"><?php _e('Please provide day, time, type of service desired:','colorway'); ?></label> <textarea name="comments" id="commentsText" rows="20" cols="30" class="required requiredField"><?php if(isset($_POST['comments'])) { if(function_exists('stripslashes')) { echo stripslashes($_POST['comments']); } else { echo $_POST['comments']; } } ?> </textarea> <?php if($commentError != '') { ?> <span class="error"> <?php echo $commentError;?> </span> <?php } ?> </li> <li> <input type="submit" value="Send Email"/> </li> </ul> <input type="hidden" name="submitted" id="submitted" value="true" /> </form> <?php } ?> </li> <!-- End the Loop. --> <?php endwhile;?> </ul> </div> <div class="hrline"></div> <!--End Blog Post--> <div class="clear"></div> <div class="social_link"> </div> <div class="social_logo"> <a title="Tweet this!" href="http://twitter.com/home/?status=<?php the_title(); ?> : <?php the_permalink(); ?>"><img src="<?php echo get_template_directory_uri(); ?>/images/twitter-share.png" alt="twitter" title="twitter"/></a> <a title="Share on StumbleUpon!" href="http://www.stumbleupon.com/submit?url=<?php the_permalink(); ?>&title=<?php the_title(); ?>"><img src="<?php echo get_template_directory_uri(); ?>/images/stumbleupon.png" alt="upon" title="upon"/></a> <a title="Share on Facebook" href="http://www.facebook.com/sharer.php?u=<?php the_permalink();?>&t=<?php the_title(); ?>"><img src="<?php echo get_template_directory_uri(); ?>/images/facebook-share.png" alt="facebook" title="facebook"/></a> <a title="Digg This!" href="http://digg.com/submit?phase=2&url=<?php the_permalink(); ?>&title=<?php the_title(); ?>"><img src="<?php echo get_template_directory_uri(); ?>/images/digg-share.png" alt="digg" title="digg"/></a> </div> <div class="clear"></div> </div> </div> <?php get_sidebar(); ?> </div> <div class="clear"></div> <!--End Content Grid--> </div> <!--End Container Div--> <?php get_footer(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/265459-contact-form-submission/ Share on other sites More sharing options...
cyberRobot Posted July 10, 2012 Share Posted July 10, 2012 It looks like you need to read in the number like you do for the other POST variables. $name = trim($_POST['contactName']); Somewhere near the top, add the following: $number = trim($_POST['number']); Quote Link to comment https://forums.phpfreaks.com/topic/265459-contact-form-submission/#findComment-1360506 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.