PHP - Check For Blank Fields
hi, is there a way to do a check for blank fields before posting to database? dumb users keep adding blank fields.
i need to check fields $_POST[company], $_POST[jobNO] and $_POST[staff]. Code: [Select] if(isset($_POST['add'])) { $cname=$_POST[company]; $compid = mysql_query("SELECT * FROM company WHERE company = '$cname'"); while($row4 = mysql_fetch_array($compid)) { $cid=$row4["ID"]; } $query = "INSERT INTO jobno VALUES ( NULL, '$_POST[jobNO]', '$cid' )"; mysql_query($query) or die('Error, insert failed'); $query1 = "INSERT INTO staff VALUES ( NULL, '$_POST[staff]', '$_POST[Y]-$_POST[M]-$_POST[D]', '$_POST[jobNO]' )"; mysql_query($query1) or die('Error, insert failed1'); echo "1 record added"; Similar TutorialsHi. I've been doing tutorials all day on checking for blank fields and I have wrote a function to do so. For now I am only checking one field to see if it works. If I miss that field out (first name) It works great and displays the correct error message. Problem I have is if I fill in the whole form and send it I get an Inturnal server error. I will post my code to show you. can anyone see whats going wrong? I have \\ some of the code for now because I my keep it if I cant do this error check. session_start(); $validation_id = strval(time()); if(isset($_POST['submit'])) { $first_name = check_input($_POST['first_name'],"Please enter a first name"); $last_name = check_input($_POST['last_name']); $DOB = check_input($_POST['DOB']); $sex = check_input($_POST['sex']); $email = check_input($_POST['email']); $username = check_input($_POST['username']); $password = check_input($_POST['password']); $agree = check_input($_POST['agreed']); $creation_date = check_input($_POST['creation_date']); $user_type = check_input($_POST['member_type']); $access_level = check_input($_POST['access_level']); $validation = check_input($_POST['validation_id']); $club_user =check_input($_POST['user_type']); // $first_name = mysql_real_escape_string($_POST['first_name']); // $last_name = mysql_real_escape_string($_POST['last_name']); // $DOB = mysql_real_escape_string($_POST['DOB']); // $sex = mysql_real_escape_string($_POST['sex']); // $email = mysql_real_escape_string($_POST['email']); // $username = mysql_real_escape_string($_POST['username']); // $password = mysql_real_escape_string($_POST['password']); // $agree = mysql_real_escape_string($_POST['agreed']); // $creation_date = mysql_real_escape_string($_POST['creation_date']); // $user_type = mysql_real_escape_string($_POST['member_type']); // $access_level = mysql_real_escape_string($_POST['access_level']); // $validation = mysql_real_escape_string($_POST['validation_id']); // $club_user = mysql_real_escape_string($_POST['user_type']); $insert_member= "INSERT INTO Members (`first_name`,`last_name`,`DOB`,`sex`,`email`,`username`,`password`,`agree`,`creation_date`,`usertype`,`access_level`,`validationID`) VALUES ('".$first_name."','".$last_name."','".$DOB."','".$sex."','".$email."','".$username."','".$password."','".$agree."','".$creation_date."','".$user_type."','".$access_level."', '".$validation."')"; $insert_member_now= mysql_query($insert_member) or die(mysql_error()); $url = "thankyou.php?name=".$_POST['username']; header('Location: '.$url); and the form <form method="POST" name="member_accounts" id="member_accounts"> <input name="first_name" type="text" class="form_fields" value="<?php echo $_POST['first_name'];?>" size="20" /> <input name="last_name" type="text" class="form_fields" value="<?php echo $_POST['last_name'];?>" size="20" /> <input name="submit" type="submit" class="join_submit" id="submit_member" value="Create Account" /> <? function check_input($data, $problem='') { $data= trim($data); $data= stripslashes($data); $data= htmlspecialchars($data); if ($problem && strlen($data) ==0) { die($problem); } return $data; } ?> Hello, I'm using the below code to determine whether fields have been left blank, however, it only a standard sentence, i'd like to customise it, like: "Email has been left blank" or The email and message has been left blank. My best preference would be to bullet point each line. IE: Email has been left blank. Message has been left blank. $name = $_POST['name']; $visitor_email = $_POST['email']; $user_message = $_POST['message']; if(empty($name)|| empty($visitor_email)|| empty($user_message)) { $errors .= "\n Some of the above fields have not been filled in.<br><br> "; } Many thanks. Good morning, I am a beginner at PHP, but trying to write a simple script to use at work and currently stuck on one part, looking for some advice! I have a simple form here > http://jmdostal.com/route2.php (Feel free to use it to test), that returns data on the next page, in a format such as : Jose F - Jose A - 285 Brenda L [Delivery] [Dallas] - Items Job 2 [Pickup] [Arlington] - Items [] [] - [] [] - [] [] - [] [] - [] [] - Gustavo - +1 - 284/pickup Jody W [Delivery] [Keller] - Items [] [] - [] [] - [] [] - [] [] - [] [] - [] [] - My question is how can I get it not to show the fields that are empty, so I dont have a bunch of lines with [] [] - formatting Here is my coding you can view here > http://jmdostal.com/code.txt A friend had suggested to me trying to use isset , so I tried it on a few lines, such as : if(isset($_POST['items14'])){ $items14 = "- ". Trim(stripslashes($_POST['items14'])); } But it didnt seem to change anything. Im sure this is something simply, Any suggestions are appreciated! Thanks ! 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? Code: [Select] <?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()); } ?> Hi all, I am trying to write a script that finds the blank $_POST values and add them to a $blank_array. All I get is a blank page - any ideas? Also is there some code I can put at the top of every php page to show exactly what the errors are? - I have tried a few scripts but have not found one to work universally. include("cxn.php"); $reg = "G-".strtoupper($_POST['reg']); $sql = "SELECT * FROM sales WHERE reg='$reg'"; $result = mysqli_query($cxn,$sql) or die ("Couldn't execute query"); $num = mysqli_num_rows($result); if ($num >0) // Listing Already Found { echo "The aircraft '$reg' is already listed!"; echo $_SESSION['logname']; } foreach ($_POST as $value) { if ($value == "") { $blank_array[] = $field; } if (@sizeof($blank_array) > 0) // blank fields are found { $error = "Please fill in all the form.<br>"; include ("../sell-your-reg.php"); } } ?> Hi guys! New to the community and hope to learn a lot here! Here is some background info and what I want to do, and what I know. I have been building websites for years, and I am familiar with Actionscript 3.0. And I have successful ran a few wordpress websites. What I am trying to do right now however is modify this form script I found, to only email the data when the field isn't left blank. It's stumping me because the actual "message" that ends up being the body of the email is a variable. And form what I can tell I can't figure out how to put if statements into it. If anyone can take a look at this script and give me any pointers you would be awesome. Code: [Select] <?php //trying to store the date in a separate variable only when it's not blank if ($_POST['starttime'] == '') { //nothing; } else { $showStartTime == "Start time: " . $_POST['starttime'] . ""; } if ($_POST['finishtime'] == '') { //nothing; } else { $showFinishTime == "Finish time: " . $_POST['finishtime'] . ""; } // Read POST request params into global vars $to = $_POST['to']; $from = $_POST['from']; $name = $_POST['name']; $company = $_POST['company']; $newcustomer = $_POST['newcustomer']; $address1 = $_POST['address1']; $address2 = $_POST['address2']; $subject = ("Event Rental for " . $name . ""); $description = $_POST['description']; $phone = $_POST['phone']; $message = (" Name: " . $name . " Company or Organization: " . $company . " Phone Number: " . $phone . " Email Address: " . $from . " Street Address: " . $address1 . " " . $address2 . " New Customer: " . $newcustomer . " Customer From: " . $_POST['howyouheard'] . " Interested in: SkyLoft " . $_POST['whichspace'] . " Date: " . $_POST['date'] . " Day of Week: " . $_POST['dayofweek'] . " " . $showStartTime . " " . $showFinishTime . " Number of Guests: " . $_POST['Guests'] . " Format: " . $_POST['format'] . " Occasion: " . $_POST['Occasion'] . " Optional Needs: " . $_POST['dj'] . " " . $_POST['tables'] . " " . $_POST['chairs'] . " " . $_POST['eventbanner'] . " " . $_POST['pasoundsystem'] . " Message: " . $description . " "); // Obtain file upload vars $fileatt = $_FILES['fileatt']['tmp_name']; $fileatt_type = $_FILES['fileatt']['type']; $fileatt_name = $_FILES['fileatt']['name']; $headers = "From: $from"; if (is_uploaded_file($fileatt)) { // Read the file to be attached ('rb' = read binary) $file = fopen($fileatt,'rb'); $data = fread($file,filesize($fileatt)); fclose($file); // Generate a boundary string $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; // Add the headers for a file attachment $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; // Add a multipart boundary above the plain message $message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/plain; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n"; // Base64 encode the file data $data = chunk_split(base64_encode($data)); // Add file attachment to the message $message .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" . " name=\"{$fileatt_name}\"\n" . //"Content-Disposition: attachment;\n" . //" filename=\"{$fileatt_name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n" . "--{$mime_boundary}--\n"; } // Send the message $ok = @mail($to, $subject, $message, $headers); if ($ok) { echo "<p><b>Thank you for your interest in SkyLofts!</b> <br>You should recieve a verification in your inbox that we recieved your request. We will contact you as soon as possible and hopefully be able to answer any questions you may have! You can also contact us via phone 410-791-6699, or toll-free 1-800-344-0410.</p>"; } else { echo "<p>There was an error when processing your request. Please try again.</p>"; } ?> HI, I have a user form on a modal. The user can be updated from this modal but on the second tab is where the users password can be updated. The update button commits all changes including the password update. If the New Password field is blank i do not want it to be updated. I am using a prepared statement and am not sure how to ommit a field if it is blank. In actual fact there is a new password and a confirm password field which must be the same before the password field is updated. if ($_SERVER['REQUEST_METHOD']=='POST'){ $uid = $_POST['UM-uid']; $fname = $_POST['UM-firstName']; $lname = $_POST['UM-lastName']; $email = $_POST['UM-emailAddress']; $accountlevel = $_POST['UM-accountLevelId']; $mobile = $_POST['UM-mobileNumber']; $roleid = $_POST['UM-roleId']; $newpass = password_hash($_POST['UM-pass'], PASSWORD_DEFAULT); if(!empty($_POST['UM-firstName'])){ // prepare stmt $stmt = $conn->prepare(" UPDATE ssm_user SET user_password=?, user_email=?, user_firstname=?, user_lastname=?, user_account_level_id=?, user_mobile=?, user_role_id=? WHERE user_id = ? "); $stmt->bind_param('sssssssi', $newpass, $email, $fname, $lname, $accountlevel, $mobile, $roleid, $uid); $stmt->execute(); $_SESSION['user']=$fname." ".$lname; $_SESSION['updateUser']="has been successfully updated"; $_SESSION['actionstatus']="success"; I am sure i will be able to work out the password confirmation part, its just the omitting password from being part of the update if blank. I have a form with a gender control made up of two radio buttons. If the user doesn't fill out this form, nothing gets submitted (i.e name='gender') in the $_POST array. So how ae you supposed to verify that the form field was left blank, and use that information to say display an error message on the form? Edited February 16 by SaranacLakeHi, I have a page where a user can change his password what i want to acheive is a way of checking the database if the text the user has entered in the textboxes already exist in the db, and if it does exist change a certain part. for example the user goes to the address, types in the email, user name and password twice. if the username and email match in the db i would like the password to write over the old password that was in the db. i keep confusing myself when i think i know what im doing but i keep stumbling. i know this sounds a bit confusing so please ask if you need more understanding. so far ive got: Code: [Select] <?php $n=$_POST['uname']; $e=$_POST['email']; if( $_POST['submitted'] == 'yes' ) { if( $_POST['pass_1'] != $_POST['pass_2'] ) { // fields don't match, so do something to indicate the error . . . echo '<p>Passwords Do Not Match</p>'; } // connect to the db include('config.php'); $query="select * from user where uname='$n' and email='$e'"; $result=mysql_query($query); } ?> <form action="" method="post"> <input type="text" name="uname" id="uname" size="30"> <input type="text" name="email" id="email" size="30"> <input type="password" name="pass_1" /> <input type="password" name="pass_2" /> <input type="hidden" name="submitted" value ="yes" /> <input type="submit" name="submit" value="Change Password" /> </form> just by looking at my code again i think its not right at all, the first php bit is only checking the password textboxes. i think i need to remove my email and username out of that form and put them in another. am i right? sorry im not that good at php or mysql thanks in advance and sorry for such a long read ...added to an error log? Currently, my coding is as follows: Form to gather data: Code: [Select] <html><head><title>Car Accident Report Form</title></head> <form action="errorlog.php" method="post"> First Name: <br><input type="text" name="name"><br> Surname:<br> <input type="text" name="surname"><br> Age: <br><input type="text" name="age"><br> Weeks Since Accident: <br><input type="text" name="weeks"><br> <input type="submit" value="Submit"> </form> Coding for error log: Code: [Select] <html><head><title>Validating Car Accident Report Form Details</title></head> <?php $name=$_POST["name"]; $surname=$_POST["surname"]; $age=$_POST["age"]; $weeks=$_POST["weeks"]; $subtime = strftime('%c'); $pass = "The details uploaded are fine<br><br>"; if ((((trim($name)="" && trim($surname)="" && trim($age)="" && trim($weeks)="")))) { echo "It seems that you have not entered a value for the Name, Surname, Age or Weeks fields. This has been added to the error log.<br><br>"; error_log("<b><u>Error</b></u><br>The user has not entered any values", 3, "C:/xampp/htdocs/errorlog.txt"); } if (($age<18)&& ($weeks<=1)) { echo "It seems that you have entered an invalid age and number of weeks since the accident. This has been added to the error log.<br><br>"; error_log("<b><u>Error</b></u><br>The user has entered an age that is below 18 and the number of weeks since the accident is equal to or under 1 week!<br>Age entered:" . $age . "<br>Number Of Weeks Since Accident entered:" . $weeks . "<br>Time that form was submitted:" . $subtime . "<br><br>", 3, "C:/xampp/htdocs/errorlog.txt"); } else if ($age<18) { echo "It seems that you have entered an invalid age. This has been added to the error log.<br><br>"; error_log("<b><u>Age Error</b></u><br>The user has entered an age that is below 18!<br>Age entered:" . $age . "<br>Time that form was submitted:" . $subtime . "<br><br>", 3, "C:/xampp/htdocs/errorlog.txt"); } else if ($weeks<=1) { echo "It seems that you have entered an invalid age number of weeks since the accident. This has been added to the error log.<br><br>"; error_log("<b><u>Week Error</b></u><br>The user has entered a number of weeks since the accident that is equal to or under 1 week!<br>Number Of Weeks Since Accident entered:" . $weeks . "<br> Time that form was submitted:" . $subtime . "<br><br>", 3, "C:/xampp/htdocs/errorlog.txt"); } else { echo $pass; } echo "Car Accident Report Form details have been sent<br>"; echo "<a href='readlog.php'>Read Error Log</a>" ?> </html> How can I get it so that if a user presses the space bar in a field, then the trim function sees that there's no white space and then this gets added to the error log? Any help is appreciated! I'm trying to show on my order printed receipt some checkout fields and extras from the products. The website is www.prontoitaliano.co.uk/shop What needs to appear on the receipt are all the extras options from all the products(See checkboxes in all pasta dishes and checkboxes toppings in "create your own pizza") and 2 fields from the checkout page (Pick up Date, Pick up Time). To send the order to the printer I'm using the "Star cloud PRNT woocommerce" plugin and for the pickup date and time fields "ultimate woocommerce delivery and pickup date time", I've attached below the code that needs to be edited to add more fields to the receipt. I know that probably it's not difficult to solve my issue but I don't have any knowledge of php and I hope you guys can assist me. Also, I've attached a picture showing what is missing on the printed receipt and what result I'm trying to get. Thanks for your time!
<?php function star_cloudprnt_get_column_separated_data($columns) { $max_chars = STAR_CLOUDPRNT_MAX_CHARACTERS_THREE_INCH; $total_columns = count($columns); if ($total_columns == 0) return ""; if ($total_columns == 1) return $columns[0]; if ($total_columns == 2) { $total_characters = strlen($columns[0])+strlen($columns[1]); $total_whitespace = $max_chars - $total_characters; if ($total_whitespace < 0) return ""; return $columns[0].str_repeat(" ", $total_whitespace).$columns[1]; } $total_characters = 0; foreach ($columns as $column) { $total_characters += strlen($column); } $total_whitespace = $max_chars - $total_characters; if ($total_whitespace < 0) return ""; $total_spaces = $total_columns-1; $space_width = floor($total_whitespace / $total_spaces); $result = $columns[0].str_repeat(" ", $space_width); for ($i = 1; $i < ($total_columns-1); $i++) { $result .= $columns[$i].str_repeat(" ", $space_width); } $result .= $columns[$total_columns-1]; return $result; } function star_cloudprnt_get_seperator() { $max_chars = STAR_CLOUDPRNT_MAX_CHARACTERS_THREE_INCH; return str_repeat('_', $max_chars); } function star_cloudprnt_parse_order_status($status) { if ($status === 'wc-pending') return 'Pending Payment'; else if ($status === 'wc-processing') return 'Processing'; else if ($status === 'wc-on-hold') return 'On Hold'; else if ($status === 'wc-completed') return 'Completed'; else if ($status === 'wc-cancelled') return 'Cancelled'; else if ($status === 'wc-refunded') return 'Refunded'; else if ($status === 'wc-failed') return 'Failed'; else return "Unknown"; } function star_cloudprnt_get_codepage_1252_currency_symbol() { $symbol = get_woocommerce_currency_symbol(); if ($symbol === "£") return "\xA3"; // £ pound else if ($symbol === "$") return "\x24"; // $ dollar else if ($symbol === "€") return "\x80"; // € euro return ""; // return blank by default } function star_cloudprnt_get_formatted_variation($variation, $order, $item_id) { $return = ''; if (is_array($variation)) { $variation_list = array(); foreach ($variation as $name => $value) { // If the value is missing, get the value from the item if (!$value) { $meta_name = esc_attr(str_replace('attribute_', '', $name)); $value = $order->get_item_meta($item_id, $meta_name, true); } // If this is a term slug, get the term's nice name if (taxonomy_exists(esc_attr(str_replace('attribute_', '', $name)))) { $term = get_term_by('slug', $value, esc_attr(str_replace('attribute_', '', $name))); if (!is_wp_error($term) && ! empty($term->name)) { $value = $term->name; } } else { $value = ucwords(str_replace( '-', ' ', $value )); } $variation_list[] = wc_attribute_label(str_replace('attribute_', '', $name)) . ': ' . rawurldecode($value); } $return .= implode('||', $variation_list); } return $return; } function star_cloudprnt_create_receipt_items($order, &$printer) { $order_items = $order->get_items(); foreach ($order_items as $item_id => $item_data) { $product_name = $item_data['name']; $product_id = $item_data['product_id']; $variation_id = $item_data['variation_id']; $item_qty = $order->get_item_meta($item_id, "_qty", true); $item_total_price = floatval($order->get_item_meta($item_id, "_line_total", true)) +floatval($order->get_item_meta($item_id, "_line_tax", true)); $item_price = floatval($item_total_price) / intval($item_qty); $currencyHex = star_cloudprnt_get_codepage_1252_currency_symbol(); $formatted_item_price = number_format($item_price, 2, '.', ''); $formatted_total_price = number_format($item_total_price, 2, '.', ''); $printer->set_text_emphasized(); $printer->add_text_line(str_replace('–', '-', $product_name)." - ID: ".$product_id.""); $printer->cancel_text_emphasized(); if ($variation_id != 0) { $product_variation = new WC_Product_Variation( $variation_id ); $variation_data = $product_variation->get_variation_attributes(); $variation_detail = star_cloudprnt_get_formatted_variation($variation_data, $order, $item_id); $exploded = explode("||", $variation_detail); foreach($exploded as $exploded_variation) { $printer->add_text_line(" ".ucwords($exploded_variation)); } } $printer->add_text_line(star_cloudprnt_get_column_separated_data(array(" Qty: ". $item_qty." x Cost: ".$currencyHex.$formatted_item_price, $currencyHex.$formatted_total_price))); } } function star_cloudprnt_create_address($order, $order_meta, &$printer) { $fname = $order_meta[_shipping_first_name][0]; $lname = $order_meta[_shipping_last_name][0]; $a1 = $order_meta[_shipping_address_1][0]; $a2 = $order_meta[_shipping_address_2][0]; $city = $order_meta[_shipping_city][0]; $state = $order_meta[_shipping_state][0]; $postcode = $order_meta[_shipping_postcode][0]; $tel = $order_meta[_billing_phone][0]; $printer->set_text_emphasized(); if ($a1 == '') { $printer->add_text_line("Billing Address:"); $printer->cancel_text_emphasized(); $fname = $order_meta[_billing_first_name][0]; $lname = $order_meta[_billing_last_name][0]; $a1 = $order_meta[_billing_address_1][0]; $a2 = $order_meta[_billing_address_2][0]; $city = $order_meta[_billing_city][0]; $state = $order_meta[_billing_state][0]; $postcode = $order_meta[_billing_postcode][0]; } else { $printer->add_text_line("Shipping Address:"); $printer->cancel_text_emphasized(); } $printer->add_text_line($fname." ".$lname); $printer->add_text_line($a1); if ($a2 != '') $printer->add_text_line($a2); if ($city != '') $printer->add_text_line($city); if ($state != '') $printer->add_text_line($state); if ($postcode != '') $printer->add_text_line($postcode); $printer->add_text_line("Tel: ".$tel); } function star_cloudprnt_print_order_summary($selectedPrinter, $file, $order_id) { $order = wc_get_order($order_id); $shipping_items = @array_shift($order->get_items('shipping')); $order_meta = get_post_meta($order_id); $printer = new Star_CloudPRNT_Star_Line_Mode_Job($selectedPrinter, $file); $printer->set_codepage("20"); // 20 hex == 32 decimal == 1252 Windows Latin-1 if (get_option('star-cloudprnt-print-logo-top-input')) $printer->add_nv_logo(esc_attr(get_option('star-cloudprnt-print-logo-top-input'))); $printer->set_text_emphasized(); $printer->set_text_center_align(); $printer->add_text_line("ORDER NOTIFICATION"); $printer->set_text_left_align(); $printer->cancel_text_emphasized(); $printer->add_new_line(1); $printer->add_text_line(star_cloudprnt_get_column_separated_data(array("Order #".$order_id, date("d-m-y H:i:s", time())))); $printer->add_new_line(1); $printer->add_text_line("Order Status: ".star_cloudprnt_parse_order_status($order->post->post_status)); $printer->add_text_line("Order Date: ".$order->order_date); if (isset($shipping_items['name'])) { $printer->add_new_line(1); $printer->add_text_line("Shipping Method: ".$shipping_items['name']); } $printer->add_text_line("Payment Method: ".$order_meta[_payment_method_title][0]); $printer->add_new_line(1); $printer->add_text_line(star_cloudprnt_get_column_separated_data(array('ITEM', 'TOTAL'))); $printer->add_text_line(star_cloudprnt_get_seperator()); star_cloudprnt_create_receipt_items($order, $printer); $printer->add_new_line(1); $printer->set_text_right_align(); $formatted_overall_total_price = number_format($order_meta[_order_total][0], 2, '.', ''); $printer->add_text_line("TOTAL ".star_cloudprnt_get_codepage_1252_currency_symbol().$formatted_overall_total_price); $printer->set_text_left_align(); $printer->add_new_line(1); $printer->add_text_line("All prices are inclusive of tax (if applicable)."); $printer->add_new_line(1); star_cloudprnt_create_address($order, $order_meta, $printer); $printer->add_new_line(1); $printer->set_text_emphasized(); $printer->add_text_line("Customer Provided Notes:"); $printer->cancel_text_emphasized(); $printer->add_text(empty($order->post->post_excerpt) ? "None" : $order->post->post_excerpt); if (get_option('star-cloudprnt-print-logo-bottom-input')) $printer->add_nv_logo(esc_attr(get_option('star-cloudprnt-print-logo-bottom-input'))); $printer->printjob(); } function star_cloudprnt_woo_on_thankyou($order_id) { $file = STAR_CLOUDPRNT_PRINTER_PENDING_SAVE_PATH.star_cloudprnt_get_os_path("/order_".$order_id."_".time().".bin"); $selectedPrinter = ""; $printerList = star_cloudprnt_get_printer_list(); if (!empty($printerList)) { foreach ($printerList as $printer) { if (get_option('star-cloudprnt-printer-select') == $printer['name']) { $selectedPrinter = $printer['printerMAC']; break; } } if ($selectedPrinter === "" && count($printerList) === 1) $selectedPrinter = $printer['printerMAC']; if ($selectedPrinter !== "") star_cloudprnt_print_order_summary($selectedPrinter, $file, $order_id); } } function star_cloudprnt_setup_order_handler() { if (selected(get_option('star-cloudprnt-select'), "enable", false) !== "" && star_cloudprnt_is_woo_activated()) { add_action('woocommerce_thankyou', 'star_cloudprnt_woo_on_thankyou', 1, 1); } }
Hello All: Trying to work with PHP on a contact form with a jQuery Validation to make certain that the visitors fill out the required information. I'll try to show everything that I have, and then the error I am getting when the visitor hits "submit." I don't know PHP all that well, and trying to learn my way through it. I used a couple of tutorials to add the features I needed and did my own styling on the live site. Here is the PHP that is currently in the header of my markup: <?php //If the form is submitted if(isset($_POST['submit'])) { //Check to make sure that the First name field is not empty if(trim($_POST['firstname']) == '') { $hasError = true; } else { $firstname = trim($_POST['firstname']); } //Check to make sure that the Last name field is not empty if(trim($_POST['lastname']) == '') { $hasError = true; } else { $lastname = trim($_POST['lastname']); } //Check to make sure that the Street Address 01 field is not empty if(trim($_POST['street01']) == '') { $hasError = true; } else { $street01 = trim($_POST['street01']); } //If Street02 is filled out, give it a value $street02 = $_POST['street02']; //Check to make sure that the City field is not empty if(trim($_POST['city']) == '') { $hasError = true; } else { $city = trim($_POST['city']); } //Check to make sure that the State field is not empty if(trim($_POST['state']) == '') { $hasError = true; } else { $state = trim($_POST['state']); } //Check to make sure that the Zip field is not empty if(trim($_POST['zip']) == '') { $hasError = true; } else { $zip = trim($_POST['zip']); } //If Email is filled out, give it a value $email = $_POST['email']; //If Telephone is filled out, give it a value $telephone = $_POST['telephone']; //Default Subject Value $subject = "VMC Inquiry"; //Check checkboxes foreach($_POST['check'] as $value) { $check_msg = "Checked: $value\n"; } //If Message is filled out, give it a value $comment = $_POST['comment']; //If there is no error, send the email if(!isset($hasError)) { $emailTo = 'xxxx.xxxx@gmail.com'; //Put your own email address here $body = "Name: $firstname $lastname \n\nStreet Address: $street01 \n\nStreet Address*: $street02 \n\nCity: $city \n\nState: $state \n\nZip: $zip \n\nEmail*: $email \n\nTelephone*: $telephone \n\nCheck Box: $check_msg \n\nMessage:\n $comment"; $headers = 'From: XXXXX <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email; mail($emailTo, $subject, $body, $headers); $emailSent = true; } } ?> So basically I am using classes to say whether or not something is required, which ties into the jQuery validation. If it isn't required, whatever the visitor types into the box is put into something like "$telephone" which is then printed in the e-mail. The markup for the forms in the body is the following: Code: [Select] <p class="contact-text-right">For more information, or to have a list of our properties mailed to you, please fill out the form below.</p> <div id="contact-wrapper"> <?php if(isset($hasError)) { //If errors are found ?> <p class="error">Please check if you've filled all the fields with valid information. Thank you.</p> <?php } ?> <?php if(isset($emailSent) && $emailSent == true) { //If email is sent ?> <p class="accept"><strong><?php echo $firstname;?>,Your Email Successfully Sent!</strong></p> <?php } ?> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" id="contactform"> <div id="names"> <label for="firstname"><strong>First Name:</strong></label> <input type="text" name="firstname" id="firstname" value="" class="required" /> <label for="lastname"><strong>Last Name:</strong></label> <input type="text" name="lastname" id="lastname" value="" class="required" /> </div> <div id="address01"> <label for="street01"><strong>Street Address:</strong></label> <input type="text" name="street01" id="street01" value="" class="required" /> </div> <div id="address02"> <label for="street02"><strong>Street Address*:</strong></label> <input type="text" name="street02" id="street02" value="" /> </div> <div id="city"> <label for="city"><strong>City:</strong></label> <input type="text" name="city" id="city" value="" class="required city" /> <label for="state"><strong>State:</strong></label> <input type="text" name="state" id="state" value="" class="required state" /> <label for="zip"><strong>Zip Code:</strong></label> <input type="text" name="zip" id="zip" value="" class="required zip" /> </div> <div id="email"> <label for="email"><strong>E-mail*:</strong></label> <input type="text" name="email" id="email" value="" class="email"/> <label for="telephone"><strong>Telephone*:</strong></label> <input type="text" name="telephone" id="telephone" value="" class="telephone" /> <p class="bottom">*Optional fields.</p> </div> <div class="checkbox"> <p><input type="checkbox" name="check[]" value="properties">XXX</p> <p><input type="checkbox" name="check[]" value="contact-regarding">XXXX</p> <p class="indent">(Please list properties or ask specific questions in the space below.)</p> </div> <div id="comment"> <label for="comment"></label> <textarea name="comment" id="comment" ></textarea> </div> <div id="button"> <input type="submit" value="Send Message" name="submit" /> </div> </form> All seems well until I hit submit on the live site. I think get this error returned to me: Warning: Invalid argument supplied for foreach() in ......./html/development/contact.php on line 64 The e-mail goes through, with all the information, no problems! I just can't get this error message to go away. Line 64 of contact.php is where the checkbox coding is: //Check checkboxes foreach($_POST['check'] as $value) { $check_msg = "Checked: $value\n"; } I know I've submitted a lot of code here, and tried to narrow you down to the exact spot I think the problem is, but hopefully some of you PHP gurus can pick out the flaw in a heartbeat. I really appreciate all the help. B Hey guys,
Thank you in advance... here is my situation, I have a form with three (3) fields in it, the 'student name' is unlimited textfield with an "add more" button to it and I have two select fields ('number of shirts' and 'trophies') that depend on the number of entries for 'student name'...
I want to create the select fields based on this math, for as many 'student name' entries:
1- i want to have the select form for 'number of shirts' to be 0 up to that number... so if there are 6 'student name' entries, the select options will be 0,1,3,4,5,6,7
2- I want to have the select form for 'trophies' to be 5 'student name' entries to 1 'trophies', for example if there are 6 'student name' entries, the select options will be 0,1... if there are 13 entries, options will be 0,1,2... So if there are less than 5 'student name' entries, the select field will not show (hidden)
of course if there are no 'student name' entries, these two fields won't show up (hidden)
let me know if that make sense and ANY help or directions will be GREATLY APPRECIATED.
Thanks guys!
Okay, minor issue, but not sure how to resolve. I have a form that processes through PHP and has it's fields validated with JS and sends the data to an e-mail address and a database. It works fine, but there are random times where a submitted entry will show up blank in the e-mail and not be in the database at all, any ideas on what might be causing this? Thanks. this form i have takes some csv data and turns it into an array. For some reason the script inserts a blank key into the array and idk why. this is my script code: Code: [Select] <?php if(isset($_POST['csv_btn'])){ $csv = $_POST['csv']; //turns csv into an array with each spot in the array a player and all data seperated by a comma $csv_mod = explode("Home,",$csv); $y = count($csv_mod) - 1; $x = 0; $team = array(); while ($x <= $y){ //takes the array from the csv explode and explodes each player and their data $tx = $csv_mod[$x]; $ex_tx = explode(",",$tx); $ex_tx_c = count($ex_tx); $z = 1; //is the players name $person = $ex_tx[0]; $person2 = $ex_tx[0]; //turn the player into an array $person = array(); //puts the players data into their array while ($z < $ex_tx_c){ array_push($person, $ex_tx[$z]); $z++; } //adds the player to the team array with their name being the index $team[$person2] = $person; $x++; } print_r($team); } ?> this is what i put into the script(exactly like this): Code: [Select] Home,AJ,2,1,2,2,0,0,0,0,0,0,0,0 Home,Conner,0,0,2,2,0,0,0,0,0,0,0,0 Home,Joe,0,0,1,1,0,0,0,1,0,0,0,0 Home,Tyler,0,0,0,0,0,0,0,0,0,0,0,0 this is what it outputs: Code: [Select] Array ( [] => Array ( ) [AJ] => Array ( [0] => 2 [1] => 1 [2] => 2 [3] => 2 [4] => 0 [5] => 0 [6] => 0 [7] => 0 [8] => 0 [9] => 0 [10] => 0 [11] => 0 ) [Conner] => Array ( [0] => 0 [1] => 0 [2] => 2 [3] => 2 [4] => 0 [5] => 0 [6] => 0 [7] => 0 [8] => 0 [9] => 0 [10] => 0 [11] => 0 ) [Joe] => Array ( [0] => 0 [1] => 0 [2] => 1 [3] => 1 [4] => 0 [5] => 0 [6] => 0 [7] => 1 [8] => 0 [9] => 0 [10] => 0 [11] => 0 ) [Tyler] => Array ( [0] => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 [6] => 0 [7] => 0 [8] => 0 [9] => 0 [10] => 0 [11] => 0 ) ) How can I make this link have a target blank suited for a Strict doctype. if (strpos($row['personalweb'], 'http://') === false && strpos($row['personalweb'], 'https://') === false) { $row['personalweb'] = "http://${row['personalweb']}"; } It maybe related to my other post about outdated value
I got myself a server and now it's on Centos 5.11 with Apache 2.2.3, PHP 5.3.3, & MySQL 5.0.95
I put all database inside as well as the web files.
And just about the time when I think it's all done I tested and...things are just wrong...
2 web file folders were put to 2 sub directory of var/www/html
1 using mysql_connect and another mysqli_connect
The one using mysql_connect can connect just fine, however some list are blank, while the one using mysqli_connect totally can't connect to the database.
Then I cut a pieces of the connection part n put it alone to test the connection, but I get blank page
$con=mysqli_connect("localhost","username","password","dbname") or die("Error ".mysqli_error($con));Completely nothing but a blank page is the result of the code. I wish I can see error page so I can start with the wrong part, but here again...I'm clueless on what's going on [root@localhost ~]# yum list installed | grep mysql mysql.x86_64 5.0.95-5.el5_9 installed mysql-connector-odbc.x86_64 3.51.26r1127-2.el5 installed mysql-server.x86_64 5.0.95-5.el5_9 installed php53-mysql.x86_64 5.3.3-26.el5_11 installed [root@localhost ~]# php -m | grep mysql mysql mysqli pdo_mysql [root@localhost ~]#Anyone know the solution or this or had the same problem can shed a light into this ? Thanks in advance, my page: http://www.retroandvintage.co.uk/register.php my code Code: [Select] <?php error_reporting(E_ALL) ; ini_set('display_errors', 1) ; session_start(); include_once("config.php"); require_once('captcha/recaptchalib.php'); $ebits = ini_get('error_reporting'); error_reporting($ebits ^ E_NOTICE); /* Login script: This script does the following: Checks that the user is NOT already logged in - if they are they are redirected to the members page by the 'checkLoggedIn()' function. Checks if the login form has been submitted - if so, the 'login' and 'password' fields are checked to ensure they are of the correct format and length. If there are any problems here an error is added to the $messages array and then the script executes the 'doIndex()' function - this function basically outputs the main 'index' page for this script - ie the login form. If there are no problems with the previous step, the 'login' and 'password' field data is passed to the 'checkPass' function to check that an entry exists in the 'users' table for that login/password pair. If nothing is returned from the 'checkPass()' function, an error is added to the $messages array and the 'doIndex()' function is called as above. If a row of data is returned from the 'users' table, the data is passed to the 'cleanMemberSession()' function - which initializes session variables and logs the user in. The user is then forwarded to the members page. If the form hasn't yet been submitted, then the 'doIndex()' function is called and the login page is displayed. */ // Check user not logged in already: checkLoggedIn("no"); // Page title: $title="Member Login Page"; // if $submit variable set, login info submitted: if(isset($_POST["login"])) { // // Check fields were filled in // // login must be between 4 and 15 chars containing alphanumeric chars only: field_validator("rsUser", $_POST["rsUser"], "alphanumeric", 4, 15); // password must be between 4 and 15 chars - any characters can be used: field_validator("rsPass", $_POST["rsPass"], "string", 4, 15); // if there are $messages, errors were found in validating form data // show the index page (where the messages will be displayed): if($messages){ doIndex(); // note we have to explicity 'exit' from the script, otherwise // the lines below will be processed: exit; } // OK if we got this far the form field data was of the right format; // now check the user/pass pair match those stored in the db: /* If checkPass() is successful (ie the login and password are ok), then $row contains an array of data containing the login name and password of the user. If checkPass() is unsuccessful however, $row will simply contain the value 'false' - and so in that case an error message is stored in the $messages array which will be displayed to the user. */ if( !($row = checkPass($_POST["rsUser"], $_POST["rsPass"])) ) { // login/passwd string not correct, create an error message: $messages[]="Incorrect login/password, try again"; } /* If there are error $messages, errors were found in validating form data above. Call the 'doIndex()' function (which displays the login form) and exit. */ if($messages){ doIndex(); exit; } /* If we got to this point, there were no errors - start a session using the info returned from the db: */ cleanMemberSession($row["rsUser"], $row["rsPass"]); // and finally forward user to members page (populating the session id in the URL): header("Location: main.php"); } else { // The login form wasn't filled out yet, display the login form for the user to fill in: doIndex(); } function doIndex() { /* Import the global $messages array. If any errors were detected above, they will be stored in the $messages array: */ global $messages; /* also import the $title for the page - note you can normally just declare all globals on one line - ie: global $messages, $title; */ global $title; } // if $submit variable set, login info submitted: if(isset($_POST["register"])) { $privatekey = "6Ldhhr4SAAAAAKFoL2INOZV0_VuF6_z3OwDjVFNn"; $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { // What happens when the CAPTCHA was entered incorrectly die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." . "(reCAPTCHA said: " . $resp->error . ")"); } else { // Your code here to handle a successful verification $rsPostCode = $_POST['rsPostCode']; $rsGender = $_POST['rsGender']; $rsUser = $_POST['rsUser']; $rsPass = $_POST['rsPass']; $rsEmail = $_POST['rsEmail']; $rsMobile = $_POST['rsMobile']; $rsAge = $_POST['rsAge']; $to = 'john.mbiddulph@gmail.com'; //define the subject of the email $subject = 'New user added to My Pub Space'; // message $message = ' <html> <head> <title>'.$subject.'</title> </head> <body> <table> <tr> <td>Name:</td> <td>'.$rsUser.'</td> </tr> <tr> <td>Email:</td> <td>'.$rsEmail.'</td> </tr> <tr> <td>Telephone:</td> <td>'.$rsMobile.'</td> </tr> <tr> <td>Age:</td> <td>'.$rsAge.'</td> </tr> <tr> <td>Password:</td> <td>'.$rsPass.'</td> </tr> </table> </body> </html> '; // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Additional headers $headers .= 'To:' .$to. "\r\n"; $headers .= 'From:' .$rsEmail. "\r\n"; // Mail it mail($to, $subject, $message, $headers); $sql = "INSERT INTO members_copy (RSPOSTCODE, RSGENDER, RSUSER, RSPASS, RSEMAIL, RSMOBILE, RSAGE) VALUES ('$rsPostCode', '$rsGender', '$rsUser', '$rsPass', '$rsEmail', '$rsMobile', '$rsAge');"; //echo $sql; mysql_query($sql); // // Check fields were filled in // // login must be between 4 and 15 chars containing alphanumeric chars only: field_validator("rsUser", $_POST["rsUser"], "alphanumeric", 4, 15); // password must be between 4 and 15 chars - any characters can be used: field_validator("rsPass", $_POST["rsPass"], "string", 4, 15); // if there are $messages, errors were found in validating form data // show the index page (where the messages will be displayed): if($messages){ doIndex(); // note we have to explicity 'exit' from the script, otherwise // the lines below will be processed: exit; } // OK if we got this far the form field data was of the right format; // now check the user/pass pair match those stored in the db: /* If checkPass() is successful (ie the login and password are ok), then $row contains an array of data containing the login name and password of the user. If checkPass() is unsuccessful however, $row will simply contain the value 'false' - and so in that case an error message is stored in the $messages array which will be displayed to the user. */ if( !($row = checkPass($_POST["rsUser"], $_POST["rsPass"])) ) { // login/passwd string not correct, create an error message: $messages[]="Incorrect login/password, try again"; } /* If there are error $messages, errors were found in validating form data above. Call the 'doIndex()' function (which displays the login form) and exit. */ if($messages){ doIndex(); exit; } /* If we got to this point, there were no errors - start a session using the info returned from the db: */ cleanMemberSession($row["rsUser"], $row["rsPass"]); // and finally forward user to members page (populating the session id in the URL): header("Location: main.php"); } /* This function displays the default 'index' page for this script. This consists of just a simple login form for the user to submit their username and password. */ function doIndex() { /* Import the global $messages array. If any errors were detected above, they will be stored in the $messages array: */ global $messages; /* also import the $title for the page - note you can normally just declare all globals on one line - ie: global $messages, $title; */ global $title; } // drop out of PHP mode to display the plain HTML: $query1 = "SELECT * FROM outcodepostcodes"; $result = mysql_query($query1); ?> <!doctype html> <html> <head> <title>List of Pubs and Bars in the UK</title> <meta name="description" content="Pubs and bars in the UK, nightlife for food and drink" /> <meta name="keywords" content="Pubs, bars, List, uk, nightlife, drinking, drinks, beer, lager, food" /> <meta name="Content-Language" content="en-gb" /> <meta name="robots" content="FOLLOW,INDEX" /> <meta name="revisit-after" content="2 days" /> <meta name="copyright" content="jbiddulph.com" /> <meta name="author" content="John Biddulph - Professional web site design and development in the south of england mainly worthing and brighton" /> <meta name="distribution" content="Global" /> <meta name="resource-type" content="document" /> <link rel="stylesheet" type="text/css" href="css/reset.css" /> <link rel="stylesheet" type="text/css" href="css/style.css" title="default" /> <link rel="alternate stylesheet" type="text/css" href="css/style1.css" title="1" /> <link rel="alternate stylesheet" type="text/css" href="css/style2.css" title="2" /> <script type="text/javascript" src="js/stylechanger.js"></script> <script type="text/javascript" src="js/jquery-1.2.1.pack.js"></script> <script src="SpryAssets/SpryValidationSelect.js" type="text/javascript"></script> <script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script> <script type="text/javascript"> function lookup(inputString) { if(inputString.length == 0) { // Hide the suggestion box. $('#suggestions').hide(); } else { $.post("rpc.php", {queryString: ""+inputString+""}, function(data){ if(data.length >0) { $('#suggestions').show(); $('#autoSuggestionsList').html(data); } }); } } // lookup function fill(thisValue) { $('#inputString').val(thisValue); setTimeout("$('#suggestions').hide();", 200); } </script> <script type="text/javascript"> var RecaptchaOptions = { theme : 'white' }; </script> <link href="SpryAssets/SpryValidationSelect.css" rel="stylesheet" type="text/css"> <link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css"> </head> <body> <?php if($messages) { displayErrors($messages); }?> <header> <div id="title"> <h1>My Pub Space <a href="#" onClick="setActiveStyleSheet('default'); return false;"><img src="images/0.gif" width="15" height="15" border="0" alt="css style" /></a> <a href="#" onClick="setActiveStyleSheet('1'); return false;"><img src="images/1.gif" width="15" height="15" border="0" alt="css style" /></a> <a href="#" onClick="setActiveStyleSheet('2'); return false;"><img src="images/2.gif" width="15" height="15" border="0" alt="css style" /></a> <span> <form method="post" class="textbox" action="search.php"> Town/City: <input type="text" size="26" class="searchbox" value="" name="rsTown" id="inputString" onKeyUp="lookup(this.value);" onBlur="fill();" /> <div class="suggestionsBox" id="suggestions" style="display: none;"> <img src="images/upArrow.png" style="position: relative; top: -36px; left: 105px; z-index:1;" alt="upArrow" /> <div class="suggestionList" id="autoSuggestionsList"> </div> </div> <input type="image" src="images/go.png" height="30" with="30" value="GO" /> </form> </span> </h1> </div> </header> <nav> <ul> <li><a href="default.php">Home</a></li> <li><a href="#">Pubs</a></li> <li><a href="#">Members</a></li> <li><a href="#">Events</a></li> <li class="selected"><a href="#">Register</a></li> </ul> </nav> <section id="intro"> <header> <h2>Your social guide to going down the pub, online!</h2> </header> <p>Stuck in town with nowhere to go? Not sure if up the road or down the street is best? Need to be somewhere warm, cosy and friendly. Need a drink?....<br />You've come to the right place, mypubspace has it all!</p> <img src="images/pub.jpg" alt="pub" /> </section> <div id="content"> <div id="mainContent"> <section> <article class="blogPost"> <header> <h2>Register to My Pub Space</h2> <form name="register" method="post" action=""> <input name="LoginCount" type="hidden" value="1" /><input name="LastLogin" type="hidden" value="<%= Now()%>" /> <table width="100%"> <tr> <td class="text">Post Code</td> <td><span id="spryselect1"> <select name="rsPostCode" class="postcodedrop"> <?PHP while($row = mysql_fetch_array($result)) { echo '<option name=\"menuarea\" class=\"postcodedrop\" value='.$row['outcode'].' />'; echo $row['outcode']; }?> </select> <span class="selectRequiredMsg">Please select an item.</span></span><i>Helps us find your local pubs!</i></td> </tr> <tr> <td class="text">Gender:</td> <td>Male <input name="rsGender" type="radio" value="Male" /> Female <input name="rsGender" type="radio" value="Female" /></td> </tr> <tr> <td class="text">User Name:</td> <td><span id="sprytextfield1"> <input name="rsUser" type="text" class="textbox" id="rsUser" /> <span class="textfieldRequiredMsg">A value is required.</span></span></td> </tr> <tr> <td class="text">Password:</td> <td><span id="sprytextfield2"> <input name="rsPass" type="password" class="textbox" id="rsPass" /> <span class="textfieldRequiredMsg">A value is required.</span></span></td> </tr> <tr> <td class="text">Confirm Password:</td> <td><span id="sprytextfield3"> <input name="rsPass2" type="password" class="textbox" id="rsPass2" /> <span class="textfieldRequiredMsg">A value is required.</span></span></td> </tr> <tr> <td class="text">Email:</td> <td><span id="sprytextfield4"> <input name="rsEmail" type="text" class="textbox" id="rsEmail" /> <span class="textfieldRequiredMsg">A value is required.</span></span></td> </tr> <tr> <td class="text">Mobile:</td> <td><span id="sprytextfield5"> <input name="rsMobile" type="text" class="textbox" id="rsMobile" /> <span class="textfieldRequiredMsg">A value is required.</span></span></td> </tr> <tr> <td class="text">Age:</td> <td><span id="sprytextfield6"> <input name="rsAge" type="text" class="textbox" id="rsAge" /> <i>dd/mm/yyyy</i> <span class="textfieldRequiredMsg">A value is required.</span></span></td> </tr> <tr> <td> </td> <td><?php require_once('captcha/recaptchalib.php'); $publickey = "6Ldhhr4SAAAAACAnyp4o6NDHjZvRlS6rnHNa-Enz"; // you got this from the signup page echo recaptcha_get_html($publickey); ?></td> </tr> <tr> <td> </td> <td><input name="register" type="submit" class="button" value="Register" /></td> </tr> </table> </form> </header> </article> </section> </div> <aside> <section> <header> <h3>Members Login Area</h3> </header> <form method="post" class="textbox" action="<?php print $_SERVER["PHP_SELF"]; ?>"> Username: <br /> <input type="text" class="textbox" name="rsUser" value="<?php print isset($_POST["rsUser"]) ? $_POST["rsUser"] : "" ; ?>"> Password: <br /> <input type="password" class="textbox" name="rsPass"> <br /> <br /> <input name="login" type="submit" value="Login"> <br /> </form> <ul> <li><a href="#">Sign up</a></li> <li><a href="#">Forgot Password</a></li> </ul> </section> <section> <header> <h3>Archives</h3> </header> <ul> <li><a href="#">December 2008</a></li> <li><a href="#">January 2009</a></li> <li><a href="#">February 2009</a></li> <li><a href="#">March 2009</a></li> <li><a href="#">April 2009</a></li> <li><a href="#">May 2009</a></li> <li><a href="#">June 2009</a></li> </ul> </section> </aside> </div> <footer> <div> <section id="about"> <header> <h3>About</h3> </header> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco <a href="#">laboris nisi ut aliquip</a> ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> </section> <section id="blogroll"> <header> <h3>Blogroll</h3> </header> <ul> <li><a href="#">NETTUTS+</a></li> <li><a href="#">FreelanceSwitch</a></li> <li><a href="#">In The Woods</a></li> <li><a href="#">Netsetter</a></li> <li><a href="#">PSDTUTS+</a></li> </ul> </section> <section id="popular"> <header> <h3>Popular</h3> </header> <ul> <li><a href="#">This is the title of a blog post</a></li> <li><a href="#">Lorem ipsum dolor sit amet</a></li> <li><a href="#">Consectetur adipisicing elit, sed do eiusmod</a></li> <li><a href="#">Duis aute irure dolor</a></li> <li><a href="#">Excepteur sint occaecat cupidatat</a></li> <li><a href="#">Reprehenderit in voluptate velit</a></li> <li><a href="#">Officia deserunt mollit anim id est laborum</a></li> <li><a href="#">Lorem ipsum dolor sit amet</a></li> </ul> </section> </div> </footer> <script type="text/javascript"> <!-- var spryselect1 = new Spry.Widget.ValidationSelect("spryselect1"); var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1"); var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2"); var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3"); var sprytextfield4 = new Spry.Widget.ValidationTextField("sprytextfield4"); var sprytextfield5 = new Spry.Widget.ValidationTextField("sprytextfield5"); var sprytextfield6 = new Spry.Widget.ValidationTextField("sprytextfield6"); //--> </script> </body> </html> <?php } ?> Hello (I am posting to php because I don't know what is giving the problem), Let's say I have these links into my <div id="header>: Home Items Faq Cart and I use a Jquery to open my links inside my <div id="content"> The problem is between Items and Cart links (I am testing in ie9 and firefox 4): I am using an ajax code (I don't know if the problem is in here) to add items to cart and stay at my items page (not sending me to the cart page). Now, when I first load the page or is refreshed, everything works fine. BUT after I add something to the Cart if I visit the Cart.php and then return to my Items.php, when I click on the next item to be added I get a Blank page. Note: the Item is added normaly. This is happening also, when I click the UPDATE button inside my cart php to update quantities. Any suggestion? Thank you. (I don't know if is ajax, php, jquery or all three of them) elloo, i have php script that works fine on a dev server however on staging server it is a blank page. i have set 'error_reporting(E_ALL) ' and ini_set('dsiplay_errors', 1) however only information i get is some notices and no fatal errors. i'm aware that php stops executing if there is a fatal error (and appears as blank screen), is there some sort of directive in 'php.ini' which stop php from executing when there are notices. thanks in advanced |