Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

php form not submitting

Hi guys,

I had created a form and it worked beautifully. After i've added some now field it suddently didnst submit any more. can you please help?

Working form:

<!DOCTYPE HTML> <?php

// controller code $domainreg = $_POST["domainreg"]; $cars = $_POST["cars"]; $domain = $_POST["domain"]; $domainnew = $_POST["domainnew"]; $domainmove = $_POST["domainmove"]; $domainnamenew = $_POST["domainnamenew"]; $domainnamemove = $_POST["domainnamemove"]; $domainnamecode = $_POST["domainnamecode"]; $hosting = $_POST["hosting"]; $exchange = $_POST["exchange"]; $domainnameexchange = $_POST["domainnameexchange"]; $antivirus = $_POST["antivirus"]; $backup = $_POST["backup"]; $office = $_POST["office"]; $desktop = $_POST["desktop"]; $sugar = $_POST["sugar"]; $noma = $_POST["noma"]; $sumprice = $_POST["sumprice"];

if ($_SERVER["REQUEST_METHOD"] == "POST") { $domainreg = $_POST["domainreg"]; $name = trim($_POST["Fullname"]); $company = trim($_POST["Company"]); $email = trim($_POST["email"]); $password = trim($_POST["password"]);

if ($name == "" OR $email == "" OR $company == "" OR $password == "") {
    $error_message = "These values all need to be filled in"; 
}

if (!isset($error_message)) {
    foreach( $_POST as $value ){
        if( stripos($value, 'Content-Type:') !== FALSE ){
            $error_message = "there was a problem with the information you entered.";
        }
    }
}

if (!isset($error_message) AND $_POST["address"] !="") {
$error_message = "Your form submission has an error.";
}

require_once("inc/class.phpmailer.php");
$mail = new PHPMailer();


if (!isset($error_message) AND !$mail->ValidateAddress($email)){
$error_message = "You must specify a valid email address.";
}

if (!isset($error_message)) {

    $email_body = "";
    $email_body = $email_body . "Name: " . $name . "<br>";
    $email_body = $email_body . "Organization: " . $company . "<br>";
    $email_body = $email_body . "Email: " . $email . "<br>";
    $email_body = $email_body . "Password: " . $password . "<br>";
    $email_body = $email_body . "domainreg: " . $domainreg . "<br>";        

    $mail->IsSendmail(); // telling the class to use SendMail transport

    $mail->SetFrom($mail, $name);

    $address = "info@meetlink.net";
    $mail->AddAddress($address, "EasyNimbus");

    $mail->Subject    = "EasyNimbus order Submission  | " . $name;

    $mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test

    $mail->MsgHTML($email_body);

    $mail->AddAttachment("images/phpmailer.gif");      // attachment
    $mail->AddAttachment("images/phpmailer_mini.gif"); // attachment

    if($mail->Send()) {
    header("Location: contact-thanks.php");
    exit;       
    } else {
     $error_message = "Mailer Error: " . $mail->ErrorInfo;
    }

}

}

?>

