Jump to content

wright67uk

Members
  • Posts

    454
  • Joined

  • Last visited

Everything posted by wright67uk

  1. Somthhing like; <?php $_POST['Phone'] = $Phone; $_POST['Email'] = $Email; $_POST['Postcode'] = $Postcode; $_POST['Website'] = $Website; ?> Ive tried putting this before and then after my validation functions, and also in the form fields themselves, but I cant get the desired effect. Where should I put this code for it to work properly?
  2. <!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"> <?php include('func.php'); include($_SERVER['DOCUMENT_ROOT'].'/include/db.php'); ?> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Chained Select Boxes using PHP, MySQL and jQuery</title> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $('#wait_1').hide(); $('#drop_1').change(function(){ $('#wait_1').show(); $('#result_1').hide(); $.get("func.php", { func: "drop_1", drop_var: $('#drop_1').val() }, function(response){ $('#result_1').fadeOut(); setTimeout("finishAjax('result_1', '"+escape(response)+"')", 400); }); return false; }); }); function finishAjax(id, response) { $('#wait_1').hide(); $('#'+id).html(unescape(response)); $('#'+id).fadeIn(); } </script> <style type="text/css"> <!-- --> </style> <link href="newbusiness.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="banner"> <div id="bannerleft"></div> <div id="logo"></div> <div id="bannerright"><div id="navbar" title=""> <div id="b1"><p class="centre"><a href="index.html">Directory</a></p></div> <div id="b2"><p class="centre"><a href="business.html">Add Your Business</a></p></div> <div id="b3"><p class="centre"><a href="contact.html">Contact Us</a></p></div> </div><!-- end of navbar--> </div><!--end of bannerright--> </div><!-- end of banner--> <form name="add" action="#" method="post"> <fieldset> <legend>Add Your Business</legend> <p><label for="Name">Name</label><input type="text" name="Name" id="Name" maxlength="50" value="<?php if (!empty($Name)) echo $Name; ?>"/></p> <p><label for="Phone">Phone</label> <input type="text" name="Phone" id="Phone" maxlength="50" <?php if (!empty($Phone)) echo $Phone; ?>/></p> <p><label for="Email">Email</label><input type="text" name="Email" id="Email" maxlength="50"<?php if (!empty($Email)) echo $Email; ?> /></p> <p><label for="Postcode">Postcode</label><input type="text" name="Postcode" id="Postcode" maxlength="50"<?php if (!empty($Postcode)) echo $Postcode; ?> /></p> <p><label for="Web Address">Web Address</label><input type="text" name="Website" id="Website" maxlength="50" <?php if (!empty($Website)) echo $Website; ?>/></p> <select name="drop_1" id="drop_1"> <option value="" selected="selected" disabled="disabled">Select a Category</option> <?php getTierOne(); ?> </select> <span id="wait_1" style="display: none;"> <img alt="Please Wait" src="ajax-loader.gif"/> </span> <span id="result_1" style="display: none;"></span> <br /> </fieldset> </form> <div id="results"> <?php function checkPostcode (&$toCheck) { $alpha1 = "[abcdefghijklmnoprstuwyz]"; $alpha2 = "[abcdefghklmnopqrstuvwxy]"; $alpha3 = "[abcdefghjkstuw]"; $alpha4 = "[abehmnprvwxy]"; $alpha5 = "[abdefghjlnpqrstuwxyz]"; $pcexp[0] = '^('.$alpha1.'{1}'.$alpha2.'{0,1}[0-9]{1,2})([0-9]{1}'.$alpha5.'{2})$'; $pcexp[1] = '^('.$alpha1.'{1}[0-9]{1}'.$alpha3.'{1})([0-9]{1}'.$alpha5.'{2})$'; $pcexp[2] = '^('.$alpha1.'{1}'.$alpha2.'[0-9]{1}'.$alpha4.')([0-9]{1}'.$alpha5.'{2})$'; $pcexp[3] = '^(gir)(0aa)$'; $pcexp[4] = '^(bfpo)([0-9]{1,4})$'; $pcexp[5] = '^(bfpo)(c\/o[0-9]{1,3})$'; $Postcode = strtolower($toCheck); $Postcode = str_replace (' ', '', $Postcode); $valid = false; foreach ($pcexp as $regexp) { if (ereg($regexp,$Postcode, $matches)) { $toCheck = strtoupper ($matches[1] . ' ' . $matches [2]); $toCheck = ereg_replace ('C\/O', 'c/o ', $toCheck); $valid = true; break; } } if ($valid){return true;} else {return false;}; } if(isset($_POST['submit'])) { $drop = mysql_real_escape_string($_POST['drop_1']); $tier_two = mysql_real_escape_string($_POST['Subtype']); $Name = mysql_real_escape_string($_POST["Name"]); $Phone = mysql_real_escape_string($_POST["Phone"]); $Email = mysql_real_escape_string($_POST["Email"]); $Postcode = mysql_real_escape_string($_POST["Postcode"]); $Website = mysql_real_escape_string($_POST["Website"]); if($Name == '') { die ("<div class=\"form\">You did not complete the name field, please try again</div>"); } elseif ($Phone == '' or (preg_match("/^([1]-)?[0-9]{3}-[0-9]{3}-[0-9]{4}$/i", $Phone))) { die("<div class=\"form\"> You completed the telephone field incorrectly, please try again</div>"); } elseif ($Email == '' or (!filter_var($Email, FILTER_VALIDATE_EMAIL))) { die("<div class=\"form\"> You completed the Email field incorrectly, please try again</div>"); } elseif ($Postcode == '' or (!checkPostcode($Postcode))) { die("<div class=\"form\"> You did not complete the Postcode field correctly, please try again</div>"); } elseif ($Website == '' or (!preg_match("~^[a-z0-9.-]+\.(com|org|net|edu|co.uk)~i", $Website))) { die("<div class=\"form\">You completed the website field incorrectly, please try again</div>"); } else { echo("<div id=\"formtwo\">Thankyou for submiting your details, you will be added to our directory shortly</div>"); } $query = ("INSERT INTO business (`id`, `Name`, `Type`, `Subtype`, `Phone`, `Email`, `Postcode`, `WebAddress`, `Confirmed`) VALUES ('NULL', '$Name', '$drop', '$tier_two' , '$Phone', '$Email', '$Postcode', '$Website', 'Yes')"); mysql_query($query) or die ( "<br>Query: $query<br>Error: " .mysql_error()); } ?> <p>I-stevenage is forever expanding, by adding new catergories and business types. <br /> If you would like to add a service that is not in our list, then please click here. <br />(It will only take 30 seconds to fill in our form)</p> </div> </body> </html>
  3. Is it then the case that If I use die, then I will not be able to repopulate my form fields? Ive seen somebody on a different thread put value="<?php if (!empty($Name)) echo $Name; ?>"/> into their html form It would be good to do somthing like this on my form to re-populate the fields but doesn't seem to work. Please excuse me if im not quite grasping this.
  4. Could you use include? <?php include('file1.php'); ?> OR <?php include($_SERVER['DOCUMENT_ROOT'].'/include/file2.php'); ?>
  5. As expected when a die statement is triggered, my script is exited and ALL of the fields that have been filled in on my form are wiped clean. This however is proving to be annoying for users making mistakes. Is there a way to keep the data in the correctly filled in fields, and to just wipe or highlight the incorrectly filled in fields? <?php function checkPostcode (&$toCheck) { $alpha1 = "[abcdefghijklmnoprstuwyz]"; $alpha2 = "[abcdefghklmnopqrstuvwxy]"; $alpha3 = "[abcdefghjkstuw]"; $alpha4 = "[abehmnprvwxy]"; $alpha5 = "[abdefghjlnpqrstuwxyz]"; $pcexp[0] = '^('.$alpha1.'{1}'.$alpha2.'{0,1}[0-9]{1,2})([0-9]{1}'.$alpha5.'{2})$'; $pcexp[1] = '^('.$alpha1.'{1}[0-9]{1}'.$alpha3.'{1})([0-9]{1}'.$alpha5.'{2})$'; $pcexp[2] = '^('.$alpha1.'{1}'.$alpha2.'[0-9]{1}'.$alpha4.')([0-9]{1}'.$alpha5.'{2})$'; $pcexp[3] = '^(gir)(0aa)$'; $pcexp[4] = '^(bfpo)([0-9]{1,4})$'; $pcexp[5] = '^(bfpo)(c\/o[0-9]{1,3})$'; $Postcode = strtolower($toCheck); $Postcode = str_replace (' ', '', $Postcode); $valid = false; foreach ($pcexp as $regexp) { if (ereg($regexp,$Postcode, $matches)) { $toCheck = strtoupper ($matches[1] . ' ' . $matches [2]); $toCheck = ereg_replace ('C\/O', 'c/o ', $toCheck); $valid = true; break; } } if ($valid){return true;} else {return false;}; } if(isset($_POST['submit'])) { $drop = mysql_real_escape_string($_POST['drop_1']); $tier_two = mysql_real_escape_string($_POST['Subtype']); $Name = mysql_real_escape_string($_POST["Name"]); $Phone = mysql_real_escape_string($_POST["Phone"]); $Email = mysql_real_escape_string($_POST["Email"]); $Postcode = mysql_real_escape_string($_POST["Postcode"]); $Website = mysql_real_escape_string($_POST["Website"]); if($Name == '') { die ("<div class=\"form\">You did not complete the name field, please try again</div>"); } elseif ($Phone == '' or (preg_match("/^([1]-)?[0-9]{3}-[0-9]{3}-[0-9]{4}$/i", $Phone))) { die("<div class=\"form\"> You completed the telephone field incorrectly, please try again</div>"); } elseif ($Email == '' or (!filter_var($Email, FILTER_VALIDATE_EMAIL))) { die("<div class=\"form\"> You completed the Email field incorrectly, please try again</div>"); } elseif ($Postcode == '' or (!checkPostcode($Postcode))) { die("<div class=\"form\"> You did not complete the Postcode field correctly, please try again</div>"); } elseif ($Website == '' or (!preg_match("~^[a-z0-9.-]+\.(com|org|net|edu|co.uk)~i", $Website))) { die("<div class=\"form\">You completed the website field incorrectly, please try again</div>"); } else { echo("<div id=\"formtwo\">Thankyou for submiting your details, you will be added to our directory shortly</div>"); } $query = ("INSERT INTO business (`id`, `Name`, `Type`, `Subtype`, `Phone`, `Email`, `Postcode`, `WebAddress`, `Confirmed`) VALUES ('NULL', '$Name', '$drop', '$tier_two' , '$Phone', '$Email', '$Postcode', '$Website', 'Yes')"); mysql_query($query) or die ( "<br>Query: $query<br>Error: " .mysql_error()); } ?>
  6. That did the job, thankyou very much. I'd never heard of quicks mode before, is there any good reading on this that you can suggest?
  7. I have two files; www.1pw.co.uk/newbusiness.html (displays fine in IE) and www.1pw.co.uk/newbusiness.php (unwanted scroll bar in IE) newbusiness.html has only html, and newbusiness.php has a javascript file in the head, and php throughout, (form validation and sql). The problem is although they both use the same css file and div layouts, for some reason or other newbusiness.php outputs an unwanted scroll bar to the side of the page. This in turn puts one of my divs out. Should the different file types output differently in this way, and are there any css rules I can use to force a browser not to display a scroll bar? Many thanks - any ideas more than welcome.
  8. Can a background image overflow its container? #banner { height:54px; width:100%; background-color:#36F; background-image:url(i-stevenage.png); background-repeat:no-repeat; background-position:5% 0%; } is it possible to have a background image spill over the top and bottom of #banner? somthing like; background-image:overflow; ???
  9. I have a problem with formating the appearance of a die statement. As you will see from the css below, p.form and p.passed both have the same text-align, and marginal values, however they display very differently. P.passed is used in an echo, and P.form is used in a die. I want to display both my echo and die statements in the same place. Ive tried the obvious and played around with the margins on P.form but it doesnt seem to make any difference. I can only presume that my die statement is ignoring the class im assigning it? P.form { color:#FF03; margin-left:100px; text-align:left; clear:both; } P.passed { color:#333; margin-left:100px; text-align:left; clear:both; } <?php // snippet if($Name == '') { die ("<P class=\"form\">You did not complete the name field, please try again</p>"); } elseif ($Phone == '' or (preg_match("/^([1]-)?[0-9]{3}-[0-9]{3}-[0-9]{4}$/i", $Phone))) { die('<P class="form"> You completed the telephone field incorrectly, please try again</p>'); } elseif ($Email == '' or (!filter_var($Email, FILTER_VALIDATE_EMAIL))) { die('<P class="form"> You completed the Email field incorrectly, please try again</p>'); } elseif ($Postcode == '' or (!checkPostcode($Postcode))) { die('<P class="form"> You did not complete the Postcode field correctly, please try again</p>'); } elseif ($Website == '' or (!preg_match("~^[a-z0-9.-]+\.(com|org|net|edu|co.uk)~i", $Website))) { die('<P class="form">You completed the website field incorrectly, please try again</p>'); } else { echo("<P class=\"passed\">Thankyou for submiting your details, you will be added to our directory shortly</p>"); }} Ive formatted if and else slightly differently but the output is still the same. Should die statements and echo's display differently?
  10. Hi im having trouble getting the below code to listen to my css margin settings. Just to clear up the server side of things, can anybody tell me wether or not im using the correct syntax in the code below? else { echo("<p class=\"passed\">Thankyou for submiting your details, you will be added to our directory shortly</p>"); }}
  11. I got this to work well in my script in the end. Just thought i'd share it. I had a comment about COM com cOm and didnt realise that if i add 'i' at the end of my closing bracket that it would allow case to be ignored. elseif ($Website == '' or (!preg_match("~^[a-z0-9.-]+\.(com|org|net|edu|co.uk)~i", $Website))) { die('<br>You completed the website field incorrectly, please try again'); }
  12. OR perhaps you could use the built in email validator? if($Email == '' or (!filter_var($Email, FILTER_VALIDATE_EMAIL))) { die('<br> You completed the Email field incorrectly, please try again'); }
  13. but as im using this in a form, wouldnt my user have to type in http://www.mysite.com opposed to www.mysite.com?
  14. I see your point, but im not overly worried. Im making a directory and just want each listing to have a similiar format. If the user doesnt type in their own email address, they dont get enquiries. My email field is using FILTER_VALIDATE_EMAIL but its the website address that im working on at the moment. Im not sure if php has inbuilt filters for web addresses/url's???
  15. thankyou I shall find one. I managed to add ; www.hityu.com and then www.hityu.coy to my database . How can I change my code to only accept tld's that I listed within my expression in the code above?
  16. I'm starting to get really fed up with GODADDY and the fact that my PHP files take sometimes 10 minutes to update on my server. Does anybody else have similiar problems with this or other hosting companies? Also, what board should I post this on if Id like to start a new thread?
  17. Yep thats fine, I can add to the domain part. The only thing is that I get an error; Parse error: syntax error, unexpected ')' on line 112. I dont have a ')' on line 112. Ive commented on line 112. Im very new to regex / pregmatch etc. <?php function checkPostcode (&$toCheck) { $alpha1 = "[abcdefghijklmnoprstuwyz]"; $alpha2 = "[abcdefghklmnopqrstuvwxy]"; $alpha3 = "[abcdefghjkstuw]"; $alpha4 = "[abehmnprvwxy]"; $alpha5 = "[abdefghjlnpqrstuwxyz]"; $pcexp[0] = '^('.$alpha1.'{1}'.$alpha2.'{0,1}[0-9]{1,2})([0-9]{1}'.$alpha5.'{2})$'; $pcexp[1] = '^('.$alpha1.'{1}[0-9]{1}'.$alpha3.'{1})([0-9]{1}'.$alpha5.'{2})$'; $pcexp[2] = '^('.$alpha1.'{1}'.$alpha2.'[0-9]{1}'.$alpha4.')([0-9]{1}'.$alpha5.'{2})$'; $pcexp[3] = '^(gir)(0aa)$'; $pcexp[4] = '^(bfpo)([0-9]{1,4})$'; $pcexp[5] = '^(bfpo)(c\/o[0-9]{1,3})$'; $Postcode = strtolower($toCheck); $Postcode = str_replace (' ', '', $Postcode); $valid = false; foreach ($pcexp as $regexp) { if (ereg($regexp,$Postcode, $matches)) { $toCheck = strtoupper ($matches[1] . ' ' . $matches [2]); $toCheck = ereg_replace ('C\/O', 'c/o ', $toCheck); $valid = true; break; } } if ($valid){return true;} else {return false;}; } if(isset($_POST['submit'])) { $drop = mysql_real_escape_string($_POST['drop_1']); $tier_two = mysql_real_escape_string($_POST['Subtype']); $Name = mysql_real_escape_string($_POST["Name"]); $Phone = mysql_real_escape_string($_POST["Phone"]); $Email = mysql_real_escape_string($_POST["Email"]); $Postcode = mysql_real_escape_string($_POST["Postcode"]); $Website = mysql_real_escape_string($_POST["Website"]); if($Name == '') { die('<br> You did not complete the name field, please try again'); } elseif ($Phone == '' or (preg_match("/^([1]-)?[0-9]{3}-[0-9]{3}-[0-9]{4}$/i", $Phone))) { //LINE74 die('<br> You completed the telephone field incorrectly, please try again'); } elseif ($Email == '' or (!filter_var($Email, FILTER_VALIDATE_EMAIL))) { die('<br> You completed the Email field incorrectly, please try again'); } elseif ($Postcode == '' or (!checkPostcode($Postcode))) { die('<br> You did not complete the Postcode field correctly, please try again'); } elseif ($Website == '' or (preg_match ("~a-zA-Z0-9-\.+\.com|COM|Com|ORG|Org|org|net|NET|Net|edu|EDU|Edu|org|ORG|Org|NET|net|Net|co.uk|CO.UK|Co.uk|Co.Uk|co.Uk|CO.uk|co.UK~", $Website))) { //THIS IS LINE 112 THIS IS LINE 112 die('<br>You completed the website field incorrectly, please try again'); } else { echo("Thankyou for submiting your details, you will be added to our directory shortly"); }} $query = ("INSERT INTO business (`id`, `Name`, `Type`, `Subtype`, `Phone`, `Email`, `Postcode`, `WebAddress`) VALUES ('NULL', '$Name', '$drop', '$tier_two' , '$Phone', '$Email', '$Postcode', '$Website')"); mysql_query($query) or die ( "<br>Query: $query<br>Error: " .mysql_error()); ?>
  18. (preg_match ("~a-zA-Z0-9-\.+\.com|COM|Com|ORG|Org|org|net|NET|Net|edu|EDU|Edu|org|ORG|Org|NET|net|Net|co.uk|CO.UK|Co.uk|Co.Uk|co.Uk|CO.uk|co.UK~", $Website)) is that what you mean? Will this be ok for checking say for example; www.mysite.com ?
  19. Can anybody help me with the preg match in my code; elseif ($Website == '' or (preg_match ("[a-zA-Z0-9\-\.]+\.(com|COM|Com|ORG|Org|org|net|NET|Net|edu|EDU|Edu|org|ORG|Org|NET|net|Net|co.uk|CO.UK|Co.uk|Co.Uk|co.Uk|CO.uk|co.UK", $Website))) I have the error; Warning: preg_match() [function.preg-match]: Unknown modifier '+' <?php //code selected if(isset($_POST['submit'])) { $drop = mysql_real_escape_string($_POST['drop_1']); $tier_two = mysql_real_escape_string($_POST['Subtype']); $Name = mysql_real_escape_string($_POST["Name"]); $Phone = mysql_real_escape_string($_POST["Phone"]); $Email = mysql_real_escape_string($_POST["Email"]); $Postcode = mysql_real_escape_string($_POST["Postcode"]); $Website = mysql_real_escape_string($_POST["Website"]); if($Name == '') { die('<br> You did not complete the name field, please try again'); } elseif ($Phone == '' or (preg_match("/^([1]-)?[0-9]{3}-[0-9]{3}-[0-9]{4}$/i", $Phone))) { //LINE74 die('<br> You completed the telephone field incorrectly, please try again'); } elseif ($Email == '' or (!filter_var($Email, FILTER_VALIDATE_EMAIL))) { die('<br> You completed the Email field incorrectly, please try again'); } elseif ($Postcode == '' or (!checkPostcode($Postcode))) { die('<br> You did not complete the Postcode field correctly, please try again'); } elseif ($Website == '' or (preg_match ("[a-zA-Z0-9\-\.]+\.(com|COM|Com|ORG|Org|org|net|NET|Net|edu|EDU|Edu|org|ORG|Org|NET|net|Net|co.uk|CO.UK|Co.uk|Co.Uk|co.Uk|CO.uk|co.UK", $Website))) { die('<br>You completed the website field incorrectly, please try again'); } else { echo("Thankyou for submiting your details, you will be added to our directory shortly"); }}
  20. Just a quick thanks for pointing out missing parenthesis. After all that the postcode validator didnt even work anyway Is there an online parenthesis checker I can use? I dont want to be wasting peoples time, on silly misatakes!
  21. <?php if(isset($_POST['submit'])) { $drop = mysql_real_escape_string($_POST['drop_1']); $tier_two = mysql_real_escape_string($_POST['Subtype']); echo "You selected "; echo $drop." & ".$tier_two; $Name = mysql_real_escape_string($_POST["Name"]); $Phone = mysql_real_escape_string($_POST["Phone"]); $Email = mysql_real_escape_string($_POST["Email"]); $Postcode = mysql_real_escape_string($_POST["Postcode"]); $Postcode = strtoupper(str_replace(' ','',$Postcode)); $Website = mysql_real_escape_string($_POST["Website"]); if($Name == '') { die('<br> You did not complete the name field, please try again'); } elseif ($Phone == '' or (!preg_match("/^([1]-)?[0-9]{3}-[0-9]{3}-[0-9]{4}$/i", $Phone))) { //LINE74 die('<br> You completed the telephone field incorrectly, please try again'); } elseif ($Email == '' or (!filter_var($Email, FILTER_VALIDATE_EMAIL))) { die('<br> You completed the Email field incorrectly, please try again'); } elseif ($Postcode == '' or (!preg_match("/^[A-Z]{1,2}[0-9]{2,3}[A-Z]{2}$/",$Postcode) || !preg_match("/^[A-Z]{1,2}[0-9]{1}[A-Z]{1}[0-9]{1}[A-Z]{2}$/",$Postcode) || !preg_match("/^GIR0[A-Z]{2}$/",$Postcode)) { die('<br> You did not complete the Postcode field correctly, please try again'); } elseif ($Website == '') { die('<br>The website field was empty, please try again'); } } Im still getting the same error on line 74, Im not sure if its more frustrating that Im making a mistake, or the fact that I cant see where im going wrong. Further reading? Ive read that w3schools is a bad place to learn php,any good places I should check out?
  22. Im trying to validate each of my form fields one by one; <form action="#" method="post"> Name: <input type="text" name="Name" maxlength="50"/><br /> Phone: <input type="text" name="Phone" maxlength="50"/><br /> Email: <input type="text" name="Email" maxlength="50"/><br /> Postcode: <input type="text" name="Postcode" maxlength="50"/><br /> Web Address: <input type="text" name="Website" maxlength="50"/><br /><br /> <select name="drop_1" id="drop_1"> <option value="" selected="selected" disabled="disabled">Select a Category</option> <?php getTierOne(); ?> </select> <span id="wait_1" style="display: none;"> <img alt="Please Wait" src="ajax-loader.gif"/> </span> <span id="result_1" style="display: none;"></span> <br /> </form> </p> <p> <?php if(isset($_POST['submit'])) { $drop = mysql_real_escape_string($_POST['drop_1']); $tier_two = mysql_real_escape_string($_POST['Subtype']); echo "You selected "; echo $drop." & ".$tier_two; $Name = mysql_real_escape_string($_POST["Name"]); $Phone = mysql_real_escape_string($_POST["Phone"]); $Email = mysql_real_escape_string($_POST["Email"]); $Postcode = mysql_real_escape_string($_POST["Postcode"]); $Postcode = strtoupper(str_replace(' ','',$Postcode)); $Website = mysql_real_escape_string($_POST["Website"]); if($Name == '') { die('<br> You did not complete the name field, please try again'); } elseif ($Phone == '' or (!preg_match("/^([1]-)?[0-9]{3}-[0-9]{3}-[0-9]{4}$/i", $Phone)) { // LINE 74 HERE die('<br> You completed the telephone field incorrectly, please try again'); } elseif ($Email == '' or (!filter_var($Email, FILTER_VALIDATE_EMAIL)) { die('<br> You completed the Email field incorrectly, please try again'); } elseif ($Postcode == '' or (!preg_match("/^[A-Z]{1,2}[0-9]{2,3}[A-Z]{2}$/",$Postcode) || !preg_match("/^[A-Z]{1,2}[0-9]{1}[A-Z]{1}[0-9]{1}[A-Z]{2}$/",$Postcode) || !preg_match("/^GIR0[A-Z]{2}$/",$Postcode)) { die('<br> You did not complete the Postcode field correctly, please try again'); } elseif ($Website == '') { die('<br>The website field was empty, please try again'); } } my code returns an error; Parse error: syntax error, unexpected '{' on line 74 I thought this was how else if statements were used, but I am learning and would love a bit of guidance should anyone be kind enough?
  23. I did try that, and I also tried the below code. Neither return any error messages, however neither submit to my database, the die message is displayed when the submit button is pressed no matter what is in the fields. (I've tried the form with my own email address) <?php if(isset($_POST['submit'])) { $drop = mysql_real_escape_string($_POST['drop_1']); $tier_two = mysql_real_escape_string($_POST['Subtype']); echo "You selected "; echo $drop." & ".$tier_two; $Name = mysql_real_escape_string($_POST["Name"]); $Phone = mysql_real_escape_string($_POST["Phone"]); $Email = mysql_real_escape_string($_POST["Email"]); $Postcode = mysql_real_escape_string($_POST["Postcode"]); $Website = mysql_real_escape_string($_POST["Website"]); if($Name == '' || $Phone == '' || $Email == '' or (!filter_var($email, FILTER_VALIDATE_EMAIL))|| $Postcode == '' || $Website == '') { die('<br> but you did not complete all of the required fields, please try again'); } }
  24. thats what I orginally thought; </form> </p> <p> <?php if(isset($_POST['submit'])) { $drop = mysql_real_escape_string($_POST['drop_1']); $tier_two = mysql_real_escape_string($_POST['Subtype']); echo "You selected "; echo $drop." & ".$tier_two; $Name = mysql_real_escape_string($_POST["Name"]); $Phone = mysql_real_escape_string($_POST["Phone"]); $Email = mysql_real_escape_string($_POST["Email"]); $Postcode = mysql_real_escape_string($_POST["Postcode"]); $Website = mysql_real_escape_string($_POST["Website"]); if($Name == '' || $Phone == '' || $Email == '' or (!preg_match('/^[A-Za-z0-9\-.]+$/', $domain)|| $Postcode == '' || $Website == '') { die('<br> but you did not complete all of the required fields correctly, please try again'); } } echo "<br>"; echo $Name; echo "<br>"; echo $Website; $query = ("INSERT INTO business (`id`, `Name`, `Type`, `Subtype`, `Phone`, `Email`, `Postcode`, `WebAddress`) VALUES ('NULL', '$Name', '$drop', '$tier_two' , '$Phone', '$Email', '$Postcode', '$Website')"); mysql_query($query) or die ( "<br>Query: $query<br>Error: " .mysql_error()); ?> </body> </html> but then I get the error message; Parse error: syntax error, unexpected '{' on line 70 <?php if($Name == '' || $Phone == '' || $Email == '' or (!preg_match('/^[A-Za-z0-9\-.]+$/', $domain)|| $Postcode == '' || $Website == '') { //LINE 70 die('<br> but you did not complete all of the required fields correctly, please try again'); } } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.