Kathy Posted June 22, 2009 Share Posted June 22, 2009 I haven't got a clue what I'm doing wrong! I've made a registration form, added all the php I though necessary, linked the database and when you enter code on it, nothing happens, the entries clear, the emails, don't send, and the data doesn't get saved into the database! So frustrating!!! Here is my code: <?php include("dbinc.php"); require("ClassMathGuard.php"); include("checkUser.php"); //add a hit $addHit = "insert into hit(last_modified, page) values(CURDATE(), 'submit')"; mysql_query($addHit, $con); //check to see if the user clicked on the register button if(isset($_POST["submit"])) { //check the mathguard if (MathGuard :: checkResult($_POST['mathguard_answer'], $_POST['mathguard_code'])) { //get the values from the form $initials = $_POST['initials']; $surname = $_POST['surname']; $company = $_POST['company']; $address = $_POST['address']; $city = $_POST['city']; $code = $_POST['code']; $tel = $_POST['tel']; $email = $_POST['email']; $production = $_POST['production']; $supplier = $_POST['supplier']; $wine = $_POST['wine']; $fruit = $_POST['fruit']; $both = $_POST['both']; $ander = $_POST['ander']; $owner = $_POST['owner']; $finance = $_POST['finance']; $hr = $_POST['hr']; $sales = $_POST['sales']; $fm = $_POST['fm']; $research = $_POST['research']; $is = $_POST['is']; $viticulture = $_POST['viticulture']; $production = $_POST['prodcution']; $retail = $_POST['retail']; $buying = $_POST['buying']; $distribution = $_POST['distribution']; $student = $_POST['student']; $other = $_POST['other']; if (isset($_POST['Submit'])) { $selected_radio = $_POST['method']; if ($selected_radio == 'production') { $production_status = 'checked'; } else if ($selected_radio == 'supplier') { $supplier_status = 'checked'; } } if (isset($_POST['Submit'])) { $selected_radio = $_POST['type']; if ($selected_radio == 'wine') { $wine_status = 'checked'; } if ($selected_radio == 'fruit') { $fruit_status = 'checked'; } if ($selected_radio == 'both') { $both_status = 'checked'; } else if ($selected_radio == 'ander') { $ander_status = 'checked'; } } //check that the required fields have been filled in if (($surname <> '') && ($cell <> '') && ($email <> '') && ((isset($production)) || (isset($supplier)) || (isset($wine)) || (isset($fruit)) || (isset($both)) || (isset($ander)) || (isset($owner)) || (isset($finance)) || (isset($hr)) || (isset($sales)) || (isset($fm)) || (isset($research)) || (isset($is)) || (isset($viticulture)) || (isset($production)) || (isset($retail)) || (isset($buying)) || (isset($distribution)) || (isset($student)) || (isset($other)))) { //insert the user into the database $add = "insert into contact_details(initials, surname, email, , company_name, address, address2, address3, address4, city, code, tel, email)"; $add .= " values('$surname', '$cell', '$email', '$production', '$supplier', '$wine', '$fruit', '$both', '$ander', '$owner', '$finance', '$hr', '$sales', '$fm', '$research', '$is', '$viticulture', '$production', '$retail', '$buying', '$distribution', '$student', '$other', '$second')"; mysql_query($add, $con); echo mysql_error($con); //send an email notification of the registration $subject = "New User Registered on Intervitis Interfructa"; $to = "[email protected]"; $msg = "A new user registered on info.co.za with the following detials:\r\n\r\n"; $msg = "Initials = " . $initials . "\r\n"; $msg = "Surname = " . $surnmae . "\r\n"; $msg = "Company = " . $company . "\r\n"; $msg = "Address = " . $address . "\r\n"; $msg = "City = " . $city . "\r\n"; $msg = "Code = " . $code . "\r\n"; $msg = "Tel = " . $tel . "\r\n"; $msg = "Email = " . $email . "\r\n"; $msg = "Production = " . $production . "\r\n"; $msg = "Supplier = " . $supplier . "\r\n"; $msg = "Wine = " . $wine . "\r\n"; $msg = "Fruit = " . $fruit . "\r\n"; $msg = "Both = " . $both . "\r\n"; $msg = "Ander = " . $ander . "\r\n"; $msg = "Owner = " . $owner . "\r\n"; $msg = "Finance = " . $finance . "\r\n"; $msg = "HR = " . $hr . "\r\n"; $msg = "Sales = " . $sales . "\r\n"; $msg = "Farm Management = " . $fm . "\r\n"; $msg = "Research = " . $research . "\r\n"; $msg = "Information Systems = " . $is . "\r\n"; $msg = "Viticulture = " . $viticulture . "\r\n"; $msg = "Production = " . $production . "\r\n"; $msg = "Retail = " . $retail . "\r\n"; $msg = "Buying = " . $buying . "\r\n"; $msg = "Distibution = " . $distribution . "\r\n"; $msg = "Student = " . $student . "\r\n"; $msg = "Other = " . $other . "\r\n\r\n"; mail($to, $subject, $msg); //send a mail to the client $clientSubject = "Welcome to info.co.za"; $clientTo = $email; $clientMsg = "<html> <head> <title>Online Registration - info.co.za</title> </head> <body style='color:#000000; font-family:verdana, helvetica, sans serif; font-size:12px;'> <p>Hi there " . rtrim($initial, $surname) . "!</p> <p>Thank you for your registering online to visit info.co.za Southern Africa. Your online registration has been confirmed. Your reference is 2009/ //creates a unique ID with a random number as a prefix - more secure than a static prefix $c = uniqid (rand (),true); echo $c; echo '<br>'; </p> <p>Please note that the exhibition takes place in halls 2,3 and 4 of the International Convention Centre and will be open daily between 10h00 and 18h00 from 28th to 30th July 2009.</p> <p>To assist our staff and speed up your entry ticket retrieval, <strong> please bring this e-mail with you when you visit the show. </strong></p> <p>Pre-Registration tickets may be collected at the Pre-Registration and Press Ticket Desk, situated to the right of the entrance to Hall 2 of the International Convention Centre.</p> <p>We look forward to your visit!</p> <p>Have a great day!</p> <table style='font-size:10px; width::200px; color:#000080; font-family:calibri, verdana, helvetica, sans serif; font-size:12px;'> <tr> <td colspan='2'> <img src='http://www.info.co.za/ivif/images/logo.jpg' width='192' height='82' alt='' /></td> </tr> <tr> </body> </html> "; $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n"; $headers .= "From: [email protected]" . "\r\n"; $headers .= "Reply-To: [email protected]" . "\r\n"; $headers .= "Cc: [email protected]" . "\r\n"; mail($clientTo, $clientSubject, $clientMsg, $headers); //thank them for registerring and inform them how its going to work $goodErr = "Thank you for registering. You may now log in."; //clear all the values $initials = ""; $surname = ""; $company = ""; $address = ""; $city = ""; $code = ""; $tel = ""; $email = ""; $production = ""; $supplier = ""; $wine = ""; $fruit = ""; $both = ""; $ander = ""; $owner = ""; $finance = ""; $hr = ""; $sales = ""; $fm = ""; $research = ""; $is = ""; $viticulture = ""; $production = ""; $retail = ""; $buying = ""; $distribution = ""; $student = ""; $other = ""; } else { $badErr = "Please fill in all the fields marked with an asterisk."; } } else { //insert your code which tells the user he is spamming your website $badErr = "Your answer to the mathguard question was incorrect, please try again."; } } ?> <html> <head> <form method="POST"> <title>Intervitis Interfructa</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link href="style.css" rel="stylesheet" type="text/css"> <style type="text/css"> <!-- .style7 {font-size: x-small} .style8 {font-size: xx-small} .style11 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; } .style14 {font-size: x-small; font-weight: bold; } --> </style> </head> <body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"> <!-- ImageReady Slices (Template.psd) --> <table id="Table_01" align="center" width="850" height="883" border="0" cellpadding="0" cellspacing="0"> <tr> <td colspan="4" background="images/Template_01.gif" width="850" height="194"></td> </tr> <tr> <td colspan="2" background="images/Template_02.gif" width="345" height="45"></td> <td width="368" height="45" ><div align="left" class="heading"> <div style="color:#f26732;">Online Registration </div> </div></td> <td rowspan="8" class="ragthPanel" width="137" height="424"> </td> </tr> <tr> <td background="images/Template_05.gif" width="218" height="36"> </td> <td colspan="2" rowspan="7" width="495" height="379" class="contentCell" valign="top" align="center"> <div id="tabMenu" align="center"><a href="visitor_info.html">Background</a> | <a href="vi_cat.html">Categories</a> | <a href="vi_highlights.html" >Highlights</a><br/> <a href="vi_online_reg.php" style="border-bottom:2px solid #9ccb3d;">Online Registration</a> | <a href="vi_ex_cat.html">Exhibitor Catalogue</a>| <a href="vi_down.php">Downloads</a> |</div> <br> <table width="100%" border="0" cellspacing="3" cellpadding="2"> <tr> <td colspan="2"><span class="style7">INITIALS/VOORLETTERS</span></td> <td colspan="2"><input name="initials" type="text" id="<?php echo $initials; ?>"></td> </tr> <tr> <td colspan="2"><span class="style7">SURNAME/VAN</span></td> <td colspan="2"><input name="surname" type="text" id="<?php echo $surname; ?>"></td> </tr> <tr> <td colspan="2"><span class="style7">COMPANY/MAATSKAPPY</span></td> <td colspan="2"><input name="company" type="text" id="<?php echo $company; ?>"></td> </tr> <tr> <td colspan="2"><span class="style7">POSTAL ADDRESS/POSADRES </span></td> <td colspan="2"><textarea name="address" rows="4" id="<?php echo $address; ?>"></textarea></td> </tr> <tr> <td colspan="2"><span class="style7">CITY/STAD</span></td> <td colspan="2"><input name="city" type="text" id="<?php echo $city; ?>"></td> </tr> <tr> <td colspan="2"><span class="style7">CODE/KODE</span></td> <td colspan="2"><input name="code" type="text" id="<?php echo $code; ?>"></td> </tr> <tr> <td colspan="2"><span class="style7">(CODE) TEL NO/<br> (KODE) TEL NR. </span></td> <td colspan="2"><input name="tel" type="text" id="<?php echo $tel; ?>"></td> </tr> <tr> <td colspan="2"><span class="style7">E-MAIL/E-POS</span></td> <td colspan="2"><input name="email" type="text" id="<?php echo $email; ?>"></td> </tr> <tr> <td colspan="4"><hr></td> </tr> <tr> <td><span class="style7">PRODUCTION OF/PRODUKSIE VAN </span></td> <td><input name="method" type="radio" value="production"><?PHP print $production_status; ?></td> <td><span class="style7">WINE/WYN</span></td> <td><input name="type" type="radio" value="wine"><?PHP print $wine_status; ?></td> </tr> <tr> <td><span class="style7">SUPPLIER TO/VERSKAFFER AAN </span></td> <td><input name="method" type="radio" value="supplier"><?PHP print $supplier_status; ?></td> <td><span class="style7">FRUIT/VRUGTE</span></td> <td><input name="type" type="radio" value="fruit"><?PHP print $fruit_status; ?></td> </tr> <tr> <td> </td> <td> </td> <td><span class="style7">BOTH/BYDE</span></td> <td><input name="type" type="radio" value="both"><?PHP print $both_status; ?></td> </tr> <tr> <td> </td> <td> </td> <td><span class="style7">OTHER/ANDER</span></td> <td><input name="type" type="radio" value="ander"><?PHP print $ander_status; ?></td> </tr> <tr> <td colspan="4"><hr></td> </tr> <tr> <td><span class="style14">JOB FUNCTION/WERKS FUNKSIE </span></td> <td><div align="center"></div></td> <td> </td> <td> </td> </tr> <tr> <td><div align="right"><span class="style7">OWNER/MD/CHAIRMAN</span></div></td> <td><div align="center"> <input name="ch1" type="checkbox" id="owner" value="owner"> </div></td> <td colspan="2"><span class="style7">EIENAAR/BD/VOORSITTER</span></td> </tr> <tr> <td><div align="right"><span class="style7">FINANCE/ADMINISTRATION</span></div></td> <td><div align="center"> <input name="ch2" type="checkbox" id="finance" value="finance"> </div></td> <td colspan="2"><span class="style7">FINANSIES/ADMINISTRASIE</span></td> </tr> <tr> <td><div align="right"><span class="style7">HUMAN RESOURCES </span></div></td> <td><div align="center"> <input name="ch3" type="checkbox" id="hr" value="hr"> </div></td> <td colspan="2"><span class="style7">MENSLIKE HULPBRONNE </span></td> </tr> <tr> <td><div align="right"><span class="style7">FARM MANAGEMENT </span></div></td> <td><div align="center"> <input name="ch4" type="checkbox" id="fm" value="fm"> </div></td> <td colspan="2"><span class="style7">BOERDERY BESTUUR </span></td> </tr> <tr> <td><div align="right"><span class="style7">RESEARCH/LABORATORY</span></div></td> <td><div align="center"> <input name="ch5" type="checkbox" id="research" value="research"> </div></td> <td colspan="2"><span class="style7">NAVORSING/LABORATORIUM</span></td> </tr> <tr> <td><div align="right"><span class="style7">INFORMATION SYSTEMS </span></div></td> <td><div align="center"> <input name="ch6" type="checkbox" id="is" value="is"> </div></td> <td colspan="2"><span class="style7">INLIGTING STELSELS </span></td> </tr> <tr> <td><div align="right"><span class="style7">VITICULTURE</span></div></td> <td><div align="center"> <input name="ch7" type="checkbox" id="viticulture" value="viticulture"> </div></td> <td colspan="2"><span class="style7">WINGERDBOU</span></td> </tr> <tr> <td><div align="right"><span class="style7">WINEMAKER/PRODUCTION</span></div></td> <td><div align="center"> <input name="ch8" type="checkbox" id="production" value="production"> </div></td> <td colspan="2"><span class="style7">WYNMAKER/PRODUKSIE</span></td> </tr> <tr> <td><div align="right"><span class="style7">HOSPITALITY/RETAIL</span></div></td> <td><div align="center"> <input name="ch9" type="checkbox" id="retail" value="retail"> </div></td> <td colspan="2"><span class="style7">GASVRYHEIDSBEDRYF/KLEINHANDEL</span></td> </tr> <tr> <td><div align="right"><span class="style7">BUYING</span></div></td> <td><div align="center"> <input name="ch10" type="checkbox" id="buying" value="buying"> </div></td> <td colspan="2"><span class="style7">AANKOPE</span></td> </tr> <tr> <td><div align="right"><span class="style7">DISTRIBUTION/WAREHOUSING</span></div></td> <td><div align="center"> <input name="ch11" type="checkbox" id="distribution" value="distribution"> </div></td> <td colspan="2"><span class="style7">VERSPREIDING/BERGING</span></td> </tr> <tr> <td><div align="right"><span class="style7">STUDENT</span></div></td> <td><div align="center"> <input name="ch12" type="checkbox" id="student" value="student"> </div></td> <td colspan="2"><span class="style7">STUDENT</span></td> </tr> <tr> <td><div align="right"><span class="style7">OTHER</span></div></td> <td><div align="center"> <input name="ch13" type="checkbox" id="other" value="other"> </div></td> <td colspan="2"><span class="style7">ANDER</span></td> </tr> <tr> <td colspan="4"><hr></td> </tr> <tr> <td colspan="4"><div align="center" class="style11"> <p> <?php MathGuard::insertQuestion(); ?> <br/> (This is to prevent spam programs from sending hundreds of fake requests)<br> <br> </p> </div></td> </tr> <tr> <td colspan="4"><center> <hr> <br> <input type="submit" name="Submit" value="Submit"> <br> <hr> </center></td> </tr> <tr> <td colspan="4"><div align="center"><span class="style8">Disclaimer: Right of admission reserved. By completing this ticket and entering the show, I agree to be contacted in a business capacity via INTERVITIS INTERFRUCTA Southern Africa database </span></div></td> </tr> </table><?php if($badErr <> "") { ?> <?php } if($goodErr <> "") { ?> <p align="center"><?php echo $badErr; ?> <?php echo $goodErr; ?></p> <?php } ?> <?php echo $err; ?> </td> </tr> <tr> <td background="images/Template_07.gif" width="218" height="27"> <div class="homeLink"><a href="background.html">Home</a></div></td> </tr> <tr> <td background="images/Template_08.gif" width="218" height="27"> <div class="menuLinks"><a href="background.html">Exhibition Details</a></div></td> </tr> <tr> <td class="menuCell" width="218" height="27"> <div class="menuLinks"><a href="why_exhib.html">Exhibition Information</a></div></td> </tr> <tr> <td class="menuCell" width="218" height="27"> <div class="menuLinks"><a href="contact.php">Contact Us </a></div></td> </tr> <tr> <td class="menuCell" width="218" height="27"> <div class="menuLinks"><a href="visitor_info.html" style="color:#f26732; font-weight:bold;">Visitor Information </a></div></td> </tr> <tr> <td width="218" height="414" class="laftCell"> <img src="images/spacer.gif" width="1" height="240" alt=""></td> </tr> <tr> <td colspan="4" align="center"> <div style="font-family:'Trebuchet MS', tahoma, Verdana, Arial; font-size:12px; padding:20px 0px 20px 0px;">© 2008 Exalon Dynamic Systems</div> </td> </tr> <tr> <td> <img src="images/spacer.gif" width="218" height="1" alt=""></td> <td> <img src="images/spacer.gif" width="127" height="1" alt=""></td> <td> <img src="images/spacer.gif" width="368" height="1" alt=""></td> <td> <img src="images/spacer.gif" width="137" height="1" alt=""></td> </tr> </table> <!-- End ImageReady Slices --> </form> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/163220-registration-form-help-uggh/ Share on other sites More sharing options...
PFMaBiSmAd Posted June 22, 2009 Share Posted June 22, 2009 In the same way that you break a coding problem down into its' individual steps to write the code, you troubleshoot your code in steps as well - Make sure that the form is correct - have you done a "view source" in your browser so that you know the form is what you want? When the form is submitted, is all the data present with expected values? Use the following to check - echo "<pre>"; echo "POST:"; print_r($_POST); echo "</pre>"; At the point of executing the query, does the query contain what you expect? Echo $add to find out. And if it does not reach that point in your code, investigate why. For the values you are receiving, what does your code do up to that point? Note: isset() can take a comma separated list of items, so it is not necessary to make a long list of isset() || isset() || .. terms in your conditional test. After you get the query working, troubleshoot your two mail() function calls. Do the variables contain what you expect? Echo them? Are the mail() function calls returning TRUE or FALSE values? Test them and if they are returning FALSE, what php generated errors do you get when you turn on full php error reporting (you should be learning php, developing php code, and debugging php code on a system with error_reporting set to E_ALL and display_errors set to ON in your php.ini to get php to help you.) And finally, no one is going to read through that whole mess of code unless you post it using the forum's ... your code here ... tags. Quote Link to comment https://forums.phpfreaks.com/topic/163220-registration-form-help-uggh/#findComment-861183 Share on other sites More sharing options...
PFMaBiSmAd Posted June 22, 2009 Share Posted June 22, 2009 As soon as you try your code on a system with the error_reporting/display_errors set as I suggested (and in your other similar thread it was suggested that you use those settings as well to help you), you will find that $_POST["submit"] does not exist because 'submit' is not the name of your form's submit button. Quote Link to comment https://forums.phpfreaks.com/topic/163220-registration-form-help-uggh/#findComment-861192 Share on other sites More sharing options...
Kathy Posted June 22, 2009 Author Share Posted June 22, 2009 I don't understand, what else would it be? As this is my button's code and I haven't named my button anything else? Is this the reason why nothing is working? <input type="submit" name="Submit" value="Submit"> Quote Link to comment https://forums.phpfreaks.com/topic/163220-registration-form-help-uggh/#findComment-861198 Share on other sites More sharing options...
Dathremar Posted June 22, 2009 Share Posted June 22, 2009 well Your submit button is named "Submit" and not "submit" Quote Link to comment https://forums.phpfreaks.com/topic/163220-registration-form-help-uggh/#findComment-861202 Share on other sites More sharing options...
PFMaBiSmAd Posted June 22, 2009 Share Posted June 22, 2009 Your form's submit button is "Submit". That is not the same as "submit". In programming everything is exact. You in fact have a test later in your code that is correctly testing $_POST['Submit']. Consistency counts in programming as well. In programming, accuracy, consistency, and exactness matters. Quote Link to comment https://forums.phpfreaks.com/topic/163220-registration-form-help-uggh/#findComment-861203 Share on other sites More sharing options...
Kathy Posted June 23, 2009 Author Share Posted June 23, 2009 Okay, thanks! I've corrected the "submit" button error. But I'm still stuck on nothing happening.... ??? Quote Link to comment https://forums.phpfreaks.com/topic/163220-registration-form-help-uggh/#findComment-861718 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.