luke1438 Posted December 15, 2008 Share Posted December 15, 2008 I am attempting to create a form that records peoples names and e-mails for a subscription to my newsletter. I don't think my MySQL database is correct because when I export it there are no headings. The form I created does not seem to be validating the entries. And, I have no clue if my .php form is correct. Up until a week ago I did not even know what .php was and the only exposure I had to SQL was the oversite of an accounting package conversion; I had 3 different SQL programmers that handled it all. I just want to collect peoples names and e-mail addresses so I can send out my newsletter; I do not know anywhere to go to hire someone. And I do not know if anyone would; it is such a small project. Below is a copy of my Table "notify", my code for both my form and my .php. I would greatly appreciate any guidence, help or suggestions. MySQL table: Field Type Collation Attributes Null Default Extra Action no tinyint(10) No auto_increment suffix varchar(5) ascii_general_ci No first varchar(30) ascii_general_ci No last varchar(30) ascii_general_ci No email varchar(50) ascii_general_ci No terms char(2) ascii_general_ci No date datetime No 0000-00-00 00:00:00 Form Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Notification Submission Form</title> <style type="text/css"> <!-- body { background-color: #FFCC33; } .style2 {color: #000000} .style3 {color: #FFCC33; font-weight: bold; } --> </style> <script src="../../SpryAssets/SpryValidationTextField.js" type="text/javascript"></script> <script src="../../SpryAssets/SpryValidationCheckbox.js" type="text/javascript"></script> <link href="../../SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" /> <style type="text/css"> <!-- .style5 { font-size: small; font-weight: bold; } --> </style> <link href="../../SpryAssets/SpryValidationCheckbox.css" rel="stylesheet" type="text/css" /> </head> <body> <table width="507" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="10"> </td> <td width="466"><div align="justify"><span class="style3"><span class="style2">Please fill out the form below and you will receive an e-mail when the next edition of GLOBAL ECONOMIST REVIEW is ready for download. Your name and e-mail address will not be shared with anyone and will not be sold; this is secure server. This information is strictly for the purpose of sending a notification and addressing you properly in the e-mail.</span>.</span></div></td> <td width="11"> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td><form id="form1" name="suffix" method="post" action="notify_process.php"> <label> <select name="suffix" size="1" id="suffix"> <option value="2">Mr.</option> <option value="3">Mrs.</option> <option value="4">Miss</option> <option value="5">Ms.</option> <option value="1">Dr.</option> </select> <strong>SUFFIX</strong></label> </form> </td><td> </td> </tr> <tr> <td> </td> <td><form id="form2" name="first" method="post" action="notify_process.php"> <label> <input type="text" name="first" id="first" /> <strong>FIRST</strong></label> </form> </td> <td> </td> </tr> <tr> <td> </td> <td><form id="form3" name="last" method="post" action="notify_process.php"> <span id="sprytextfield1"> <label> <input type="text" name="last" id="last" /> <strong>LAST</strong></label> <span class="textfieldRequiredMsg">(Required)*</span></span> </form> </td> <td> </td> </tr> <tr> <td> </td> <td><form id="form4" name="email" method="post" action="notify_process.php"> <span id="sprytextfield2"> <label> <input type="text" name="email" id="email" /> <strong>E-MAIL ADDRESS</strong></label> <span class="textfieldRequiredMsg">(Required)</span><span class="textfieldInvalidFormatMsg">*</span></span> </form> </td> <td> </td> </tr> <tr> <td> </td> <td><form id="form5" name="confirm_email" method="post" action="notify_process.php"> <span id="sprytextfield3"> <label> <input type="text" name="confirm_email" id="confirm_email" /> <strong>CONFIRM E-MAIL</strong></label> <span class="textfieldRequiredMsg">(Required)</span><span class="textfieldInvalidFormatMsg">*</span></span> </form> </td> <td> </td> </tr> <tr> <td> </td> <td><form id="form6" name="terms" method="post" action="notify_process.php"> <span id="sprycheckbox1"> <label> <input type="checkbox" name="terms" id="terms" /> <a href="http://www.globaleconomistreview.com/Terms Conditions and Disclosures.pdf"><strong>TERMS, CONDITIONS AND DISCLOSURES</strong></a></label> <span class="checkboxRequiredMsg">(Required)*</span></span> </form> </td> <td> </td> </tr> <tr> <td> </td> <td><form id="form7" name="submit" method="post" action="notify_process.php"> <label> <input type="submit" name="submit" id="submit" value="Submit" /> <strong>SUBMIT</strong></label> </form> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td><span class="style5">All fields must be filled in completly</span></td> <td> </td> </tr> <tr> <td> </td> <td><span class="style5">If you are experiencing issues with this form please contact us for help</span></td> <td> </td> </tr> <tr> <td> </td> <td><p class="style5">E-Mail: <a href="mailto: info@globaleconomistreview.com">info@globaleconomistreview.com</a> or call us at 646-873-6093</p></td> <td> </td> </tr> </table> <script type="text/javascript"> <!-- var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1"); var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "email"); var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3", "email"); var sprycheckbox1 = new Spry.Widget.ValidationCheckbox("sprycheckbox1"); //--> </script> </body> </html> .php Form: <?php //Connect To Database $hostname='hostserver'; $username='*******'; $password='******'; $dbname='tim6843'; $usertable='notify'; $suffix='suffix'; $first='first'; $last='last'; $email='email'; $terms='terms'; mysql_connect($hostname,$username,$password); mysql_select_db($dbname) OR DIE ('ERROR! - Could NOT Connect to DataBase'); $query="INSERT INTO notify (suffix, first, last, e-mail, terms) VALUES ('$suffix', '$first', '$last', '$email', '$terms')"; mysql_select_db($dbname) OR DIE ('ERROR!'); $query = "SELECT * FROM `notify' WHERE 'email'='$email'"; $result = mysql_query($query)or die(mysql_error()); if($result) { while($row=mysql_fetch_array($result)){ echo "Thank you, however it appears you are already registered"; } } ?> <html> <style type="text/css"> <!-- body { background-color: #FFCC33; } --> </style></head> <body> <p><strong>THANK YOU </strong></p> <p><strong>For registering to recieve a notification of the next Global Economist Review</strong></p> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/137002-very-frustrated/ Share on other sites More sharing options...
btherl Posted December 15, 2008 Share Posted December 15, 2008 There's 2 problems I can see there. First, in your form processing script you need to fetch the input data like this: $suffix=mysql_real_escape_string(stripslashes($_REQUEST['suffix'])); The extra functions there ensure that you can't have your database modified by sql injection attacks. And secondly, you have several forms on your page. There should be just one big form. There's a php freelancing forum here if you want professional help (not everyone who responds may be a professional of course!) Quote Link to comment https://forums.phpfreaks.com/topic/137002-very-frustrated/#findComment-715599 Share on other sites More sharing options...
sKunKbad Posted December 15, 2008 Share Posted December 15, 2008 I own a small business, and we use an email service called getresponse.com, however, I don't recommend them because they are a pain. I'm going to try a new one called constantcontact.com. These type of services have pre-built forms that you can use on your website to have customers add themselves to your database, and when you want to send an email, you just log in, fill out the email to broadcast, and click a few buttons. These types of services are known by ISPs to deliver mail that isn't spam, so your emails have a better chance of not being flagged as spam. There's no way that I would send all of my email to my customers off my own server, and I don't think you should either. Something to consider. Quote Link to comment https://forums.phpfreaks.com/topic/137002-very-frustrated/#findComment-715604 Share on other sites More sharing options...
Mad Mick Posted December 15, 2008 Share Posted December 15, 2008 So this registers the information - apart from btherls v. important point about sql injection I can't see too much wrong on the face of it. I would say that MySQL is definitely the right way to go - you now need a script that will take your database info and mail the newsletters. I would have thought if you keep the newsletter fairly short, provide a genuine unsubscribe link and don't send too often you won't have to worry about being labelled a spammer. Its perhaps not as small a job as you might think... You can try oDesk - don't know much about it but it might be OK for you. Quote Link to comment https://forums.phpfreaks.com/topic/137002-very-frustrated/#findComment-715668 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.