<html> <head> <meta http-equiv="Content-Type" Content="text/html; charset=utf-8"/> <title>EasyNimbus | The easiest way to get into the Cloud</title> <link rel="stylesheet" href="css/normalize.css" type="text/css" media="screen"> <link rel="stylesheet" href="css/style.css" type="text/css" media="screen"> <style> a:link {color: inherit;} /* unvisited link / a:visited {color: inherit;} / visited link / a:hover {color: inherit;} / mouse over link / a:active {color: inherit;} / selected link / a.btnconfirm:link {color:#FFFFFF;} / unvisited link / a.btnconfirm:visited {color:#FFFFFF;} / visited link / a.btnconfirm:hover {color:#FFFFFF;} / mouse over link / a.btnconfirm:active {color:#FFFFFF;} / selected link */ </style> </head> <body> <div class="page-containerorder"> <div id="bodyorder"> <div class="main-navwhite"> <div id="logo"> <a href="index.php"><img src="img/logo.png" alt="logo"></a> </div> <div id="ordersteps"> <p class="step1">Get into the cloud, Step 2 of 2</p> </div>
</div>
</div> <div id="float"> <div id="payment"> <div id="imagepayment"> <img src="img/cloudcartoon.jpg" alt="cloud cartoon"> </div> <div id="registrationfields"> <p class="headerpay">We just need a few details so we can get you into the <b>Cloud</b>:)</p> <p id="thankyou">Thank you for choosing EasyNimbus. After submitting you will receive your control panel login credentials and activation mails.</p> <div id="formpayment"><p class="regheader">1. Tell us about yourself</p> <?php if (isset($error_message)) { echo '<p class="message">' . $error_message . '</p>'; } ?>
<form name="myForm" action="payment.php" onSubmit="return validateForm();" method="post">

                <input type="text" class="regfield" id="fullname" name="Fullname" placeholder="Your full name" value="<?php if(isset($name)) { echo htmlspecialchars($name); } ?>">
                <input type="text" class="regfield" name="Company" placeholder="Company or Organisation" value="<?php if(isset($company)) { echo htmlspecialchars($company); } ?>">
                <input type="email" class="regfield" id="email" name="email" placeholder="Your email address*" value="<?php if(isset($email)) { echo htmlspecialchars($email); } ?>">
                <input type="password" class="regfield" name="password" placeholder="Pick a password*">
                <p style="display: none;">
                <input type="text" class="address" name="address" placeholder="address">
                Humans: please leave this field blank
                </p>
                <p class="note">* Email address and password will grant you access to your control panel</p>
                <br>
                <p class="submit">
                <input type="submit"  type="submit" name="submit" value="Confirm and charge my card $XX/month" id="submit">
                </form> 


            </form>
            </div>
        </div>
    </div>
    </div>

    <div id="footer">
        <div id="logolinks">
                <div class="logosubtext">
                <div class="logobelow">
                <a href="index.php"><img src="img/logo.png" alt="logo">
                </div>
                <p>Our mission is to make Cloud Computing available for everyone</p>
                </div>
                <ul class="footerproduct">
                    <li class="first">Product</li>
                    <li><a href="index.php">Home</a></li>
                    <li><a href="whyeasynimbus.html">Why EasyNimbus</a></li>
                    <li><a href="#">Login</a></li>
                    <li><a href="#">Help &amp; Support</a></li>
                </ul>
                <br>
                <ul class="footercompany">
                    <li class="first">Company</li>
                    <li><a href="about.html">About Us</a></li>
                    <li><a href="#">Contact Us</a></li>
                </ul>
                <br>
                <br>
                <div class="twitter"    
                    <a href="http://twitter.com/#"><img class="twitter" src="img/buttons/twitter.jpg" alt="twitter"</a><a class="twitter-link" href="http://twitter.com/#">Follow us on Twitter</a>
                </div>
                <div id="copyright">
                <p>&copy;<?php echo date('Y'); ?> EasyNimbus, a Meetlink.net initiative. All rights reserved.</p>
                </div>
        </div>
    </div>
</div>

</body>

New form that doens work anymore:

<!DOCTYPE HTML> <?php

// controller code $domainreg = $_POST["domainreg"]; $cars = $_POST["cars"]; $domain = $_POST["domain"]; $domainnew = $_POST["domainnew"]; $domainmove = $_POST["domainmove"]; $domainnamenew = $_POST["domainnamenew"]; $domainnamemove = $_POST["domainnamemove"]; $domainnamecode = $_POST["domainnamecode"]; $hosting = $_POST["hosting"]; $exchange = $_POST["exchange"]; $domainnameexchange = $_POST["domainnameexchange"]; $antivirus = $_POST["antivirus"]; $backup = $_POST["backup"]; $office = $_POST["office"]; $desktop = $_POST["desktop"]; $sugar = $_POST["sugar"]; $noma = $_POST["noma"]; $sumprice = $_POST["sumprice"];

