Jump to content

My PHP Coded form is not working correctly!


Recommended Posts

Hello, I'm working on a website for a friend and can't seem to figure this out but it shows email progress right on the page without even sending a email just going to website!

I was wondering if someone can help me fix also diagnose why no emails are sending!

Thank you


Here is the PHP file:

called "form-to-email"

<?php/*Configuration You are to edit these configuration values. Not all of them need to be edited.However, the first few obviously need to be edited.EMAIL_RECIPIENTS - your email address where you want to get the form submission.*/$email_recipients = "support@nueroedge.com";//<<=== enter your email address here//$email_recipients =  "mymanager@gmail.com,his.manager@yahoo.com"; <<=== more than one recipients like this$visitors_email_field = 'email';//The name of the field where your user enters their email address                                        //This is handy when you want to reply to your users via email                                        //The script will set the reply-to header of the email to this email                                        //Leave blank if there is no email field in your form$email_subject = "New Form submission";$enable_auto_response = true;//Make this false if you donot want auto-response.//Update the following auto-response to the user$auto_response_subj = "Thanks for contacting us";$auto_response ="HiThanks for contacting us. We will get back to you soon!RegardsNueroEdge";/*optional settings. better leave it as is for the first time*/$email_from = ''; /*From address for the emails*/$thank_you_url = 'thank-you.html';/*URL to redirect to, after successful form submission*//*This is the PHP back-end script that processes the form submission.It first validates the input and then emails the form submission.The variable $_POST contains the form submission data.*/if(!isset($_POST['submit'])){    // note that our submit button's name is 'submit'     // We are checking whether submit button is pressed	// This page should not be accessed directly. Need to submit the form.	echo "error; you need to submit the form!".print_r($_POST,true);    exit;}require_once "includes/formvalidator.php";//Setup Validations$validator = new FormValidator();$validator->addValidation("fullname","req","Please fill in Name");$validator->addValidation("email","req","Please fill in Email");//Now, validate the formif(false == $validator->ValidateForm()){    echo "<B>Validation Errors:</B>";    $error_hash = $validator->GetErrors();    foreach($error_hash as $inpname => $inp_err)    {        echo "<p>$inpname : $inp_err</p>n";    }    exit;}$visitor_email='';if(!empty($visitors_email_field)){    $visitor_email = $_POST[$visitors_email_field];}if(empty($email_from)){    $host = $_SERVER['SERVER_NAME'];    $email_from ="forms@$host";}$fieldtable = '';foreach ($_POST as $field => $value){    if($field == 'submit')    {        continue;    }    if(is_array($value))    {        $value = implode(", ", $value);    }    $fieldtable .= "$field: $valuen";}$extra_info = "User's IP Address: ".$_SERVER['REMOTE_ADDR']."n";$email_body = "You have received a new form submission. Details below:n$fieldtablen $extra_info";    $headers = "From: $email_from rn";$headers .= "Reply-To: $visitor_email rn";//Send the email!@mail(/*to*/$email_recipients, $email_subject, $email_body,$headers);//Now send an auto-response to the user who submitted the formif($enable_auto_response == true && !empty($visitor_email)){    $headers = "From: $email_from rn";    @mail(/*to*/$visitor_email, $auto_response_subj, $auto_response,$headers);}//done. if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])    AND strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest') {    //This is an ajax form. So we return success as a signal of succesful processing    echo "success";}else{    //This is not an ajax form. we redirect the user to a Thank you page    header('Location: '.$thank_you_url);}?>

Here is the HTML:

This would be the "contactus.html"

