Form wont send

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
perkinsDP
Forum Newbie
Posts: 8
Joined: Wed Sep 16, 2009 2:51 pm

Form wont send

Post by perkinsDP »

Hey guys my form validates well but when everything in the form is filled out it wont send it just reloads the form with my info still in it and i cant seem to figure out why im sure its simple.

Code: Select all

 
if (isset($_POST['$contents'] )) { 
                            $contents .= "name, Email, phone, details";
                            $ToEmail .= 'brendan@designpilotonline.com'; 
                            $EmailSubject .= 'Quote Form'; 
                            $mailheader .= "From: ".$_POST["name"]."\r\n"; 
                            $mailheader .= "Reply-To: ".$_POST["Email"]."\r\n"; 
                            $mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n"; 
                            $MESSAGE_BODY .= "Name/Company: ".$_POST["name"]."<br />";  
                            $MESSAGE_BODY .= "Email: ".$_POST["Email"]."<br />";
                            $MESSAGE_BODY .= "Phone: ".$_POST["phone"]."<br />"; 
                            $MESSAGE_BODY .= "Time: ".$_POST["call_option"]."<br />"; 
                            $MESSAGE_BODY .= "Development for: ".$_POST["development_for"]."<br /><br />"; 
                            $MESSAGE_BODY .= "Project Details:<br /><br /> ".nl2br($_POST["details"])."<br />"; 
                            
                            if ($contents != ''){
                            mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); 
                            }
                            else {
                            echo 'Could Not send RFP ';
                            }
 
 
User avatar
desperado
Forum Commoner
Posts: 46
Joined: Wed Dec 10, 2008 8:49 am

Re: Form wont send

Post by desperado »

what is the target of the form?
perkinsDP
Forum Newbie
Posts: 8
Joined: Wed Sep 16, 2009 2:51 pm

Re: Form wont send

Post by perkinsDP »

the target is #quote(using jquery for page) i just changed my code and it still does the same thing it wont let me do anything until all fields are filled in but then just reloads the form with my values still there and wont send

Code: Select all

 
        if ($_POST["Email, phone, name, details"]<>'') { 
                            $ToEmail .= 'brendan@designpilotonline.com'; 
                            $EmailSubject .= 'Quote Form'; 
                            $mailheader .= "From: ".$_POST["name"]."\r\n"; 
                            $mailheader .= "Reply-To: ".$_POST["Email"]."\r\n"; 
                            $mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n"; 
                            $MESSAGE_BODY .= "Name/Company: ".$_POST["name"]."<br />";  
                            $MESSAGE_BODY .= "Email: ".$_POST["Email"]."<br />";
                            $MESSAGE_BODY .= "Phone: ".$_POST["phone"]."<br />"; 
                            $MESSAGE_BODY .= "Time: ".$_POST["call_option"]."<br />"; 
                            $MESSAGE_BODY .= "Development for: ".$_POST["development_for"]."<br /><br />"; 
                            $MESSAGE_BODY .= "Project Details:<br /><br /> ".nl2br($_POST["details"])."<br />"; 
                            
                            if ($name != '' || $Email != '' || $phone != '' || $details != '' ){
                            mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader); 
                            echo '<div id="formmessage">
                                <p>Thank you for your submission. We are now thinking of the best possible solution for your project and will be back to you in the next 1 to 2 working days. If this is urgent contact info@designpilotonline.com or call us at 1 416 538 3003.
                                -Design Pilot</p>
                            </div>';
                            }
                            else {
                            echo 'Could Not send RFP ';
                            }
                            }
 
User avatar
desperado
Forum Commoner
Posts: 46
Joined: Wed Dec 10, 2008 8:49 am

Re: Form wont send

Post by desperado »

I don't understand the following:

$_POST['$contents']

should be

$_POST['contents'] (no $)


also <> is a math operator.

I would write it

Code: Select all

if ($_POST['Email'] != "" && $_POST['phone'] != "" && $_POST['name'] != "" && $_POST['details'] != "")
perkinsDP
Forum Newbie
Posts: 8
Joined: Wed Sep 16, 2009 2:51 pm

Re: Form wont send

Post by perkinsDP »

thanks that worked it now validates everything good and sends me the form but after i click submit the message comes up saying the form was sent and i recieve it to my email but the form it self is still sitting there underneath the thank you message im not sure why it doesnt go away

Code: Select all

 
    if ($_POST['Email'] != "" && $_POST['phone'] != "" && $_POST['name'] != "" && $_POST['details'] != "") { 
                            $ToEmail .= 'brendan@designpilotonline.com'; 
                            $EmailSubject .= 'Quote Form'; 
                            $mailheader .= "From: ".$_POST["name"]."\r\n"; 
                            $mailheader .= "Reply-To: ".$_POST["Email"]."\r\n"; 
                            $mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n"; 
                            $MESSAGE_BODY .= "Name/Company: ".$_POST["name"]."<br />";  
                            $MESSAGE_BODY .= "Email: ".$_POST["Email"]."<br />";
                            $MESSAGE_BODY .= "Phone: ".$_POST["phone"]."<br />"; 
                            $MESSAGE_BODY .= "Time: ".$_POST["call_option"]."<br />"; 
                            $MESSAGE_BODY .= "Development for: ".$_POST["development_for"]."<br /><br />"; 
                            $MESSAGE_BODY .= "Project Details:<br /><br /> ".nl2br($_POST["details"])."<br />"; 
                            
                            if ($_POST['Email'] != "" && $_POST['phone'] != "" && $_POST['name'] != "" && $_POST['details'] != ""){
                            mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader); 
                            echo '<div id="formmessage">
                                <p>Thank you for your submission. We are now thinking of the best possible solution for your project and will be back to you in the next 1 to 2 working days. If this is urgent contact info@designpilotonline.com or call us at 1 416 538 3003.
                                -Design Pilot</p>
                                </div>';
                            }
                            else {
                            echo 'Could Not send RFP ';
                            }
                            }
 
User avatar
desperado
Forum Commoner
Posts: 46
Joined: Wed Dec 10, 2008 8:49 am

Re: Form wont send

Post by desperado »

hard to say because you only post a part of your code, but my guess is that because it's all in the same file, it executes this bit of code, and after that, renders your form.

you would have to wrap your form within the "}else{" clause for it not to display.

the logic would then be:

if (all fields filled out){
send the email and <span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span>;
}else{
booboo message;
display form;
}
perkinsDP
Forum Newbie
Posts: 8
Joined: Wed Sep 16, 2009 2:51 pm

Re: Form wont send

Post by perkinsDP »

THANK YOU it works now just how i want it too thank you soo much for your help, yea i didnt post all my code because its like 10 pages in one using jquery so the code is extremely long.

again THANK YOU
Post Reply