if ($_SERVER["REQUEST_METHOD"] == "POST") { $name = trim($_POST["Fullname"]); $company = trim($_POST["Company"]); $password = trim($_POST["Password"]);
$email = trim($_POST["email"]); $password = trim($_POST["password"]); $terms = trim($_POST["terms"]); $voorletters = trim($_POST["Voorletters"]); $adres = trim($_POST["Adres"]); $postcode = trim($_POST["Postcode"]); $plaats = trim($_POST["Plaats"]); $rekeningnummer = trim($_POST["Rekeningnummer"]); $bank = trim($_POST["bank"]);

if ($name == "" OR $email == "" OR $company == "" OR $password == "" OR $terms == "" OR $voorletters == "" OR $adres == "" OR $postcode == "" OR $plaats == "" OR $rekeningnummer == "" OR $password == "") {
    $error_message = "U dient alle velden in te vullen"; 
}

if (!isset($error_message)) {
    foreach( $_POST as $value ){
        if( stripos($value, 'Content-Type:') !== FALSE ){
            $error_message = "Er is een probleem met de informatie die u heeft ongevoegd.";
        }
    }
}

if (!isset($error_message) AND $_POST["address"] !="") {
$error_message = "Uw gegevens kloppen niet.";
}

require_once("inc/class.phpmailer.php");
$mail = new PHPMailer();


if (!isset($error_message) AND !$mail->ValidateAddress($email)){
$error_message = "Gebruik een geldig emailadres";
}

if (!isset($error_message)) {

    $email_body = "";
    $email_body = $email_body . "Name: " . $name . "<br>";
    $email_body = $email_body . "Organization: " . $company . "<br>";
    $email_body = $email_body . "Email: " . $email . "<br>";
    $email_body = $email_body . "Password: " . $password . "<br>";      
    $email_body = $email_body . "Password: " . $password . "<br>";
    $email_body = $email_body . "Voorletters: " . $voorletters . "<br>";    
    $email_body = $email_body . "Adres: " . $adres . "<br>";
    $email_body = $email_body . "Postcode: " . $postcode . "<br>";  
    $email_body = $email_body . "Plaats: " . $plaats . "<br>";
    $email_body = $email_body . "Rekeningnummer: " . $rekeningnummer . "<br>";      
    $email_body = $email_body . "Bank: " . $bank . "<br>";  
    $email_body = $email_body . "domainreg: " . $domainreg . "<br>";
    $email_body = $email_body . "cars: " . $cars . "<br>";
    $email_body = $email_body . "Domain: " . $domain . "<br>";
    $email_body = $email_body . "Domainnew: " . $domainnew . "<br>";
    $email_body = $email_body . "Domainmove: " . $domainmove . "<br>";
    $email_body = $email_body . "Domainnew: " . $domainnamenew . "<br>";
    $email_body = $email_body . "Domainmove: " . $domainnamemove . "<br>";      
    $email_body = $email_body . "Domainname: " . $domainnamecode . "<br>";
    $email_body = $email_body . "Hosting: " . $hosting . "<br>";
    $email_body = $email_body . "Exchange: " . $exchange . "<br>";
    $email_body = $email_body . "Domainnameexchange: " . $domainnameexchange . "<br>";
    $email_body = $email_body . "Antivirus: " . $antivirus . "<br>";
    $email_body = $email_body . "Backup: " . $backup . "<br>";  
    $email_body = $email_body . "Office: " . $office . "<br>";
    $email_body = $email_body . "Desktop: " . $desktop . "<br>";    
    $email_body = $email_body . "Sugar: " . $sugar . "<br>";
    $email_body = $email_body . "Noma: " . $noma . "<br>";      
    $email_body = $email_body . "Sumprice: " . $sumprice . "<br>";  

    $mail->IsSendmail(); // telling the class to use SendMail transport

    $mail->SetFrom($mail, $name);

    $address = "info@meetlink.net";
    $mail->AddAddress($address, "EasyNimbus");

    $mail->Subject    = "EasyNimbus bestelling  | " . $name;

    $mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test

    $mail->MsgHTML($email_body);

    $mail->AddAttachment("images/phpmailer.gif");      // attachment
    $mail->AddAttachment("images/phpmailer_mini.gif"); // attachment

    if($mail->Send()) {
    header("Location: contact-thanks.php");
    exit;       
    } else {
     $error_message = "Mailer Error: " . $mail->ErrorInfo;
    }

}

}