<!DOCTYPE HTML><!--	Solarize by TEMPLATED	templated.co @templatedco	Released for free under the Creative Commons Attribution 3.0 license (templated.co/license)--><html>	<head>		<title>NueroEdge | Contact Us!</title>		<meta http-equiv="content-type" content="text/html; charset=utf-8" />		<meta name="description" content="" />		<meta name="keywords" content="" />		<!--[if lte IE 8]><script src="css/ie/html5shiv.js"></script><![endif]-->		<script src="js/jquery.min.js"></script>		<script src="js/jquery.dropotron.min.js"></script>		<script src="js/skel.min.js"></script>		<script src="js/skel-layers.min.js"></script>		<script src="js/init.js"></script>			<!-- JavaScript Files -->    <script type="text/javascript" src="http://code.jquery.com/jquery-1.11.0.min.js"></script>    <script type="text/javascript" src="js/jquery.validate.min.js"></script>    <script type="text/javascript" src="js/additional-methods.min.js"></script>    <script type="text/javascript" src="js/main.js"></script>    <!-- End JavaScript Files -->		<noscript>			<link rel="stylesheet" href="css/skel.css" />			<link rel="stylesheet" href="css/style.css" />		</noscript>		<!--[if lte IE 8]><link rel="stylesheet" href="css/ie/v8.css" /><![endif]-->	</head>	<body>		<!-- Header Wrapper -->			<div class="wrapper style1">						<!-- Header -->				<div id="header">					<div class="container">													<!-- Logo -->							<h1><a href="#" id="logo">NueroEdge</a></h1>												<!-- Nav -->							<nav id="nav">															<ul>																	<li class="active">									<a href="index.html">Home</a>                                    <ul>											<li><a href="aboutus.html">About Us</a></li>											<li><a href="contactus.html">Contact Us</a></li>									</li>								</ul>									<li><a href="left-sidebar.html">Application</a></li>									<li><a href="right-sidebar.html">Leader board</a></li>									<li>										<a href="">Team List</a>										<ul>											<li><a href="no-sidebar.html">Ryan Tarson</a></li>											<li><a href="no-sidebar.html">Kavin I.</a></li>									</li>								</ul>								<li>										<a href="">More...</a>										<ul>											<li><a href="#">Lorem ipsum dolor</a></li>											<li><a href="#">Magna phasellus</a></li>											<li><a href="#">Etiam dolore nisl</a></li>											<li>												<a href="">Phasellus consequat</a>												<ul>													<li><a href="#">Lorem ipsum dolor</a></li>													<li><a href="#">Phasellus consequat</a></li>													<li><a href="#">Magna phasellus</a></li>													<li><a href="#">Etiam dolore nisl</a></li>													<li><a href="#">Veroeros feugiat</a></li>												</ul>											</li>											<li><a href="#">Veroeros feugiat</a></li>										</ul>									</li>							</nav>						</div>				</div>				</div>				<!-- Main -->							<!-- Content -->				<div id="main" class="wrapper style4">				<div id="content" class="container">					<section>						<header class="major">							<h2>Contact Us</h2>							<span class="byline">Want to get in touch?</span>						</header>						<p>Welcome to the Contact us page please drop us a line with any questions you may have! This message will be reviewed and wrote back to within 24hr! Please do not send rude messages or irrelevant messages! Thank you! </p>						<p>Do not use this system to reply to us! We will message back to you, if you need to reply to our message just use the open ticket and reply to our email! Thanks!</p>						<div class="contact-form">        <h1>Contact Us</h1>		<form id="contact-form" method="POST" action="form-to-email.php">			<div class="control-group">				<label>Your Name</label>				<input class="fullname" type="text" name="fullname" />			</div>			<div class="control-group">				<label>Email</label>				<input class="email" type="text" name="email" />			</div>			<div class="control-group">				<label>Phone (optional)</label>				<input class="phone" type="text" name="phone" />			</div>			<div class="control-group">				<label>Message</label>				<textarea class="message" name="message"></textarea>			</div>			<div id="errors"></div>			<div class="control-group no-margin">			<br>				<input type="submit" name="submit" value="Submit" id="submit" />			</div>		</form>		        <div id='msg_submitting'><h2>Submitting ...</h2></div>        <div id='msg_submitted'><h2>Thank you !<br> The form was submitted Successfully.</h2></div> 	</div>	</div>	</div>					</section>				</div>			<div class="wrapper style2">				<section class="container">					<div class="row double">						<div class="6u">						<header class="major">							<div class="boxA">							<br>								<h2>NueroEdge YouTube  <img src="images/youtubeicon.png" alt="YouTube" style="width:50px;height:35px"></h2>								<span class="byline">We here at NueroEdge are a Friendly Competitive team. We have are great YouTube channel we will try our best to keep up with our weekly uploads! Click the button below!</span>								<br>								<a href="#" class="button">NueroEdge YT</a>							</header>						</div>						<div class="6u">							<h3>Twitch Streaming   <img src="images/twitch.png" alt="Twitch TV" style="width:50px;height:50px"></h3>							<font size="5"><p>Here at NueroEdge we have our own Twitch Streaming Team! Want to watch or check out what we do? Go ahead and click the button down below!</p></font>							<a href="#" class="button">Twitch Streaming</a>													</div>	</div>	</section>	</div> 	</div>		<!-- Team -->                <div class="wrapper style5">                    <section id="team" class="container">                        <header class="major">                            <h2>Key Members/Co-Founder</h2>                            <span class="byline">These are the people who make it Happen! Click the Picture for twitter</span>                        </header>                        <div class="row">                            <div class="3u">                                <a href="#" class="image"><img src="images/ryantarson.png" alt="" style="width:162px;height:162px"></a>                                <h3>Ryan Tarson</h3>                                <p>Ryan is a Contributor, Website Developer, Social Media Admin, Account Managers, Hosting, Financial Advisor, PC Gamer/PC streamer</p>                            </div>                            <div class="3u">                                <a href="#" class="image"><img src="images/kavini.png" alt="" style="width:162px;height:162px"></a>                                <h3>Kavin I.</h3>                                <p>Kavin is a Contributor, GFX Artist, Streamer, Competitive Gamer, Social Media Modarator, Account Manager</p>                            </div>                            <div class="3u">                                <a href="#" class="image"><img src="images/placeholder.png" alt="" style="width:162px;height:162px"></a>                                <h3>Help Wanted</h3>                                <p>Another Develper Needed</p>                            </div>                            <div class="3u">                                <a href="#" class="image"><img src="images/placeholder.png" alt="" style="width:162px;height:162px"></a>                                <h3>Help Wanted</h3>                                <p>Streamer/Competitive Player. Trust worthy</p>                            </div>                        </div>                    </section>                </div>                <!-- Footer -->                <div id="footer">                    <section class="container">                        <header class="major">                            <h2>Connect with us</h2>                            <span class="byline">Want to stay up to date? Follow our Social Media Networks.</span>                        </header>                        <ul class="icons">                            <li class="active"><a href="https://www.facebook.com/pages/NueroEdge/1560679180842070" class="fa fa-facebook"><span>Facebook</span></a></li>                            <li><a href="https://twitter.com/NueroEdge" class="fa fa-twitter"><span>Twitter</span></a></li>                            <li><a href="#" class="fa fa-youtube-play"><span>YouTube</span></a></li>                            <li><a href="https://plus.google.com/111096761474269802283/about" class="fa fa-google-plus"><span>Google+</span></a></li>							<li><a href="#" class="fa fa-envelope"><span>Mail></a></li>                        </ul>                        <hr />                    </section>                    <!-- Copyright -->                    <div id="copyright">                        ©2014 <a href="http://nueroedge.com">NueroEdge</a>  All Rights Reserved | <a href="http://nueroedge.com">Contact Us |</a> <a href="http://nueroedge.com/cc0">Team Members </a>                    </div>                </div></body></html>
Link to comment
Share on other sites

it shows email progress right on the page

What do you mean, what does it show?

I was wondering if someone can help me fix also diagnose why no emails are sending!

What happens when you submit the form? One thing to do is to remove the @ operators in front of the 2 mail functions, those will hide error messages. Another is to add this to the top of your PHP code:
ini_set('display_errors', 1);error_reporting(E_ALL);
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...