Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Hannah Rolston

Members
  • Joined

  • Last visited

Everything posted by Hannah Rolston

  1. Valid code.Unfortunately that code has already been used. Notice: Undefined index: file in /Applications/MAMP/htdocs/index.php on line 71 Notice: Undefined index: file in /Applications/MAMP/htdocs/index.php on line 74 Notice: Undefined index: file in /Applications/MAMP/htdocs/index.php on line 75 Notice: Undefined index: file in /Applications/MAMP/htdocs/index.php on line 76 Invalid file. This is what I get when i choose A3 product size and put a code in to go with that A3 table and it comes back valid code and also the code has been used. It updates the grouponused for the grouponcode in A3 table to '1' but it seems to be running the check to see if it has been used after i've used it which i don't want it to do i just want it to validate with the ajax tick i have and then submit and change table appropriately but it seems the validation messages in check.php and my ajax validation are getting muddled.
  2. The deal goes live at 12 tonight and i need to get it on clients server before then and give groupon link to page. Thank you both for trying to help me anything you can do to help me will be a god send!
  3. This is what i get echo'ing the update statement Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /Applications/MAMP/htdocs/check.phpon line 19 UPDATE undefined SET grouponused='1' WHERE grouponcode = 'CM9ZZ92S95' Please enter a valid voucher code.
  4. I have posted it above , here is updated and yes i do have product size it is my radio buttons this was working in your previous check.php <?php //GLOBAL $HTTP_POST_FILES; //If the form is submitted if(isset($_POST['submit'])) { //Check to make sure that the name field is not empty if(trim($_POST['name']) == '') { $hasError = true; } else { $name = trim($_POST['name']); } //Check to make sure that the phone field is not empty if(trim($_POST['phone']) == '') { $hasError = true; } else { $phone = trim($_POST['phone']); } //Check to make sure sure that a valid email address is submitted if(trim($_POST['email']) == '') { $hasError = true; } else if (!preg_match("/^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$/i", trim($_POST['email']))) { $hasError = true; } else { $email = trim($_POST['email']); } //Check to make sure Address were entered if(trim($_POST['postaddress']) == '') { $hasError = true; } else { $postaddress =trim($_POST['postaddress']); } //Check to make sure Address were entered if(trim($_POST['postaddress2']) == '') { $hasError = true; } else { $postaddress2 =trim($_POST['postaddress2']); } //Check to make sure Address were entered if(trim($_POST['postcity']) == '') { $hasError = true; } else { $postcity =trim($_POST['postcity']); } //Check to make sure Address were entered if(trim($_POST['postregion']) == '') { $hasError = true; } else { $postregion =trim($_POST['postregion']); } //Check to make sure Address were entered if(trim($_POST['postcode']) == '') { $hasError = true; } else { $postcode =trim($_POST['postcode']); } //Check product size is selected $req=$_REQUEST['productsize']; require("check.php"); $req=$_REQUEST['grouponcode']; require("check.php"); //Check Image Upload $allowedExts = array("jpg", "jpeg", "gif", "png"); //$extension = end(explode(".", $_FILES["file"]["name"])); $tmp = explode('.', $_FILES['file']['name']); $extension = end($tmp); if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/pjpeg")) && ($_FILES["file"]["size"] < 20000) && in_array($extension, $allowedExts)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />"; if (file_exists("upload/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]); echo "Stored in: " . "upload/" . $_FILES["file"]["name"]; } } } else { echo "Invalid file"; } //If there is no error, send the email if(!isset($hasError)) { $emailTo = 'me@mydomain.com'; //Put your own email address here $subject = "From: Studio $emailTo . \n . 'Reply-To: ' . $email"; $body = "Name: $name \n\nPhone: $phone \n\nEmail: $email \n\nAddress:\n $postaddress\n$postaddress2\n$postcity\n$postregion\n$postcode\nProduct Size: $productsize\n$grouponcode\n"; mail($emailTo, $subject, $body); $emailSent = true; } } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"> <html> <head> <title>Groupon Form</title> <meta name="keywords" content=" groupon, redeem, coupon code"> <meta name="description" content="groupon form" > <script type="text/javascript" src="jquery-1.2.6.min.js"></script> <style> #form-wrapper{width:800px; margin:0 auto;overflow:hidden;} h1{font-family:Arial; font-size:30px ;color:#999999;} h2{font-family: Arial,sans-serif;font-size:20px; color: #00AEEF;border-bottom:1px dotted #999999;} label,legend{display:inline-block;font-family: Arial; font-size: 16px; color: #00AEEF;padding:10px;width:30%;} input{font-family:arial;font-size:12px; color:#999999; padding:10px;} #name,#phone,#email,#address,#product-size,#groupon-code,#image-upload{padding: 20px 10px 0px;} #address label{display:block; width:50%;} #address-fields{float:right;display:inline-block;width:60%;padding-right:54px;} #address-fields input{width:80%;} #address-fields label{display:block;padding:0px;} #product-size{display:block;clear:both;} #product-size .one-col{display:block; width:60%;float:right; font-family:arial;font-size:14px;color:#999999;padding-right:54px;} #groupon-code{clear:both;} #submit{padding:20px;} #submit input{font-size:18px;margin:20px;} #status{display:inline-block;} .object_ok{border: 1px solid green; color:#333333;} .object_error{border: 1px solid #ac3962; color:#333333;} </style> <script src="jquery.validate.pack.js" type="text/javascript"></script> <script type="text/javascript"> pic1 = new Image(16, 16); pic1.src="loader.gif"; $(document).ready(function(){ $("#grouponcode").change(function(){ var code =$("#grouponcode").val(); var productsize =$("productsize").val(); { $("#status").html('<img src="loader.gif" align="absmiddle"> Validating Code...'); $.ajax({ type: "POST", url:"check.php", data:"grouponcode="+code+"&productsize="+productsize, success: function(msg){ $("#status").ajaxComplete(function(event,request,settings){ if(msg == 'OK') { $("#grouponcode").removeClass('object_error'); $("#grouponcode").addClass('object_ok'); $(this).html(' <img src="tick.gif" align="absmiddle">'); } else { $("#grouponcode").removeClass('object_ok'); $("#grouponcode").addClass('object_error'); $(this).html(msg); } }); } }); } } )}); </script> <script type="text/javascript" > $("#grouponform").validate(); </script> </head> <body> <div id="form-wrapper"> <h1 align="center">Art</h1> <h2>Your Order</h2> <?php if(isset($hasError)) { //If errors are found ?> <p class="error">Oops! Check and try again.</p> <?php } ?> <?php if(isset($emailSent) && $emailSent == true) { //If email is sent ?> <p class="success"><strong>Email Sent!</strong> Thank you <strong><?php echo $name;?></strong> I will be in touch shortly.</p> <?php } ?> <form method="post" action="<?= $_SERVER['PHP_SELF'] ?>" name="grouponform" > <div id="name"> <label for="name"><strong>Name: *</strong></label> <input type="text" size="30" name="name" value="" class="required" /> </div> <div id="phone"> <label for="phone"><strong>Phone: *</strong></label> <input type="text" size="30" name="phone" value="" class="required" /> </div> <div id="email"> <label for="email"><strong>Email: *</strong></label> <input type="text" size="30" name="email" value="" class="required email" /> </div> <div id="address"> <legend><strong>Address: *</strong></legend> </div> <div id="address-fields"> <label for="postaddress">Street Address</label> <input type="text" id="postaddress" name="postaddress" /> <label for="postaddress2">Address Line 2</label> <input type="text" id="postaddress2" name="postaddress2" /> <label for="postcity">City</label> <input type="text" id="postcity" name="postcity" /> <label for="postprov">Region</label> <input type="text" id="postregion" name="postregion" /> <label for="postcode">Postcode</label> <input type="text" id="postcode" name="postcode" /> </div> <div id="product-size"> <label for="productsize"><strong>Product Size: *</strong></label> <div class="one-col"><input type="radio" name='productsize' value="A4" checked="checked"/> A4 Size</div> <div class="one-col"><input type="radio" name='productsize' value="A3" /> A3 Size</div> <div class="one-col"><input type="radio" name='productsize' value="A2" /> A2 Size</div> </div> <div id="groupon-code"> <label for="grouponcode"><strong>Voucher Code: *</strong></label> <input type="text" id="grouponcode" name="grouponcode" class="required" /> </div> <div id="status"> </div> <div id="image-upload"> <label for"file"><strong>Upload Image: </strong></label> <input type="file" name="file" id="file" /> </div> <div id="submit"> <input type="submit" value="Send Message" name="submit" /> </div> </form> </div> </body> </html>
  5. grouponused has a value of 0 so i have two columns in each table ( 3 tables A4, A3, A2) to correspond to each radio button grouponcode grouponused chdh8373 0 sfsdfsdfsdf 0 and so on and when the user enters valid code it finds it and says valid code and then updates the 0 to 1 so it cannot be used again when someone presses submit.
  6. SELECT grouponcode FROM undefined WHERE grouponcode = 'CM9ZZ92A94' it says undefined for the table but it does actually update the correct table when you submit regardless of the errors?
  7. I'm still getting the same error? Could it have anything to do with the ajax ? I also get the error when its on my hosting server as well. But it still updates the database? Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /Applications/MAMP/htdocs/check.phpon line 18 Please enter a valid voucher code I'm testing with a voucher code i know is in there and it updates?
  8. Still no change, my deadline is in a couple of hours as it goes live on groupon. I'm baffled now! Thank you for your help so far.
  9. Thanks, Yes because it is actually updating the table once i submit regardless of the errors. and I've tested it with each table and it updates each table to correspond. That replacement hasn't changed anything, still same error.
  10. I'm testing the new check.php now. When i type in a code i know is valid it brings up this error : Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /Applications/MAMP/htdocs/check.phpon line 19 Please enter a valid voucher code. This is line 19 code: $selected_rows = mysql_num_rows($execute_select_statement);
  11. Here is my index.php now with my submit-form.php embedded into it. <?php //GLOBAL $HTTP_POST_FILES; //If the form is submitted if(isset($_POST['submit'])) { //Check to make sure that the name field is not empty if(trim($_POST['name']) == '') { $hasError = true; } else { $name = trim($_POST['name']); } //Check to make sure that the phone field is not empty if(trim($_POST['phone']) == '') { $hasError = true; } else { $phone = trim($_POST['phone']); } //Check to make sure sure that a valid email address is submitted if(trim($_POST['email']) == '') { $hasError = true; } else if (!preg_match("/^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$/i", trim($_POST['email']))) { $hasError = true; } else { $email = trim($_POST['email']); } //Check to make sure Address were entered if(trim($_POST['postaddress']) == '') { $hasError = true; } else { $postaddress =trim($_POST['postaddress']); } //Check to make sure Address were entered if(trim($_POST['postaddress2']) == '') { $hasError = true; } else { $postaddress2 =trim($_POST['postaddress2']); } //Check to make sure Address were entered if(trim($_POST['postcity']) == '') { $hasError = true; } else { $postcity =trim($_POST['postcity']); } //Check to make sure Address were entered if(trim($_POST['postregion']) == '') { $hasError = true; } else { $postregion =trim($_POST['postregion']); } //Check to make sure Address were entered if(trim($_POST['postcode']) == '') { $hasError = true; } else { $postcode =trim($_POST['postcode']); } //Check product size is selected $req=$_REQUEST['productsize']; require("check.php"); $req=$_REQUEST['grouponcode']; require("check.php"); // //Check image upload // $MaxFileSize = "2048000"; // max file size in bytes // $HDDSpace = "1048576"; // max total size of all files in directory // $HDDTotal = "445"; $OffExt = ""; // // add characters to strip out of filenames // $ThisFileName = basename(__FILE__); // get the file name // $abspath = str_replace($ThisFileName,"",__FILE__); // get the directory path // // full path // $path=$abspath; // $pathext="upload/"; // $snr = array("%","'","+","\\","/","#","..","!",'"',',','?','*','~'); // $temp=$HTTP_POST_FILES['imageupload']['name']; // if($HTTP_POST_FILES['imageupload']['name']) { $HTTP_POST_FILES['imageupload']['name'] = strip_tags($HTTP_POST_FILES['imageupload']['name']); // $HTTP_POST_FILES['imageupload']['name'] = str_replace($snr,"",$HTTP_POST_FILES['imageupload']['name']); // // remove any % signs from the file name // $HTTP_POST_FILES['imageupload']['name'] = trim($HTTP_POST_FILES['imageupload']['name']); // /* if the file size is within allowed limits */ // if($HTTP_POST_FILES['imageupload']['size'] > 0 && $HTTP_POST_FILES['imageupload']['size'] < $MaxFileSize) { // /* if adding the file will not exceed the maximum allowed total */ // if(($HDDTotal + $HTTP_POST_FILES['imageupload']['size']) < $HDDSpace) { // /* put the file in the directory */ // move_uploaded_file($HTTP_POST_FILES['imageupload']['tmp_name'], $path.$pathext.$HTTP_POST_FILES['imageupload']['name'].$OffExt); // $msg = "The file ".$HTTP_POST_FILES['imageupload']['name']." is Successfully uploaded "; // $myfrom = $Email; // $myemail = "me@mydomain.com"; // $todayis = date("l, F j, Y, g:i a") ; // $filename="http://www.sitename.com/".$pathext.$HTTP_POST_FILES['imageupload']['name'].$OffExt; // $filename=str_replace("","%20",$filename); // $subject= "Request From Website"; // $message = " // Name : $name // Phone : $phone // Email : $email // Address: $postaddress,$postaddress2,$postcity,$postprov,$postcode // Product Size: $product size // imageupload : $filename // "; // $from = "From: $myfrom\r\n"; // mail($myemail, $subject, $message, $from); // } else { // $msg = "The Filename: ".$HTTP_POST_FILES['imageupload']['name']." is BLOCKED from being uploaded here."; // } // } else { // $MaxKB = $MaxFileSize/1024; // // show the max file size in Kb // $msg = "The file was greater than the maximum allowed, file size of $MaxKB and could not be uploaded."; // } // } // /*print $msg;*/ // // mail($myemail, $filename, $subject, $message); // $emailSent = true; // } //If there is no error, send the email if(!isset($hasError)) { $emailTo = 'me@mydomain.com'; //Put your own email address here $body = "Name: $name \n\nPhone: $phone \n\nEmail: $email \n\nAddress:\n $postaddress\n$postaddress2\n$postcity\n$postregion\n$postcode\nProduct Size: $productsize\n$grouponcode\n"; $headers = 'From: My Domain <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email; mail($emailTo, $body, $headers); $emailSent = true; } } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"> <html> <head> <title>Groupon Form</title> <meta name="keywords" content="groupon, redeem, coupon code"> <meta name="description" content="fhfhdfhff" > <script type="text/javascript" src="jquery-1.2.6.min.js"></script> <style> #form-wrapper{width:800px; margin:0 auto;overflow:hidden;} h1{font-family:Arial; font-size:30px ;color:#999999;} h2{font-family: Arial,sans-serif;font-size:20px; color: #00AEEF;border-bottom:1px dotted #999999;} label,legend{display:inline-block;font-family: Arial; font-size: 16px; color: #00AEEF;padding:10px;width:30%;} input{font-family:arial;font-size:12px; color:#999999; padding:10px;} #name,#phone,#email,#address,#product-size,#groupon-code,#image-upload{padding: 20px 10px 0px;} #address label{display:block; width:50%;} #address-fields{float:right;display:inline-block;width:60%;padding-right:54px;} #address-fields input{width:80%;} #address-fields label{display:block;padding:0px;} #product-size{display:block;clear:both;} #product-size .one-col{display:block; width:60%;float:right; font-family:arial;font-size:14px;color:#999999;padding-right:54px;} #groupon-code{clear:both;} #submit{padding:20px;} #submit input{font-size:18px;margin:20px;} #status{display:inline-block;} .object_ok{border: 1px solid green; color:#333333;} .object_error{border: 1px solid #ac3962; color:#333333;} </style> <script type="text/javascript"> pic1 = new Image(16, 16); pic1.src="loader.gif"; $(document).ready(function(){ $("#grouponcode").change(function(){ var code =$("#grouponcode").val(); var productsize =$("productsize").val(); { $("#status").html('<img src="loader.gif" align="absmiddle"> Validating Code...'); $.ajax({ type: "POST", url:"check.php", data:"grouponcode="+code+"&productsize="+productsize, success: function(msg){ $("#status").ajaxComplete(function(event,request,settings){ if(msg == 'OK') { $("#grouponcode").removeClass('object_error'); $("#grouponcode").addClass('object_ok'); $(this).html(' <img src="tick.gif" align="absmiddle">'); } else { $("#grouponcode").removeClass('object_ok'); $("#grouponcode").addClass('object_error'); $(this).html(msg); } }); } }); } } )}); </script> </head> <body> <div id="form-wrapper"> <h1 align="center">Groupon Form</h1> <h2>Your Order</h2> <form method="POST" action="<?= $_SERVER['PHP_SELF'] ?>" > <div id="name"> <label for="name"><strong>Name: *</strong></label> <input type="text" size="30" name="name" value="" class="required" /> </div> <div id="phone"> <label for="phone"><strong>Phone: *</strong></label> <input type="text" size="30" name="phone" value="" class="required" /> </div> <div id="email"> <label for="email"><strong>Email: *</strong></label> <input type="text" size="30" name="email" value="" class="required email" /> </div> <div id="address"> <legend><strong>Address: *</strong></legend> </div> <div id="address-fields"> <label for="postaddress">Street Address</label> <input type="text" id="postaddress" name="postaddress" /> <label for="postaddress2">Address Line 2</label> <input type="text" id="postaddress2" name="postaddress2" /> <label for="postcity">City</label> <input type="text" id="postcity" name="postcity" /> <label for="postprov">Region</label> <input type="text" id="postregion" name="postregion" /> <label for="postcode">Postcode</label> <input type="text" id="postcode" name="postcode" /> </div> <div id="product-size"> <label for="productsize"><strong>Product Size: *</strong></label> <div class="one-col"><input type="radio" name='productsize' value="A4" checked="checked"/> A4 Size</div> <div class="one-col"><input type="radio" name='productsize' value="A3" /> A3 Size</div> <div class="one-col"><input type="radio" name='productsize' value="A2" /> A2 Size</div> </div> <div id="groupon-code"> <label for="grouponcode"><strong>Voucher Code: *</strong></label> <input type="text" id="grouponcode" name="grouponcode" /> </div> <div id="status"> </div> <!--<div id="image-upload"> <label for"imageupload"><strong>Upload Image: </strong></label> <input type="file" name="imageupload" /> </div>--> <div id="submit"> <input type="submit" value="Send Message" name="submit" /> </div> </form> </div> </body> </html> and here is the seperate check.php for the database queries <?php // Connect to Database $dbusername = "root"; $dbpassword = "***********"; $dbhostname = "localhost"; $con = mysql_connect("$dbhostname", "$dbusername", "$dbpassword") or die(mysql_error()); mysql_select_db("database1") or die(mysql_error()); // setting variables $grouponcode = mysql_real_escape_string($_POST['grouponcode']); $productsize = mysql_real_escape_string($_POST['productsize']); $grouponcode = mysql_real_escape_string($_POST['grouponcode']); $productsize = mysql_real_escape_string($_POST['productsize']); // Mark Whether groupon has been used $selectstatement = "SELECT grouponcode FROM ".$productsize." WHERE grouponcode = '" . $grouponcode . "'"; $execute_select_statement = mysql_query($selectstatement); // Gets the number of rows in the database that has the same groupon code. So it checks wheter the code exist. $selected_rows = mysql_num_rows($execute_select_statement); $updatestatement = "UPDATE ".$productsize." SET grouponused='1' WHERE grouponcode = '" . $grouponcode . "'"; $execute_update_statement = mysql_query($updatestatement); // Gets number of changed rows in the UPDATE statement. $rows_affected = mysql_affected_rows(); if ( $selected_rows > 0 && $rows_affected > 0 ) { echo 'Valid code.'; } else if ( $selected_rows > 0 && $rows_affected < 1) { echo 'Unfortunately that code has already been used.'; } else if ( $selected_rows == 0 && $rows_affected < 1 ) { echo 'Please enter a valid voucher code.'; } mysql_close($con); ?>
  12. Thank you very much! Having quickly tested it looks like its doing something right! definitely much further than i was before so thank you! Yes originally i has the submit-form.php within the index page itself when it was a simple form but i separated it, i think i will have my validation and send back in within the index and have check.php as a separate database query file. I will post the full code in one file shortly! Thank you again!
  13. Oops thankfully that is only on a test i literally set up a couple hours ago on a different computer, anyway i've changed password. When i go and fill in the voucher code area with anything to test what happens it is basically stuck at the "validating code... point of the ajax here $("#status").html('<img src="loader.gif" align="absmiddle"> Validating Code...'); $.ajax({ type: "POST", url:"check.php", data:"grouponcode="+code+"&productsize="+productsize, success: function(msg){ $("#status").ajaxComplete(function(event,request,settings){ if(msg == 'OK') So i cannot see if my sql statements are working. hmm
  14. Here is my check.php updated. Are you able to tell if my if statements look correct in what they are supposed to do? <?php $grouponcode = $_REQUEST['grouponcode']; $productsize = $_REQUEST['productsize']; $row = 'grouponused'; // Connect to Database $dbusername = "root"; $dbpassword = "adcliverpool306"; $dbhostname = "localhost"; $con = mysql_connect("$dbhostname", "$dbusername", "$dbpassword") or die(mysql_error()); // Create connection to database mysql_select_db("hamiltons") or die(mysql_error()); // Choose database on server $grouponcode = my_sql_escape_string($_POST['grouponcode']); //Select which table to use based on user input of radio button $productsize = addslashes($_REQUEST['productsize']); /*$selectstatement = "SELECT grouponcode,grouponused FROM table WHERE id= '". $productsize ."';"; $a4print = "SELECT grouponcode,grouponused FROM a4size WHERE grouponcode = '". $grouponcode ."';"; $a3print = "SELECT grouponcode,grouponused FROM a3size WHERE grouponcode = '". $grouponcode ."';"; $a2print = "SELECT grouponcode,grouponused FROM a2size WHERE grouponcode = '". $grouponcode ."';"; */ //Select two fields from table one for code one for code status used / unused $selectstatement = "SELECT grouponcode, grouponused FROM '" . $productsize . "' WHERE grouponcode = '" . $grouponcode . "'"; // Mark Whether groupon has been used $updatestatement = "UPDATE grouponused SET grouponused='1' WHERE grouponcode = '" . $grouponcode . "'"; $selectrows = mysql_query($selectstatement); $row = mysql_fetch_array($selectrows); // Get coupon code field from database result $dbgrouponcode = $row['grouponcode']; // Get coupon used field from database $dbgrouponused = $row['grouponused']; $grouponcode = $_REQUEST['grouponcode']; // Query if (isset($_REQUEST['grouponcode'])) { mysql_query($selectstatement); if ($grouponcode == "$dbgrouponcode") { if($dbgrouponused == "1") { echo("Unfortunately that code has already been used."); } elseif($dbgrouponused =="0") { echo ("OK"); } else { echo ("Please enter a valid voucher code."); } } } mysql_close($con); ?>
  15. so if my tables are each named "A4" "A3" "A2" it should search through the right table for the code the user enters? Thank you for your help. I'm leaving the imageupload validation to the very last as if it isn't ready by my deadline they will have to email the image until i get it right.
  16. Thank you. I'll go through those issues. No the groupon code is just a mix of letters and numbers. One of my main questions is how do i go about the 3 radio buttons id (productsize) and having each radio button correspond to each table I have and selects the appropriate table and then starts the search and validation of the grouponcode. On the submit-form.php where would I insert validation of the radio buttons and grouponcode field and validating the imageupload with image type etc. before it sends to the email ? I've looked at it so much now i'm just thinking to much into it! Thank you for your advice it is very much appreciated!
  17. Sorry, no its not updating it. I put that SQL statement in to phpadmin to test if it was working and it couldn't match the columns together so I know that update statement isn't correct, I tested the select statement by echo ing back and it queried the database.
  18. Hi Leon Yes each code needs to be set as used once a customer has entered it and submitted the form. I have two columns in each table with 1 column named "grouponused" with its value as "0" meaning the grouponcode is available and when it is used successfully the database updates it to "1" to represent it already taken. Do I look like im going in the right direction with this ? I'm on a deadline yōu see :~z Thank you for replying!
  19. Hi everyone I need help with a project I'm doing! I have an html form that is taking a customers name, phone, email, address, product size (radio button a4, a3, a2) groupon code and image upload and sending it to email. The scenario is i have one database and three tables within that database calles a4size, a3size and a2size. within each of these tables is 2 columns. one column id "grouponcode" that contains all of the groupon codes and the second column id "grouponused" which contains "0" for each The customer needs to be able to select the size they chose on the radio button : So if they choose A4 size it queries the A4 database table and searches for the code and if it is in the table and set at 0 it will give a message back "Code Validated" and update the grouponused row for that specific code to "1" so that it cannot be used again. and the same for A3size table and A2size table matching the radio button choice. They then need to upload an image and submit the form to email. I have my html form in there i have some ajax that is checking the code and displaying validation and message. Right now i can connect to the database fine and query the table as i echo'd it back to see what was happening. but i have a couple of problems I need to match each radio button value to the corresponding table in the database (which i cannot do) I need to validate the image upload (i'm struggling to put it together in the php code i already have) and when i submit it now it just brings up blank screen. and from what it looks like when i put a code in it quickly says validating and then displays nothing. This is my html form : <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"> <html> <head> <title>Groupon Form</title> <meta name="keywords" content=" groupon, redeem, coupon code"> <meta name="description" content="" > </meta> <script type="text/javascript" src="jquery-1.2.6.min.js"></script> <style> #form-wrapper{width:800px; margin:0 auto;overflow:hidden;} h1{font-family:Arial; font-size:30px ;color:#999999;} h2{font-family: Arial,sans-serif;font-size:20px; color: #00AEEF;border-bottom:1px dotted #999999;} label,legend{display:inline-block;font-family: Arial; font-size: 16px; color: #00AEEF;padding:10px;width:30%;} input{font-family:arial;font-size:12px; color:#999999; padding:10px;} #name,#phone,#email,#address,#product-size,#groupon-code,#image-upload{padding: 20px 10px 0px;} #address label{display:block; width:50%;} #address-fields{float:right;display:inline-block;width:60%;padding-right:54px;} #address-fields input{width:80%;} #address-fields label{display:block;padding:0px;} #product-size{display:block;clear:both;} #product-size .one-col{display:block; width:60%;float:right; font-family:arial;font-size:14px;color:#999999;padding-right:54px;} #groupon-code{clear:both;} #submit{padding:20px;} #submit input{font-size:18px;margin:20px;} #status{display:inline-block;} .object_ok{border: 1px solid green; color:#333333;} .object_error{border: 1px solid #ac3962; color:#333333;} </style> <script type="text/javascript"> pic1 = new Image(16, 16); pic1.src="loader.gif"; $(document).ready(function(){ $("#grouponcode").change(function(){ var code =$("#grouponcode").val(); var productsize =$("#productsize").val(); { $("#status").html('<img src="loader.gif" align="absmiddle"> Validating Code...'); $.ajax({ type: "POST", url:"check.php", data:"grouponcode="+code+"&productsize="+productsize, success: function(msg){ $("#status").ajaxComplete(function(event,request,settings){ if(msg == 'OK') { $("#grouponcode").removeClass('object_error'); $("#grouponcode").addClass('object_ok'); $(this).html(' <img src="tick.gif" align="absmiddle">'); } else { $("#grouponcode").removeClass('object_ok'); $("#grouponcode").addClass('object_error'); $(this).html(msg); } }); } }); } } )}); </script> </head> <body> <div id="form-wrapper"> <h1 align="center">Glass Art</h1> <h2>Your Order</h2> <form method="POST" action="submit-form.php" > <div id="name"> <label for="name"><strong>Name: *</strong></label> <input type="text" size="30" name="name" value="" class="required" /> </div> <div id="phone"> <label for="phone"><strong>Phone: *</strong></label> <input type="text" size="30" name="phone" value="" class="required" /> </div> <div id="email"> <label for="email"><strong>Email: *</strong></label> <input type="text" size="30" name="email" value="" class="required email" /> </div> <div id="address"> <legend><strong>Address: *</strong></legend> </div> <div id="address-fields"> <label for="postaddress">Street Address</label> <input type="text" id="postaddress" name="postaddress" /> <label for="postaddress2">Address Line 2</label> <input type="text" id="postaddress2" name="postaddress2" /> <label for="postcity">City</label> <input type="text" id="postcity" name="postcity" /> <label for="postprov">Region</label> <input type="text" id="postregion" name="postregion" /> <label for="postcode">Postcode</label> <input type="text" id="postcode" name="postcode" /> </div> <div id="product-size"> <label for="productsize"><strong>Product Size: *</strong></label> <div class="one-col"><input type="radio" id="productsize" name="productsize" value="a4size" checked="checked"/> A4 Size</div> <div class="one-col"><input type="radio" id="productsize" name="productsize" value="a3size" /> A3 Size</div> <div class="one-col"><input type="radio" id="productsize" name="productsize" value="a2size" /> A2 Size</div> </div> <div id="groupon-code"> <label for="grouponcode"><strong>Voucher Code: *</strong></label> <input type="text" id="grouponcode" name="grouponcode" /> </div> <div id="status"></div> <!--<div id="image-upload"> <label for"imageupload"><strong>Upload Image: </strong></label> <input type="file" name="imageupload" /> </div>--> <div id="submit"> <input type="submit" value="Send Message" name="submit" /> </div> </form> </div> </body> </html> This is my check.php for ajax and database querying <?php $grouponcode = $_REQUEST['grouponcode']; $productsize = $_REQUEST['productsize']; $row = 'grouponused' ; // Connect to Database $dbusername = "root"; $dbpassword = "*************"; $dbhostname = "localhost"; $con = mysql_connect("$dbhostname", "$dbusername", "$dbpassword") or die(mysql_error()); // Create connection to database mysql_select_db("hams") or die(mysql_error()); // Choose database on server $grouponcode = $_POST['grouponcode']; //Select which table to use based on user input of radio button /*$selectstatement = "SELECT grouponcode,grouponused FROM table WHERE id= '". $productsize ."';"; $a4print = "SELECT grouponcode,grouponused FROM a4size WHERE grouponcode = '". $grouponcode ."';"; $a3print = "SELECT grouponcode,grouponused FROM a3size WHERE grouponcode = '". $grouponcode ."';"; $a2print = "SELECT grouponcode,grouponused FROM a2size WHERE grouponcode = '". $grouponcode ."';"; */ //Select two fields from table one for code one for code status used / unused $selectstatement = "SELECT grouponcode, grouponused FROM `" . $productsize . "` WHERE grouponcode = '". $grouponcode."';"; // Mark Whether groupon has been used $updatestatement = "UPDATE grouponcode SET grouponused='1' WHERE grouponcode = '".$grouponcode ."';"; $selectrows = mysql_query($selectstatement); $row = mysql_fetch_array( $selectrows ); // Get coupon code field from database result $dbgrouponcode = $row['grouponcode']; // Get coupon used field from database $dbgrouponused = $row['grouponused']; $grouponcode = $_REQUEST['grouponcode']; // if (!isset($_REQUEST['grouponcode'])) { // echo("<form action='submit-form.php' method='post' id='checkgc'> // <p>Voucher Code: <input id='name' name='grouponcode' class='text' /><br /> // <input type='submit' name='submit' /></p></form>"); // } // elseif ($grouponcode=="") { // echo("Unfortunately that code has already been used."); // } // elseif ($grouponcode=="$dbgrouponcode") { // if ($grouponused=="0") { // mysql_query($updatestatement); // echo("Code Validated!"); // // } // } // // else { // echo("Invalid Code!"); // }; mysql_close($con); ?> And this is my submit-form.php (I've commented the image upload php section for now but that is what i'm trying to use) <?php //GLOBAL $HTTP_POST_FILES; //If the form is submitted if(isset($_POST['submit'])) { //Check to make sure that the name field is not empty if(trim($_POST['name']) == '') { $hasError = true; } else { $name = trim($_POST['name']); } //Check to make sure that the phone field is not empty if(trim($_POST['phone']) == '') { $hasError = true; } else { $phone = trim($_POST['phone']); } //Check to make sure sure that a valid email address is submitted if(trim($_POST['email']) == '') { $hasError = true; } else if (!preg_match("/^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$/i", trim($_POST['email']))) { $hasError = true; } else { $email = trim($_POST['email']); } //Check to make sure Address were entered if(trim($_POST['postaddress']) == '') { $hasError = true; } else { $postaddress =trim($_POST['postaddress']); } //Check to make sure Address were entered if(trim($_POST['postaddress2']) == '') { $hasError = true; } else { $postaddress2 =trim($_POST['postaddress2']); } //Check to make sure Address were entered if(trim($_POST['postcity']) == '') { $hasError = true; } else { $postcity =trim($_POST['postcity']); } //Check to make sure Address were entered if(trim($_POST['postregion']) == '') { $hasError = true; } else { $postregion =trim($_POST['postregion']); } //Check to make sure Address were entered if(trim($_POST['postcode']) == '') { $hasError = true; } else { $postcode =trim($_POST['postcode']); } //Check product size is selected $req=$_REQUEST['productsize']; require("check.php"); // //Check image upload // $MaxFileSize = "2048000"; // max file size in bytes // $HDDSpace = "1048576"; // max total size of all files in directory // $HDDTotal = "445"; $OffExt = ""; // // add characters to strip out of filenames // $ThisFileName = basename(__FILE__); // get the file name // $abspath = str_replace($ThisFileName,"",__FILE__); // get the directory path // // full path // $path=$abspath; // $pathext="upload/"; // $snr = array("%","'","+","\\","/","#","..","!",'"',',','?','*','~'); // $temp=$HTTP_POST_FILES['imageupload']['name']; // if($HTTP_POST_FILES['imageupload']['name']) { $HTTP_POST_FILES['imageupload']['name'] = strip_tags($HTTP_POST_FILES['imageupload']['name']); // $HTTP_POST_FILES['imageupload']['name'] = str_replace($snr,"",$HTTP_POST_FILES['imageupload']['name']); // // remove any % signs from the file name // $HTTP_POST_FILES['imageupload']['name'] = trim($HTTP_POST_FILES['imageupload']['name']); // /* if the file size is within allowed limits */ // if($HTTP_POST_FILES['imageupload']['size'] > 0 && $HTTP_POST_FILES['imageupload']['size'] < $MaxFileSize) { // /* if adding the file will not exceed the maximum allowed total */ // if(($HDDTotal + $HTTP_POST_FILES['imageupload']['size']) < $HDDSpace) { // /* put the file in the directory */ // move_uploaded_file($HTTP_POST_FILES['imageupload']['tmp_name'], $path.$pathext.$HTTP_POST_FILES['imageupload']['name'].$OffExt); // $msg = "The file ".$HTTP_POST_FILES['imageupload']['name']." is Successfully uploaded "; // $myfrom = $Email; // $myemail = "hannah.rolston@adc-creative.co.uk"; // $todayis = date("l, F j, Y, g:i a") ; // $filename="http://www.sitename.com/".$pathext.$HTTP_POST_FILES['imageupload']['name'].$OffExt; // $filename=str_replace("","%20",$filename); // $subject= "Request From Website"; // $message = " // Name : $name // Phone : $phone // Email : $email // Address: $postaddress,$postaddress2,$postcity,$postprov,$postcode // Product Size: $productsize // imageupload : $filename // "; // $from = "From: $myfrom\r\n"; // mail($myemail, $subject, $message, $from); // } else { // $msg = "The Filename: ".$HTTP_POST_FILES['imageupload']['name']." is BLOCKED from being uploaded here."; // } // } else { // $MaxKB = $MaxFileSize/1024; // // show the max file size in Kb // $msg = "The file was greater than the maximum allowed, file size of $MaxKB and could not be uploaded."; // } // } // /*print $msg;*/ // // mail($myemail, $filename, $subject, $message); // $emailSent = true; // } //If there is no error, send the email if(!isset($hasError)) { $emailTo = 'me@mydomain.com'; //Put your own email address here $body = "Name: $name \n\nPhone: $phone \n\nEmail: $email \n\nAddress:\n $postaddress\n$postaddress2\n$postcity\n$postregion\n$postcode\nProduct Size: $productsize\n$grouponcode\n$imageupload"; $headers = 'From: Hams<'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email; mail($emailTo, $body, $headers); $emailSent = true; } } ?> I'm scratching my head at this point as I am only slightly clued up on php,ajax,jquery right now! Thank you in advance!
  20. I've just tried that this second, and its very similar what it brings up but you have to buy it for $30 and i know that the person who originally used it didn't buy it. Hes away so cannot communicate with him. thanks for the link! x
  21. Hi guys, Can anyone identify this font for me? It is VERY similar to champagne & limousines but not the same. If anyone could help that would be brilliant! Thanks
  22. Thank you Wickham that centres it but is their no way the ends of my image can overflow the main wrapper div ?
  23. Thanks for the advice, unfortunately nothing is centering it, i think its something with woo canvas i'm using, so i've just set margin-left to 25% for now. Hannah x
  24. Thank you both, It is being built in wordpress, and i already had what i thought would center it, and still no joy, but evu i tried -101px and it seems to have put it in right place, hopefully this won't move thanks very much! now i just need to senter the actual navigation links, which doesn't seem to easy on wordpress. Thanks!

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.