?>

<html> <head> <meta http-equiv="Content-Type" Content="text/html; charset=utf-8"/> <title>EasyNimbus | Bestelling afronden</title> <link rel="stylesheet" href="css/normalize.css" type="text/css" media="screen"> <link rel="stylesheet" href="css/style.css" type="text/css" media="screen"> <style> a:link {color: inherit;} /* unvisited link / a:visited {color: inherit;} / visited link / a:hover {color: inherit;} / mouse over link / a:active {color: inherit;} / selected link / a.btnconfirm:link {color:#FFFFFF;} / unvisited link / a.btnconfirm:visited {color:#FFFFFF;} / visited link / a.btnconfirm:hover {color:#FFFFFF;} / mouse over link / a.btnconfirm:active {color:#FFFFFF;} / selected link / </style> </head> <body> <div class="page-containerorder"> <div id="bodyorder"> <div class="main-navwhite"> <div id="logo"> <a href="index.php"><img src="img/logo.png" alt="logo"></a> </div> <div id="ordersteps"> <p class="step1">Get into the cloud, Stap 2 van 2</p> </div>
</div>
</div> <div id="float"> <div id="payment"> <div id="imagepayment"> <img src="img/cloudcartoon.jpg" alt="cloud cartoon"> </div> <div id="registrationfields"> <p class="headerpay">We zijn er bijna! We hebben alleen nog wat persoonlijke informatie nodig:)</p> <p id="thankyou">Hartelijk dank voor uw vertrouwen in EasyNimbus. Na afronding van uw bestelling zult u binnen <strong>8 uur</strong> uw activatiemails ontvangen.</p> <div id="formpayment"><p class="regheader">1. Persoonlijke informatie</p> <?php if (isset($error_message)) { echo '<p class="message">' . $error_message . '</p>'; } ?>
<form name="myForm" action="payment.php" method="post"> <input type="hidden" name="domainreg" value="<?php echo htmlspecialchars($domainreg); ?>"> <input type="hidden" name="cars" value="<?php echo htmlspecialchars($cars); ?>"> <input type="hidden" name="domain" value="<?php echo htmlspecialchars($domain); ?>"> <input type="hidden" name="domainnew" value="<?php echo htmlspecialchars($domainnew); ?>"> <input type="hidden" name="domainmove" value="<?php echo htmlspecialchars($domainmove); ?>">
<input type="hidden" name="domainnamemove" value="<?php echo htmlspecialchars($domainnamemove); ?>">
<input type="hidden" name="domainnamenew" value="<?php echo htmlspecialchars($domainnamenew); ?>"> <input type="hidden" name="domainnamecode" value="<?php echo htmlspecialchars($domainnamecode); ?>">
<input type="hidden" name="hosting" value="<?php echo htmlspecialchars($hosting); ?>">
<input type="hidden" name="exchange" value="<?php echo htmlspecialchars($exchange); ?>">
<input type="hidden" name="domainnameexchange" value="<?php echo htmlspecialchars($domainnameexchange); ?>">
<input type="hidden" name="antivirus" value="<?php echo htmlspecialchars($antivirus); ?>"> <input type="hidden" name="backup" value="<?php echo htmlspecialchars($backup); ?>">
<input type="hidden" name="office" value="<?php echo htmlspecialchars($office); ?>">
<input type="hidden" name="desktop" value="<?php echo htmlspecialchars($desktop); ?>">
<input type="hidden" name="sugar" value="<?php echo htmlspecialchars($sugar); ?>">
<input type="hidden" name="noma" value="<?php echo htmlspecialchars($noma); ?>">
<input type="hidden" name="sumprice" id="sumprice" value="<?php echo htmlspecialchars($sumprice); ?>">
<input type="text" class="regfield" id="voorletters" name="Voorletters" placeholder="Voorletters" value="<?php if(isset($voorletters)) { echo htmlspecialchars($voorletters); } ?>"> <input type="text" class="regfield" id="fullname" name="Fullname" placeholder="Achternaam" value="<?php if(isset($name)) { echo htmlspecialchars($name); } ?>"> <input type="text" class="regfield" name="Company" placeholder="Bedrijfsnaam" value="<?php if(isset($company)) { echo htmlspecialchars($company); } ?>"> <input type="text" class="regfield" id="adres" name="Adres" placeholder="Adres" value="<?php if(isset($adres)) { echo htmlspecialchars($adres); } ?>"> <input type="text" class="regfield" name="Postcode" placeholder="Postcode" value="<?php if(isset($company)) { echo htmlspecialchars($company); } ?>"> <input type="text" class="regfield" id="plaats" name="Plaats" placeholder="Plaats" value="<?php if(isset($plaats)) { echo htmlspecialchars($plaats); } ?>">
<input type="email" class="regfield" id="email" name="email" placeholder="Emailadres
" value="<?php if(isset($email)) { echo htmlspecialchars($email); } ?>"> <input type="password" class="regfield" name="Password" placeholder="Wachtwoord*" value="<?php if(isset($password)) { echo htmlspecialchars($password); } ?>"> <p style="display: none;"> <input type="text" class="address" name="address" placeholder="address"> Humans: please leave this field blank </p> <div id="formpayment"><p class="regheader">2. Betaal Informatie</p> Betaalwijze: Automatische incasso<br> <input type="text" class="regfield" id="rekeningnummer" name="Rekeningnummer" placeholder="Rekeningnummer" value="<?php if(isset($rekening)) { echo htmlspecialchars($rekening); } ?>">
<span id="radiooption1">Bank<input type="radio" name="bank" checked="checked" value="bank" /></span> <span id="radiooption2">Giro<input type="radio" name="bank" value="giro" /></span><br> <p class="note">* Emailadres en wachtwoord zal u toegang verlenen tot uw controlpanel.</p> <br> Ik ga akkoord met de <a href="termsofuse.php"><u>Algemene Voorwaarden</u></a> <input type="checkbox" name="terms"/> <p class="submit"> <input type="submit" type="submit" name="submit" value="Bevestig en betaal &euro;<?php echo htmlspecialchars($sumprice); ?>/maand" id="submit"> </form>

            </form>
            </div>
        </div>
    </div>
    </div>

    <div id="footer">
        <div id="logolinks">
                <div class="logosubtext">
                <div class="logobelow">
                <a href="index.php"><img src="img/logo.png" alt="logo">
                </div>
                <p>Our mission is to make Cloud Computing available for everyone</p>
                </div>
                <ul class="footerproduct">
                    <li class="first">Product</li>
                    <li><a href="index.php">Home</a></li>
                    <li><a href="whyeasynimbus.php">Waarom EasyNimbus</a></li>
                    <li><a href="#">Login</a></li>
                    <li><a href="#">Ondersteuning</a></li>
                </ul>
                <br>
                <ul class="footercompany">
                    <li class="first">Bedrijf</li>
                    <li><a href="about.php">Over Ons</a></li>
                    <li><a href="#">Contact</a></li>
                    <li><a href="termsofuse.php">Algemene Voorwaarden</a></li>                              
                </ul>
                <br>
                <br>
                <div class="twitter"    
                    <a href="http://twitter.com/#"><img class="twitter" src="img/buttons/twitter.jpg" alt="twitter"</a><a class="twitter-link" href="http://twitter.com/#">Follow us on Twitter</a>
                </div>
                <div id="copyright">
                <p>&copy;<?php echo date('Y'); ?> EasyNimbus, a Meetlink.net initiative. All rights reserved.</p>
                </div>
        </div>
    </div>
</div>

</body>

hope you can help..

James Barnett
James Barnett
39,199 Points

Posting a few hundred lines of code to a forum unformatted isn't really productive. Instead I suggest you check out reduced test cases and narrow down your problem first.

1 Answer

Hi, Its difficult to see your code in this way. Can you submit in other way. Also I can see your form tag