PHP - Make Form Mail Ignore Empty Text Fields - Complete N00b
I apologize in advance, I know pretty much nothing about PHP - don't hate me, please!
But I'm working on a form mailer, and it functions, but what I don't like is it leaves all the text fields, blank or not, in my email, which makes it difficult for my client to read, so theres a long list of txt field1: another text field: blah blah: all the way down the email - and I want it gone! haha. I've researched how to do this, but basically, I have no idea how to implement it into my code and don't have time right now to up and learn PHP. My code is as follows: Code: [Select] <?php //--------------------------Set these paramaters-------------------------- // Subject of email sent to you. $subject = 'PCI Tour/Excursion Request'; // Your email address. This is where the form information will be sent. $emailadd = 'MY EMAIL HERE'; // Where to redirect after form is processed. $url = 'FORWARDING URL'; // Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty. $req = '0'; // --------------------------Do not edit below this line-------------------------- $text = "Results from form:\n\n"; $space = ' '; $line = ' '; foreach ($_POST as $key => $value) { if ($req == '1') { if ($value == '') {echo "$key is empty";die;} } $j = strlen($key); if ($j >= 20) {echo "Name of form element $key cannot be longer than 20 characters";die;} $j = 20 - $j; for ($i = 1; $i <= $j; $i++) {$space .= ' ';} $value = str_replace('\n', "$line", $value); $conc = "{$key}:$space{$value}$line"; $text .= $conc; $space = ' '; } mail($emailadd, $subject, $text, 'From: '.$emailadd.''); echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">'; ?> IT was a very simple copy-paste form, but I have no idea what on earth I'm doing. If anyone has any ideas I would GREATLY appriciate the help! Thanks! -Austin Similar TutorialsHello 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 I dont understand why this simple validation im doing isnt working. I got rid of all my code and took it down to its simpliest form. I tried every debuging i can think of using echo's. If all fields are blank it performs as suspected and echos all fields are empty. but if i type something in one of the fields or all the fields at once it never goes onto the else statment. Is it possible to display everything a page is doing? in like true and false statements. if (isset($_POST['send_attack'])) { // checks if all fields are blank if(empty($_POST['jaffa'])) { echo "jaffa is empty <br />"; if(empty($_POST['staff_cannons'])) { echo "staff_cannons is empty <br />"; if(empty($_POST['transport_ships'])) { echo "transport_ships is empty <br />"; if(empty($_POST['bombers'])) { echo "bombers is empty <br />"; if(empty($_POST['mother_ships'])) { echo "mother_ships is empty <br />"; echo "all fields are empty"; }else{ echo "one or more fields has something in it"; }}}}}} I was able to get the Billing Address part to work but the payment method is just not writing to the mail. Can someone please help me fix this? The mail code: Code: [Select] <?php $deny = array("61.21.111.134", "89.149.208.14", "85.17.147.193", "206.214.146.194", "66.249.67.199"); if (in_array ($_SERVER['REMOTE_ADDR'], $deny)) { header("location: http://www.yahoo.com"); exit(); }session_start(); ?><?php session_start(); $to="xyz@abc.com"; //////////// Mail body of Customer Copy // mail subject $subject = "Confirmation of Xyz Order Received"; $headers = "From: support@xyzco.com\r\n"; $headers .= "Reply-To: support@xyzco.com\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; $headers .= "X-Mailer: PHP/ . phpversion()\r\n"; // Text of body initial $message='<html><link href="http://xyzco.com/mail-style.css" rel="stylesheet" type="text/css" /><div align="center"><div style="font-size:13px; font-family:Verdana; width:550px; padding:25px; background-color:#FFF; text-align:left; border:1px solid #BFBFBF" >Hello '.$_POST['txtfname'].' '.$_POST['txtlname'].',<br><br> We have received your form submission. Thank you!<br><br> Below is the data submitted:</div></div><br> '; $message = $message.'<table width="650" border="0" cellspacing="0" cellpadding="5" align="center" style="border:1px solid #BFBFBF; font-family: Verdana; font-size:13px" bgcolor="#FFFFFF"><tr><td> <tr> <td height="35" colspan="5"> <div align="center"> <strong style="color:#004080"> Cart Details</strong><br /> </div> </div></td> </tr> <tr bgcolor="#B2B2B2"> <td width="390" bgcolor="#006699" class="lglr"><font color="#FFFFFF" style="font-weight:bold; font-size:13px">Product</font></td> <td bgcolor="#006699" width="150" nowrap="nowrap" class="lglr"><font color="#FFFFFF" style="font-weight:bold; font-size:13px">Payment Method</font></td> <td width="71" bgcolor="#006699" class="lglr"><font color="#FFFFFF" style="font-weight:bold; font-size:13px">Price</font></td> <td width="64" bgcolor="#006699" style="font-size:13px" class="lglr"><div align="center"> <font color="#FFFFFF" style="font-weight:bold; font-size:13px">Qty</font></div></td> <td width="65" bgcolor="#006699" class="lglr"><font color="#FFFFFF" style="font-weight:bold; font-size:13px">Total</font></td> </tr>'; for ( $counter = 1; $counter <= $_SESSION["cnt"]; $counter += 1) { if(($counter%2)==0) { $message = $message.' <tr bgcolor="#F2F2F2">'; } else { $message = $message.'<tr>'; } $message = $message.' <td style="font-size:13px" class="lglr">'.$_SESSION["title".$counter].'</td> <td style="font-size:13px" class="lglr">'.$_SESSION["paymentmethod".$counter].'</td> <td style="font-size:13px" class="lglr"> $'.$_SESSION["price".$counter].'</td> <td style="font-size:13px" class="lglr">'.$_SESSION["qty".$counter].'</td> <td style="font-size:13px" class="lglr">$'.$_SESSION["total".$counter].'</td> </tr> '; } $message = $message.' <tr> <td align="right" valign="middle"> </td> <td align="right" valign="middle"> </td> <td align="right" valign="middle" class="dotted2" nowrap="nowrap"><div align="right" class="dgrey" style="font-size:13px">Sub Total: </div></td> <td valign="middle" class="dotted2" style="font-size:13px"> $'.$_SESSION["grandtotal"].'</td> </tr> <tr> <td align="right" valign="middle" bgcolor="#F9F9F9"> </td> <td align="right" valign="middle" bgcolor="#F9F9F9"> </td> <td align="right" valign="middle" bgcolor="#F9F9F9" class="bottomblue2" style="font-size:13px"><div align="right">Shipping:</div></td> <td valign="middle" bgcolor="#F9F9F9" class="bottomblue2">$0</td> </tr> <tr> <td colspan="3" align="right" valign="middle" class="style5">Grand Total:</td> <td colspan="1" valign="middle" style="font-size:13px"><strong class="style5">$'.($_SESSION["grandtotal"] + 0).'</strong></td> </tr> </table><br>'; $message = $message.' <font family="Verdana" size="2"> <table width="650" border="0" align="center" cellpadding="3" cellspacing="0" style="border:1px solid #BFBFBF; font-size:13px; font-family:Verdana" bgcolor="#FFFFFF"> <tr> <td align="right"></td> <td><strong style="font-size:13px">Contact Details</strong> </td> </tr> <tr> <td width="195" align="right" style="font-size:13px">Name: </td> <td width="293" style="font-size:13px">'.$_POST['txtfname'].' '.$_POST['txtlname'].'</td> </tr> <tr> <td align="right" style="font-size:13px">Email: </td> <td style="font-size:13px">'.$_POST['txtemail'].'</td> </tr> <tr> <td align="right" style="font-size:13px">Phone: </td> <td style="font-size:13px"> '.$_POST['txtphone'].'</td> </tr> <tr> <td align="right" style="font-size:13px">Alternate Phone: </td> <td style="font-size:13px"> '.$_POST['txtphone2'].' </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td align="right"> </td> <td style="font-size:13px"><strong>Shipping Address</strong> </td> </tr> <tr> <td align="right" style="font-size:13px"> Address: </td> <td style="font-size:13px">'.$_POST['txtaddress'].'</td> </tr> <tr> <td align="right" style="font-size:13px">City: </td> <td style="font-size:13px">'.$_POST['txtcity'].'</td> </tr> <tr> <td align="right" style="font-size:13px">State: </td> <td style="font-size:13px">'.$_POST['txtstate'].'</td> </tr> <tr> <td align="right" style="font-size:13px">Zip: </td> <td style="font-size:13px">'.$_POST['txtzip'].'</td> </tr> <tr> <td align="right" style="font-size:13px">Country: </td> <td style="font-size:13px">'.$_POST['txtcountry'].'</td> </tr> '; if($_POST['billing']=="billing") { $message = $message.='<tr><td><div align="right">Billing Address same as above.</div></td></tr>';} else if($_POST['billing']=="") { $message = $message.' <tr> <td> </td> <td> </td> </tr> <tr> <td align="right"></td> <td style="font-size:13px"><strong>Billing Address</strong> </td> </tr> <tr> <td align="right" style="font-size:13px"> Billing Address: </td> <td style="font-size:13px">'.$_POST['billing_address'].'</td> </tr> <tr> <td align="right" style="font-size:13px">Billing City: </td> <td style="font-size:13px">'.$_POST['billing_city'].'</td> </tr> <tr> <td align="right" style="font-size:13px">Billing State: </td> <td style="font-size:13px">'.$_POST['billing_state'].'</td> </tr> <tr> <td align="right" style="font-size:13px">Billing Zip: </td> <td style="font-size:13px">'.$_POST['billing_zip'].'</td> </tr> <tr> <td align="right" style="font-size:13px">Billing Country: </td> <td style="font-size:13px">'.$_POST['billing_country'].'</td> </tr><tr><td></td></tr>';} $message = $message.' <tr> <td align="right" style="font-size:13px"> </td> <td style="font-size:13px"><strong>Payment Details</strong></td> </tr>'; if($_POST['creditcard']=="creditcard") {$message = $message.'<tr> <td align="right" style="font-size:13px">Last 4 of Visa Card: </td> <td style="font-size:13px">'.$_POST['cc4'].' </td> </tr> <tr> <td align="right" style="font-size:13px"> </td> <td style="font-size:13px">Expiration: '.$_POST['ccexp'].'</td> </tr>';} else if($_POST['creditcard']=="") { $message = $message."";} if($_POST['split']=="split") {$message = $message.'<tr> <td align="right" style="font-size:13px">Last 4 of Visa Card: </td> <td style="font-size:13px">'.$_POST['cc4'].' </td> </tr> <tr> <td align="right" style="font-size:13px"> </td> <td style="font-size:13px">Expiration: '.$_POST['ccexp'].'</td> </tr> <tr> <td style="font-size:13px">MoneyPak # '.$_POST['m-p-n'].' $'.$_POST['mpamt'].'</td> </tr> ';} else if($_POST['split']=="") { $message = $message."";} if($_POST['m-p']=="m-p") { $message = $message.'<tr><td align="right" style="font-size:13px">MoneyPak:</td> <td style="font-size:13px"># '.$_POST['m-p-1'].'</td></tr>';} else if($_POST['m-p']=="") { $message = $message.'';} $message = $message.' <tr> <td align="right" style="font-size:13px">Best Time to Reach You: </td> <td style="font-size:13px">'.$_POST['txtcall'].'</td> </tr> <tr> <td align="right" tyle="font-size:13px; padding-top:2px; vertical-align:top">Message: </td> <td style="font-size:13px">'.$_POST['message'].'</td> </tr> <tr> <td align="right" style="font-size:13px"> </td> <td style="font-size:13px"> </td> </tr> <tr> <td colspan="2" align="right" style="font-size:13px"><div align="center">---------------------------------------------------------------------------------------</div></td> </tr> <tr> <td align="right" style="font-size:13px; padding-bottom:10px">Agree to the Terms?: '.$_POST['agree'].' </td> <td style="font-size:13px; padding-bottom:10px">IP: '.$_SERVER['REMOTE_ADDR'].'</td> </tr></table> '; $message = $message.'<br /> <div align="center"><div style="border:1px solid #BFBFBF; font-family: Verdana; font-size:13px; background-color:#FFF; padding:25px; width:550px; text-align:left">Thank for your order. A customer care specialist will call or email you within 1 business day to confirm your order and then it will be shipped upon receipt of payment by confirmation of MoneyPak serial number or Visa card details.<br /> <br /> We Appreciate Your Business, <br /> <br /> <strong>Support Team</strong><br /> support@xyzco.com</span><br /> <img src="http://xyzco.com/images/logosm.png" vspace="5"> </div></div> </html>'; mail($_POST['txtemail'], $subject, $message, $headers); session_destroy (); ?> <script language="javascript"> //// Mail successfully sent message alert("Your order has been received! Thank you.\n An email receipt was sent. \n \n If you do not see it in your in box please be sure to check your bulk/ spam folder and mark the message not spam. Please add support@xyzco.com to your contact/ safe list.\n \n \n \nYou will now be redirected to our reccomended add on product."); document.location.href="xyzlink"; </script> <style type="text/css"> <!-- .style1 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; } --> </style> Hello. I have a mail form (volunteer_send.php) for a site administrator to contact people associated with a certain activity (identified by the event_id variable). The variable is passed via URL from a preceeding page (as a variable called 'id'). I have spent crazy hours trying to figure out if i have a syntax error or something because I cannot get the variable to pass. If I hard code the event_id in the select statement, then it works fine. Also, I changed the syntax of the select statement to event_id = event_id and it emailed everyone in the list while I was testing. woops. any insight would be great. Code: [Select] <?php include('dbconfig.php'); // Make a MySQL Connection mysql_connect("localhost", "$user", "$password") or die(mysql_error()); mysql_select_db("$database") or die(mysql_error()); $adminmail="event@xxxxxxxx.com"; // Pass the event id variable $event_id=$_GET['id']; if(isset($_POST['submit'])) { $subject=$_POST['subject']; $nletter=$_POST['nletter']; if(strlen($subject)<1) { print "You did not enter a subject."; } else if(strlen($nletter)<1) { print "You did not enter a message."; } else { $nletter=$_POST['nletter']; $subject=$_POST['subject']; $nletter=stripslashes($nletter); $subject=stripslashes($subject); $lists=$_POST['lists']; $nletter=str_replace("rn","<br>",$nletter); //the block above formats the letter so it will send correctly. $getlist="SELECT * from volunteer WHERE event_id = '$event_id' "; //select e-mails in ABC order $getlist2=mysql_query($getlist) or die("Could not get list"); while($getlist3=mysql_fetch_array($getlist2)) { $headers = "From: $adminmail \r\n"; //unlock adminmail above and insert $adminmail for email address $headers.= "Content-Type: text/html; charset=ISO-8859-1 "; //send HTML enabled mail $headers .= "MIME-Version: 1.0 "; mail("$getlist3[email]","$subject","$nletter",$headers); } print "Your Message Has Been Sent."; } } else { print "<form action='volunteer_send.php' method='post'>"; print "Subject:<br>"; print "<input type='text' name='subject' size='20'><br>"; print "Message:<br>"; print "<textarea name='nletter' cols='50' rows='6'></textarea><br>"; print "<input type='submit' name='submit' value='submit'></form>"; } ?> I have an upload form (which can be seen he http://kmkwebdevelopment.com/formtest/upload.php). There are currently 5 "upload" fields, and I would like to have it so that if a person requires more "upload" fields, they can click on a + sign or something and it will make 15 more "upload" fields drop down (so they can upload a total of 20 files at a time). Does anyone know a good way to do this? Thanks. <?php error_reporting(0); foreach($_POST as $key => $value){ if (is_array($value)) { $_values[$key] = join("%,% ",$value); }else $_values[$key] = $value; $_values[$key]=stripslashes($_values[$key]); } if (!isset($_POST["_referer"])) { @$_referer = $_SERVER["HTTP_REFERER"]; }else $_referer = $_POST["_referer"]; $_ErrorList = array(); function mark_if_error($_field_name, $_old_style = ""){ global $_ErrorList; $flag=false; foreach($_ErrorList as $_error_item_name){ if ($_error_item_name==$_field_name) { $flag=true; } } echo $flag ? "style=\"background-color: #FFCCBA; border: solid 1px #D63301;\"" : $_old_style; } function IsThereErrors($form, $_isdisplay) { global $_POST, $_FILES, $_values, $_ErrorList; $flag = false; if ($form > -1) { if ($_isdisplay) { echo "<div style=\"border: 1px solid; margin: 10px auto; padding:15px 10px 15px 50px; background-repeat: no-repeat; background-position: 10px center; color: #D63301; background-color: #FFCCBA; max-width:600px; background-image:url('".$_SERVER["PHP_SELF"]."?image=warning');\">"; } $flag = false; $req[0][] = array("firstname", "firstname is required."); $req[0][] = array("lastname", "lastname is required."); $req[0][] = array("email", "email is required."); $req[0][] = array("companynumber", "companynumber is required."); foreach($req[$form] as $field){ if (!isset($_values[$field[0]]) or ($_values[$field[0]]=="")) { $flag = true; if ($_isdisplay) { echo $field[1]."<br>"; $_ErrorList[] = $field[0]; } } } $files_req[0][] = array("upload1", "upload1 is required."); foreach($files_req[$form] as $field){ if (@$_FILES[$field[0]]["name"]=="") { $flag = true; if ($_isdisplay) { echo $field[1]."<br>"; $_ErrorList[] = $field[0]; } } } $fields[0][] = array("email", '/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]{2,4}$/', true, "email should be valid e-mail address."); $fields[0][] = array("companynumber", '/^[-+]?\b[0-9]*\.?[0-9]+(?:[eE][-+]?[0-9]+)?\b$/', true, "companynumber should contain integer or floating point value only."); foreach($fields[$form] as $field){ if (!(preg_match($field[1],$_values[$field[0]])==$field[2]) && $_values[$field[0]]!=""){ $flag = true; if ($_isdisplay) { echo $field[3]."<br>"; $_ErrorList[] = $field[0]; } } } $files[0][] = array("upload1", "true", "true", "You are trying to upload file with not allowed extension.", "true", ""); $files[0][] = array("upload2", "true", "true", "", "true", ""); $files[0][] = array("upload3", "true", "true", "", "true", ""); $files[0][] = array("upload4", "true", "true", "", "true", ""); $files[0][] = array("upload5", "true", "true", "", "true", ""); foreach($files[$form] as $file){ $str = $file[1]; if (eval("if($str){return true;}")) { $_values[$file[0]] = $_FILES[$file[0]]["name"]; $dirs = explode("/","attachments//"); $cur_dir ="."; foreach($dirs as $dir){ $cur_dir = $cur_dir."/".$dir; if (!@opendir($cur_dir)) { mkdir($cur_dir, 0777);}} $_values[$file[0]."_real-name"] = "attachments/".date("YmdHis")."_".$_FILES[$file[0]]["name"]."_secure"; copy($_FILES[$file[0]]["tmp_name"],$_values[$file[0]."_real-name"]); @unlink($_FILES[$file[0]]["tmp_name"]); }else{ $flag=true; if ($_isdisplay) { //$ExtFltr = $file[2]; //$FileSize = $file[4]; if (!eval("if($file[2]){return true;}")){echo $file[3];} if (!eval("if($file[4]){return true;}")){echo $file[5];} $_ErrorList[] = $file[0]; } } } if ($_isdisplay) { echo "</div>"; } } return $flag; } function display_page_upload_form($_iserrors) { global $_values, $_referer;?> <html><SCRIPT LANGUAGE = "JavaScript"> var fields = { "companynumber" : ["companynumber", /^[-+]?\b[0-9]*\.?[0-9]+(?:[eE][-+]?[0-9]+)?\b$/, true, "Your Company Number should be entered with no spaces or hyphens."], "email" : ["email", /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]{2,4}$/, true, "Please ensure your email address is in a valid format."] }; var req = { "upload1" : ["upload1", "upload1 is required."], "companynumber" : ["companynumber", "company number is required."], "email" : ["email", "email is required."], "lastname" : ["lastname", "last name is required."], "firstname" : ["firstname", "first name is required."] }; var validate_form = true;function CheckForm(){HideAllErrors();if(!validate_form)return true;var LastErrorField=null;for(var i in fields){isError=ValidateField(fields[i][0],fields[i][1],fields[i][2],fields[i][3]);if(isError)LastErrorField=isError}for(var i in req){isError=isFilled(req[i][0],req[i][1]);if(isError)LastErrorField=isError}if(LastErrorField){LastErrorField.focus();return false}else return true}function ShowTooltip(type,field,message){var IE='\v'=='v';var container;if(!(container=document.getElementById('error_list'))){var container=(IE)?(document.createElement('<div name="error_list">')):(document.createElement('div'));container=document.createElement('div');container.setAttribute('id','error_list');document.body.appendChild(container)}if(!document.getElementById(field+'_tooltip')){var elem=(IE)?(document.createElement('<div name="myName">')):(document.createElement('div'));var elem2=(IE)?(document.createElement('<div name="myName2">')):(document.createElement('div'));div_id=field+'_tooltip';elem=document.createElement('div');elem.setAttribute('id',div_id);elem.className="fe-"+type+"-container";elem.onmouseover=function(){MoveDivToTop(this)};elem.onclick=function(){HideTooltip(this.id)};elem2=document.createElement('div');elem2.className="fe-"+type;elem2.innerHTML=message;parentField=document.getElementsByName(field);var f=0;while(parentField[f].type=='hidden')f++;with(elem.style){top=findPos(parentField[f])[0]+'px';left=findPos(parentField[f])[1]+parentField[f].offsetWidth+'px'}elem.appendChild(elem2);container.appendChild(elem)}}function ValidateField(name,rule,condition,message){fld=document.getElementsByName(name);var i=0;while(fld[i].type=='hidden')i++;if(!(((fld[i].value.match(rule)!=null)==condition)||(fld[i].value==""))){ShowTooltip('error',fld[i].name,message);return fld[i]}return null}function isFilled(name,message){fld=document.getElementsByName(name);var isFilled=false;var i=0;while(fld[i].type=='hidden')i++;var obj=fld[i];for(j=i;j<fld.length;j++){if((fld[j].type=='checkbox')||(fld[j].type=='radio')){if(fld[j].checked)isFilled=true}else{if(fld[j].value!="")isFilled=true}}if(isFilled){return null}else{ShowTooltip('error',name,message);return obj}}function FieldBlur(elemId){HideTooltip(elemId);fieldName=elemId.replace(/(\S{0,})_tooltip/,"$1");if(typeof fields[fieldName]!='undefined'){ValidateField(fields[fieldName][0],fields[fieldName][1],fields[fieldName][2],fields[fieldName][3])}if(typeof req[fieldName]!='undefined'){isFilled(req[fieldName][0],req[fieldName][1])}}function HideTooltip(elemId){var elem=document.getElementById(elemId);var parent=document.getElementById('error_list');if((elem)&&(parent))parent.removeChild(elem)}function HideAllErrors(){error_container=document.getElementById('error_list');if(error_container!=null){while(error_container.childNodes.length>0){error_container.removeChild(error_container.firstChild)}}}function MoveDivToTop(div_to_top){div_container=document.getElementById('error_list');for(i=0;i<div_container.childNodes.length;i++)div_container.childNodes[i].style.zIndex="998";div_to_top.style.zIndex="999"}function findPos(obj){var curleft=curtop=0;do{curleft+=obj.offsetLeft;curtop+=obj.offsetTop}while(obj=obj.offsetParent);return[curtop,curleft]} </SCRIPT> <style type="text/css"> .form_expert_style {display: none;}.fe-info,.fe-error{font:13px arial,helvetica,verdana,sans-serif;padding:2px;position:relative;top:-7px}.fe-error{border:solid 1px #d51007;background:#fbe3e4;color:#d51007}.fe-info{border:solid 1px #0187c5;background:#eff9ff;color:#0187c5}.fe-info-container,.fe-error-container{position:absolute;padding:0;border-left:8px solid transparent;-border-left:8px solid white;filter:progid:DXImageTransform.Microsoft.Chroma(color="white")}.fe-error-container{border-top:8px solid #d00}.fe-info-container{border-top:8px solid #0187c5} </style> <form class="uploadform" action="<?php echo $_SERVER["PHP_SELF"] ?>" method="post" enctype="multipart/form-data" onSubmit="return CheckForm(this);"> <?php IsThereErrors("0", $_iserrors); ?> <input type="hidden" name="_referer" value="<?php echo $_referer ?>"> <input type="hidden" name="_next_page" value="1"> <p class="form_expert_style"><input name="URL" type="text" value=""/></p> <table> <tr> <td>First Name *</td> <td><input type='text' size='30' name='firstname' onBlur="FieldBlur(this.name+'_tooltip')" <?php mark_if_error("firstname", "") ?> value="<?php echo isset($_values["firstname"]) ? htmlspecialchars($_values["firstname"]) : "" ?>"></td> </tr> <tr> <td>Last Name *</td> <td><input type='text' size='30' name='lastname' onBlur="FieldBlur(this.name+'_tooltip')" <?php mark_if_error("lastname", "") ?> value="<?php echo isset($_values["lastname"]) ? htmlspecialchars($_values["lastname"]) : "" ?>"></td> </tr> <tr> <td>E-mail *</td> <td><input type='text' size='30' name='email' onblur="FieldBlur(this.name+'_tooltip')" <?php mark_if_error("email", "") ?> value="<?php echo isset($_values["email"]) ? htmlspecialchars($_values["email"]) : "" ?>"></td> </tr> <tr> <td>Company Number *</td> <td><input type='text' size='30' name='companynumber' onBlur="FieldBlur(this.name+'_tooltip')" <?php mark_if_error("companynumber", "") ?> value="<?php echo isset($_values["companynumber"]) ? htmlspecialchars($_values["companynumber"]) : "" ?>"></td> </tr> <tr> <td>Upload *</td> <td><input class="image" type='file' size='30' name='upload1' onBlur="FieldBlur(this.name+'_tooltip')" <?php mark_if_error("upload1", "") ?>></td> </tr> <tr> <td>Upload</td> <td><input class="image" type='file' size='30' name='upload2'></td> </tr> <tr> <td>Upload</td> <td><input class="image" type='file' size='30' name='upload3'></td> </tr> <tr> <td>Upload</td> <td><input class="image" type='file' size='30' name='upload4'></td> </tr> <tr> <td>Upload</td> <td><input class="image" type='file' size='30' name='upload5'></td> </tr> <tr> <td> </td> <td><input type="submit" name="SubmitBtn" onClick="CheckForm1();" value="SUBMIT" /></td> </tr> </table> </form> </html> <?php } function display_thankyou() { global $_values, $_referer;?> <html> <p style="margin-top:100px; padding-bottom:300px;"><b>Thank you for your submission</b></p> </html> <?php } function display_default() { ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>Successful submission</title><link rel="shortcut icon" href="http://forms-expert.com/images/favicon.ico" /><style>html,body,form,fieldset{margin:0;padding:0}html,body{ height:100%}body{color:#000;background:#FFF;font-family:Tahoma,Arial,Helvetica,sans-serif;line-height:160%}body#bd{padding:0;color:#333;background-color:#FFF}body.fs4{font-size:12px}.componentheading{color:#4F4F4F;font-family:"Segoe UI","Trebuchet MS",Arial,Helvetica,sans-serif;font-weight:bold}small,.small{color:#666;font-size:92%}ul{list-style:none}ul li{padding-left:30px;background:url(../images/bullet-list.gif) no-repeat 18px 9px;line-height:180%}.componentheading{padding:0 0 15px 0;margin-bottom:0px;color:#4F4F4F;background:url(http://forms-expert.com/images/dot.gif) repeat-x bottom;font-size:250%;font-weight:bold}#ja-header{height:60px;position:relative;z-index:999;width:920px;margin:0 auto;clear:both}#ja-containerwrap,#ja-footer{width:920px;margin:0 auto;clear:both}#main-container{ min-height:100%; /*height:100%;*/ position:relative}#ja-footerwrap{clear:both;border-top:1px solid #CCC;margin-top:10px;background:url(../images/grad2.gif) repeat-x top; position:absolute; bottom:0; width:100%; height:60px}#ja-footer{padding:15px 0;position:relative}#ja-footer small{padding:4px 0 0 10px;float:left;display:block;color:#999;font-style:normal;line-height:normal}small.ja-copyright{position:absolute;right:10px}#ja-footer a{color:#666;text-decoration:none}#ja-footer a:hover,#ja-footer a:active,#ja-footer a:focus{color:#666;text-decoration:underline}#ja-footer ul{margin:4px 0 5px 10px;padding:0;float:left;background:url(http://forms-expert.com/images/vline.gif) no-repeat center right;line-height:normal}#ja-footer li{margin:0;padding:0;display:inline;background:none}#ja-footer li a{padding:0 10px;display:inline;background:url(http://forms-expert.com/images/vline.gif) no-repeat center left;font-size:92%;line-height:normal}.clearfix:after{clear:both;display:block;content:".";height:0;visibility:hidden}* html >body .clearfix{width:100%;display:block}* html .clearfix{height:1%}/* Firefox Scrollbar Hack - Do not remove *//*html{margin-bottom:1px;height:100%!important;height:auto}*/a{color:#F90}a:hover,a:active,a:focus{color:#F90}#ja-containerwrap{padding:0;padding-bottom:60px}</style></head><body id="bd" class="fs4"><div id="main-container"><br><br><br><br><br><div id="ja-containerwrap"> <div id="ja-container" class="clearfix"><div style="padding: 20px 30px 20px 30px;"><div class="ja-innerpad clearfix"><div class="componentheading">Your submission was successful. Thank you.</div><p align="right">This form was processed by <a href="http://forms-expert.com">Forms Expert</a>.<p align="right">© 2009 Forms-Expert. </div></div></div></div><div id="ja-footerwrap"><div id="ja-footer" class="clearfix"><ul><li><a href="http://forms-expert.com">Visit Forms Expert</a></li><li><a href="http://forms-expert.com/form-processing-features/">Features</a></li><li><a href="http://forms-expert.com/download/">Download Beta</a></li><li><a href="http://forms-expert.com/support/">Support</a></li><li><a href="http://forms-expert.com/contactus/">Contact page</a></li></ul><small class="ja-copyright">© 2009 <a href="http://forms-expert.com/">Forms-Expert</a></small></div></div></div></body></html> <?php } function display_spam_warning() { ?> <html> <form action="" method="post"><style> .form_expert_style {display: none;} </style> <?php IsThereErrors("1", $_iserrors); ?> <input type="hidden" name="firstname" value="<?php echo htmlspecialchars($_values['firstname'])?>"> <input type="hidden" name="lastname" value="<?php echo htmlspecialchars($_values['lastname'])?>"> <input type="hidden" name="email" value="<?php echo htmlspecialchars($_values['email'])?>"> <input type="hidden" name="companynumber" value="<?php echo htmlspecialchars($_values['companynumber'])?>"> <input type="hidden" name="upload1" value="<?php echo htmlspecialchars($_values['upload1'])?>"> <input type="hidden" name="upload1_real-name" value="<?php echo htmlspecialchars($_values['upload1_real-name'])?>"> <input type="hidden" name="upload2" value="<?php echo htmlspecialchars($_values['upload2'])?>"> <input type="hidden" name="upload2_real-name" value="<?php echo htmlspecialchars($_values['upload2_real-name'])?>"> <input type="hidden" name="upload3" value="<?php echo htmlspecialchars($_values['upload3'])?>"> <input type="hidden" name="upload3_real-name" value="<?php echo htmlspecialchars($_values['upload3_real-name'])?>"> <input type="hidden" name="upload4" value="<?php echo htmlspecialchars($_values['upload4'])?>"> <input type="hidden" name="upload4_real-name" value="<?php echo htmlspecialchars($_values['upload4_real-name'])?>"> <input type="hidden" name="upload5" value="<?php echo htmlspecialchars($_values['upload5'])?>"> <input type="hidden" name="upload5_real-name" value="<?php echo htmlspecialchars($_values['upload5_real-name'])?>"> <input type="hidden" name="_referer" value="<?php echo $_referer ?>"> <input type="hidden" name="_next_page" value="2"> <p class="form_expert_style"><input name="URL" type="text" value=""/></p> <p align="center"><b>Your submission seems to be a SPAM. Please contact web site administrator or click "Back" button to return to the form.</b></p> <p align="center"><input type="submit" name="back" value="< Back"></p></form> </html> <?php } function BuildBody($body, $html, $num){ global $zag, $un; if ($html) { $zag[$num] = "--".$un."\r\nContent-Type:text/html;\r\n"; } else { $zag[$num] = "--".$un."\r\nContent-Type:text/plain;\r\n"; }; $zag[$num] .= "Content-Transfer-Encoding: 8bit\r\n\r\n$body\r\n\r\n"; } function SendEmails (){ global $_values, $zag, $un; $un = strtoupper(uniqid(time())); $to[0] .= htmlspecialchars($_values["companynumber"]) . "@aissolutions.ca"; $from[0] .= "".str_replace("%,%", ",", $_values['email']).""; $subject[0] .= "upload_form was submitted on ".date("F j, Y")." ".date("H:i").""; $head[0] .= "MIME-Version: 1.0\r\n"; $head[0] .= "From: ".str_replace("%,%", ",", $_values['email'])."\r\n"; $head[0] .= "X-Mailer: Forms Expert at www.forms-expert.com\r\n"; $head[0] .= "Reply-To: ".str_replace("%,%", ",", $_values['email'])."\r\n"; $head[0] .= "Content-Type:multipart/mixed;"; $head[0] .= "boundary=\"".$un."\"\r\n\r\n"; $EmailBody = "<html><body> Form was filled with the following data: <br><b>firstname:</b> ".htmlspecialchars($_values["firstname"])." <br><b>lastname:</b> ".htmlspecialchars($_values["lastname"])." <br><b>email:</b> ".htmlspecialchars($_values["email"])." <br><b>companynumber:</b> ".htmlspecialchars($_values["companynumber"])." <br><b>upload1:</b> ".htmlspecialchars($_values["upload1"])." <br><b>upload2:</b> ".htmlspecialchars($_values["upload2"])." <br><b>upload3:</b> ".htmlspecialchars($_values["upload3"])." <br><b>upload4:</b> ".htmlspecialchars($_values["upload4"])." <br><b>upload5:</b> ".htmlspecialchars($_values["upload5"])." </body></html> "; BuildBody($EmailBody, True, 0); for ($i=0;$i<=0;$i++){ mail($to[$i], $subject[$i], $zag[$i], $head[$i]); } } $actions = array ("display_page_upload_form","display_thankyou"); session_start(); if(!isset($_SESSION["FormSent"])) { $_SESSION["FormSent"] = time(); $delta = -1; } else { $delta = time() - $_SESSION["FormSent"]; } if (((strlen(trim(@$_POST["URL"])) > 0) or (($delta>-1)and($delta<2)))and(!isset($_POST["back"]))){ display_spam_warning(); }else{ unset($_SESSION["FormSent"]); if (in_array($_GET["image"], array("warning"))) { header("Content-type: image/png"); echo base64_decode("iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAAsTAAALEwEAmpwYAAAKOWlDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanZZ3VFTXFofPvXd6oc0w0hl6ky4wgPQuIB0EURhmBhjKAMMMTWyIqEBEEREBRZCggAGjoUisiGIhKKhgD0gQUGIwiqioZEbWSnx5ee/l5ffHvd/aZ+9z99l7n7UuACRPHy4vBZYCIJkn4Ad6ONNXhUfQsf0ABniAAaYAMFnpqb5B7sFAJC83F3q6yAn8i94MAUj8vmXo6U+ng/9P0qxUvgAAyF/E5mxOOkvE+SJOyhSkiu0zIqbGJIoZRomZL0pQxHJijlvkpZ99FtlRzOxkHlvE4pxT2clsMfeIeHuGkCNixEfEBRlcTqaIb4tYM0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kcXOIYOP+cY/j36T3Db6C+/6BcBso5/yBR9f8vJGr+Qdl/f/1j+HrvNoOquhrbk9vcqUBVRwECiIWZjV36x6PXDN/+fmX4D7QAhJnYIJYxMUEiiRFU2AEx039YjvnHwPRxPwMX435gOQG1ENpnAKljAOL/oMgF8YHmgNT8h2bPL08+MrAAKywuPhYzkBaAAGL59vnVqSf3GBgUBYFFOjcjAzMnE7CEA1oGrAaYWBnBIQDyNZhmRDgI0q2BOIqJAWIZsPQB0/+hoQELgb8//0NyE9Alv7//Y7h/7gnD67cMm0FGAAQQi0VQ2frbpzZOPn37Rryk6H8+7l8sDGzfmBmYQaHAxAi2HGQRjIZ3qRiRa0/UnhM4KmA0KE39/sfw6/t/hl8f/zA8fwrMrFKqS0z9/dtAygECiBFUBnx4cZvh8/tnGoyMzLJAO7mAQc8G8TuSlaT0YRlRa3dgsfwXaM0vYFQB8Z8XvIJSVwQl1UBlKgNAADHiaTwyYRhFHviPhDEAQACx4HA7I5UsZ8BiDopDAAIMAP+QrU5p/QTlAAAAAElFTkSuQmCC"); }else{ if (isset($_POST["_next_page"])) { $_next_page = $_POST["_next_page"]; }else $_next_page = 0; if (isset($_POST["back"])) { call_user_func($actions[$_next_page-2],false); }else if (IsThereErrors($_next_page-1, false)){ call_user_func($actions[$_next_page-1],true); }else { call_user_func($actions[$_next_page+0],false); if ($_next_page == count($actions)-1) { SendEmails(); session_destroy(); } } } } ?> Hello All, Have another problem want to make the fields editable, i have tried in several ways but it's not helping if some one can help me out on this, i have tried contents editable = "true" but not helpful at all below is the code: Please advise what and where needs to be added to make the fields editable except date fields. <?php session_start(); error_reporting(0); include('includes/dbconnection.php'); if (strlen($_SESSION['cvmsaid']==0)) { header('location:logout.php'); } else{ if(isset($_POST['submit'])) { $eid=$_GET['editid']; $remark=$_POST['remark']; $fullname=$_POST['fullname']; $query=mysqli_query($con,"update tblsupvisitor set remark='$remark',fullname-'$fullname' where ID='$eid'"); if ($query) { $msg="Visitors Remark has been Updated."; } else { $msg="Something Went Wrong. Please try again"; } } ?> <!DOCTYPE html> <html lang="en"> <head> <!-- Required meta tags--> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <meta name="description" content="au theme template"> <meta name="author" content="Hau Nguyen"> <meta name="keywords" content="au theme template"> <!-- Title Page--> <title>CVSM Visitors Forms</title> <!-- Fontfaces CSS--> <link href="css/font-face.css" rel="stylesheet" media="all"> <link href="vendor/font-awesome-5/css/fontawesome-all.min.css" rel="stylesheet" media="all"> <link href="vendor/font-awesome-4.7/css/font-awesome.min.css" rel="stylesheet" media="all"> <link href="vendor/mdi-font/css/material-design-iconic-font.min.css" rel="stylesheet" media="all"> <!-- Bootstrap CSS--> <link href="vendor/bootstrap-4.1/bootstrap.min.css" rel="stylesheet" media="all"> <!-- Vendor CSS--> <link href="vendor/animsition/animsition.min.css" rel="stylesheet" media="all"> <link href="vendor/bootstrap-progressbar/bootstrap-progressbar-3.3.4.min.css" rel="stylesheet" media="all"> <link href="vendor/wow/animate.css" rel="stylesheet" media="all"> <link href="vendor/css-hamburgers/hamburgers.min.css" rel="stylesheet" media="all"> <link href="vendor/slick/slick.css" rel="stylesheet" media="all"> <link href="vendor/select2/select2.min.css" rel="stylesheet" media="all"> <link href="vendor/perfect-scrollbar/perfect-scrollbar.css" rel="stylesheet" media="all"> <!-- Main CSS--> <link href="css/theme.css" rel="stylesheet" media="all"> </head> <body class="animsition"> <div class="page-wrapper"> <!-- HEADER MOBILE--> <?php include_once('includes/sidebar-Supp.php');?> <!-- END HEADER MOBILE--> <!-- MENU SIDEBAR--> <!-- END MENU SIDEBAR--> <!-- PAGE CONTAINER--> <div class="page-container"> <!-- HEADER DESKTOP--> <?php include_once('includes/header-supp.php');?> <!-- HEADER DESKTOP--> <!-- MAIN CONTENT--> <div class="main-content"> <div class="section__content section__content--p30"> <div class="container-fluid"> <div class="row"> <div class="col-lg-12"> <div class="card"> <div class="card-header"> <strong>Visitor</strong> Details </div> <div class="card-body card-block"> <p style="font-size:16px; color:red" align="center"> <?php if($msg){ echo $msg; } ?> </p> <?php $eid=$_GET['editid']; $ret=mysqli_query($con,"select * from tblsupvisitor where ID='$eid'"); $cnt=1; while ($row=mysqli_fetch_array($ret)) { ?><table border="1" class="table table-bordered mg-b-0"> <tr> <th>Full Name</th> <td><?php echo $row['FullName'];?></td> </tr> <tr> <th>Qatar ID #</th> <td><?php echo $row['IDNO'];?></td> </tr> <tr> <th>Vehicle #</th> <td><?php echo $row['vno'];?></td> </tr> <tr> <th>No of Persons</th> <td><?php echo $row['noopaxs'];?></td> </tr> <tr> <th>Address</th> <td><?php echo $row['Address'];?></td> </tr> <tr> <th>Whom to Meet</th> <td><?php echo $row['WhomtoMeet'];?></td> </tr> <tr> <th>Deptartment</th> <td><?php echo $row['Deptartment'];?></td> </tr> <tr> <th>Reason to Meet</th> <td><?php echo $row['ReasontoMeet'];?></td> </tr> <tr> <th>Vistor Entring Time</th> <td><?php echo $row['EnterDate'];?></td> </tr> <?php if($row['remark']==""){ ?> <form method="post"> <tr> <th>Outing Remark :</th> <td> <textarea name="remark" placeholder="" rows="12" cols="14" class="form-control wd-450" required="true"></textarea></td> </tr> <tr align="center"> <td colspan="2"><button type="submit" name="submit" class="btn btn-primary btn-sm">Update</button></td> </tr> </form> <?php } else { ?> <tr> <th>Outing Remark </th> <td><?php echo $row['remark']; ?></td> </tr> <tr> <th>Out Time</th> <td><?php echo $row['outtime']; ?> </td> <?php } ?> </tr> </table> </div> </div> </div> </div> <?php include_once('includes/footer.php');?> </div> </div> </div> </div> <!-- Jquery JS--> <script src="vendor/jquery-3.2.1.min.js"></script> <!-- Bootstrap JS--> <script src="vendor/bootstrap-4.1/popper.min.js"></script> <script src="vendor/bootstrap-4.1/bootstrap.min.js"></script> <!-- Vendor JS --> <script src="vendor/slick/slick.min.js"> </script> <script src="vendor/wow/wow.min.js"></script> <script src="vendor/animsition/animsition.min.js"></script> <script src="vendor/bootstrap-progressbar/bootstrap-progressbar.min.js"> </script> <script src="vendor/counter-up/jquery.waypoints.min.js"></script> <script src="vendor/counter-up/jquery.counterup.min.js"> </script> <script src="vendor/circle-progress/circle-progress.min.js"></script> <script src="vendor/perfect-scrollbar/perfect-scrollbar.js"></script> <script src="vendor/chartjs/Chart.bundle.min.js"></script> <script src="vendor/select2/select2.min.js"> </script> <!-- Main JS--> <script src="js/main.js"></script> </body> </html> <!-- end document--> <?php } ?> <?php } ?> Â Any help will be much appreciated. Â Kind Regards, Naveed. Edited July 30, 2020 by Naveed786I am working on a little project for my site and I am trying to get this script to ignore the index.html file and the .htaccess file in there. I just want it to display all files like .zip, .rar, .tar, .gz, .gtar, .ace, ect... echo " <td width='70%'><select id='download'>"; echo " <option value=''>None</option>"; if ($handle = opendir("./modules/Downloads/files")) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { echo " <option value='".$file."'>".$file."</option>"; } } closedir($handle); } echo " </td>\n"; Here goes.
I am trying to retrieve info. from mySql database and update 3 textfields.
I also have 4 selects on the form that need populating during the running of the program. My problem is using console I can see the info - Customer name - but it does not appear in the text field. The onchange request in the DIV container seems to be where it fails. Here are the files I am using:
1. add_an_order.php
<html> <head> <title>Add an Order</title> <link href = "css/style.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="include/jquery-1.11.1.min.js"></script> </head> <body> <div id="header"><img src="images/logo.png" /></div> <div id="nav"> <div id="nav_wrapper"> <ul> <li><a href="index.php">Orders</a></li><li> <a href="customers.php">Customers</a></li><li> <a href="contacts.php">Contacts</a></li><li> <a href="batteries.php">Batteries</a></li><li> <a href="#">Queries</a> </li> </ul> </div> </div> <div id="main"> <?php echo '<h3 id="menOpt">Add an Order</h3><hr>'; // Check for a form submission. /* if ($_SERVER['REQUEST_METHOD'] == 'POST') { $errors = array(); $required_fields = array('customer_name', 'customer_address', 'city', 'telephone'); foreach ($required_fields as $fieldname) { if (!isset($_POST[$fieldname]) || empty($_POST[$fieldname])) { $errors[] = strtoupper($fieldname); } } if (empty($errors)) { include ('include/dbconnect.php'); $name = mysqli_real_escape_string($con, trim(strip_tags($_POST['customer_name']))); $contact = mysqli_real_escape_string($con, trim(strip_tags($_POST['contact']))); $address = mysqli_real_escape_string($con, trim(strip_tags($_POST['customer_address']))); $city = mysqli_real_escape_string($con, trim(strip_tags($_POST['city']))); $telephone = mysqli_real_escape_string($con, trim(strip_tags($_POST['telephone']))); $telephone = preg_replace('/[^0-9]/', '', $telephone); if (isset($_POST['deepc'])) { $deepc = 1; } else { $deepc = 0; } if (isset($_POST['problemc'])) { $problemc = 1; } else { $problemc = 0; } $problem = mysqli_real_escape_string($con, trim(strip_tags($_POST['problem']))); if (isset($_POST['blacklist'])) { $blacklist = 1; } else { $blacklist = 0; } if (isset($_POST['pickup'])) { $pickup = 1; } else { $pickup = 0; } $query = "INSERT INTO customers ( customer_name, contact, customer_address, city, telephone, deep_cycle, problem_customer, problem, blacklist, pickup) VALUES ('$name', '$contact', '$address', '$city', '$telephone', $deepc, $problemc, '$problem', $blacklist, $pickup)"; $r = mysqli_query($con, $query); if (mysqli_affected_rows($con) == 1) { echo '<p class="success">Customer has been successfully added.</p>'; } else { $message = "Could not add customer."; $message .= "<br />" . mysqli_error($con); } mysqli_close($con); } else { // We have errors. $message = count($errors) . " error(s) on the form."; } } // End: if ($_SERVER['REQUEST_METHOD'] == 'POST'). */ // Leave PHP and display the form. ?> <?php if (!empty($message)) { echo '<p class="error">' . $message . '</p>'; } ?> <?php // Output list of fields that have errors. if (!empty($errors)) { echo '<p class="error">'; foreach ($errors as $error) { echo $error . '<br />'; } echo '</p>'; } ?> <div class="container"> <form action="<?php $_SERVER['PHP_SELF']; ?>" method="post"> <fieldset> <label>Business: <span class="important"> *</span><select name="customer_name" id="customer_name" onchange="request_fill(this.value)" value="<?php if (isset($_POST['customer_name'])) echo $_POST['customer_name']; ?>" ></select></label> <label>Address: <input type="text" name="address" id="add_a" value="<?php if (isset($_POST['customer_address'])) echo $_POST['customer_address']; ?>" /></label> <label>City: <input type="text" name="city" id="city" value="<?php if (isset($_POST['city'])) echo $_POST['city']; ?>" /></label> <label>Phone: <input type="text" name="telephone" value="<?php if (isset($_POST['telephone'])) echo $_POST['telephone']; ?>" /></label> <label>Manufacturer: <span class="important"> *</span><select name="manufacturer" id="manufacturer" onchange="request_mod(this.value)" value="<?php if (isset($_POST['manufacturer'])) echo $_POST['manufacturer']; ?>" ></select></label> <label>Model: <span class="important"> *</span><select name="model" id="model" onchange="form_yr(this.value)" value="<?php if (isset($_POST['model'])) echo $_POST['model']; ?>" ></select></label> <label>Year: <span class="important"> *</span><select name="battery" id="bat_disp" value="<?php if (isset($_POST['battery'])) echo $_POST['year'] ?>" ></select></label> <label>Quantity: <span class="important"> *</span><input type="text" name="quantity" id="quantity" value="<?php if (isset($_POST['quantity'])) echo $_POST['quantity']; ?>" /></label> <label>Warranty ? <input type="checkbox" name="warranty" <?php if ($_POST['warranty']) echo " checked"; ?> /></label> <label>Exchange ? <input type="checkbox" name="exchange" <?php if ($_POST['exchange']) echo " checked"; ?> /></label> <input type="submit" name="submit" value="Add Order" /> or <a href="index.php">Cancel</a> </fieldset> </form> </div> <script type="text/javascript" src="include/functions.js"></script> <script> $(document).ready(function() { $('.container').hide(); $('.container').fadeIn(1000); request_cust(); request_man(); }); </script> <?php include ('include/footer.php'); 2. request_fill function request_fill() { var cust2 = 'customer'; var ad = document.getElementById("add_a"); var hr = new XMLHttpRequest(); hr.open("POST", "battery_parser.php", true); hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); hr.onreadystatechange = function() { if(hr.readyState == 4 && hr.status == 200) { var dataArray = hr.responseText; ad.innerHTML = dataArray[1]; } } hr.send("&cust2="+cust2); } 3. battery_parser.php <?php include_once("include/dbconnect.php"); if (isset($_POST['cust2'])) { $cust2 = $_POST['cust2']; $sql = "SELECT customer_address FROM customers WHERE customer_id = 2"; $query = mysqli_query($con, $sql); $dataString = ''; while($row = mysqli_fetch_array($query, MYSQLI_ASSOC)){ $add = $row["customer_address"]; $dataString = $add; } mysqli_close($con); echo $dataString; exit(); } else { exit(); } ?> Assist a newbie! Greetings! I have a CSV file that looks something like this: Quote ,,,,,,,,sdfsdf sdfsdf,,,,,,,,,,,,,,,,,,,,,,sdfsdfsdf:,,,,,,,,2011-04-27,,,,,, ,,,,,,,,,,,,,,,,,,,,,,,, ,,,,,,,,dfgdfg,,fgh,,,,,gfh,,,,,,,,,,,,,,fghfgh,,,,,fghf,, fghfh,, fgh,,,,,,fhfgh,,,, Code: [Select] <?php $handle = fopen("csv.csv", "r"); while (($data = fgetcsv($handle, 5000, ",")) !== FALSE) { echo "<pre>"; print_r($data); echo "<pre>"; } ?> Now this prints everything, could someone please provide me with an example of how I can ignore the "empty fields"? Thanks in advance! Hi, I searched and couldn't find a previous solution.. I'm supposed to take this existing long form and tweak it so it excludes empty fields when emailed.. Can anyone show me what would work for this code below? Any help would be greatly appreciated.. Sorry for the long code, i didn't know where to cut it off.. Code: [Select] <?php $EmailTo = Trim(stripslashes($_POST['EmailTo'])); $EmailFrom = Trim(stripslashes($_POST['EmailFrom'])); $Subject = ""; // terms $terms_conditions_details = Trim(stripslashes($_POST['terms_conditions_details'])); // contact information $full_name = Trim(stripslashes($_POST['full_name'])); $title = Trim(stripslashes($_POST['title'])); $company = Trim(stripslashes($_POST['company'])); $billing_address = Trim(stripslashes($_POST['billing_address'])); $billing_city = Trim(stripslashes($_POST['billing_city'])); $billing_state = Trim(stripslashes($_POST['billing_state'])); $billing_zip = Trim(stripslashes($_POST['billing_zip'])); $phone = Trim(stripslashes($_POST['phone'])); $alt_phone = Trim(stripslashes($_POST['alt_phone'])); $how_did_you_hear = Trim(stripslashes($_POST['how_did_you_hear'])); // event information $event_date = Trim(stripslashes($_POST['event_date'])); $guests = Trim(stripslashes($_POST['guests'])); $event_start_time = Trim(stripslashes($_POST['event_start_time'])); $event_end_time = Trim(stripslashes($_POST['event_end_time'])); $event_address = Trim(stripslashes($_POST['event_address'])); $event_city = Trim(stripslashes($_POST['event_city'])); $event_state = Trim(stripslashes($_POST['event_state'])); $event_zip = Trim(stripslashes($_POST['event_zip'])); $event_type = Trim(stripslashes($_POST['event_type'])); $event_type_other = Trim(stripslashes($_POST['event_type_other'])); $event_theme = Trim(stripslashes($_POST['event_theme'])); $special_requests = Trim(stripslashes($_POST['special_requests'])); $budget = Trim(stripslashes($_POST['budget'])); $service_type = Trim(stripslashes($_POST['service_type'])); // wings & wingers $grilled_wings = Trim(stripslashes($_POST['grilled_wings'])); $buffalo_wings = Trim(stripslashes($_POST['buffalo_wings'])); $wingers = Trim(stripslashes($_POST['wingers'])); $wing_sauces1 = Trim(stripslashes($_POST['wing_sauces1'])); $wing_sauces2 = Trim(stripslashes($_POST['wing_sauces2'])); $wing_sauces3 = Trim(stripslashes($_POST['wing_sauces3'])); $wing_sauces4 = Trim(stripslashes($_POST['wing_sauces4'])); $wing_sauces5 = Trim(stripslashes($_POST['wing_sauces5'])); $wing_sauces6 = Trim(stripslashes($_POST['wing_sauces6'])); $wing_sauces7 = Trim(stripslashes($_POST['wing_sauces7'])); $wing_sauces8 = Trim(stripslashes($_POST['wing_sauces8'])); $wing_sauces9 = Trim(stripslashes($_POST['wing_sauces9'])); $wing_sauces10 = Trim(stripslashes($_POST['wing_sauces10'])); $wing_sauces11 = Trim(stripslashes($_POST['wing_sauces11'])); $wing_sauces12 = Trim(stripslashes($_POST['wing_sauces12'])); $wing_sauces13 = Trim(stripslashes($_POST['wing_sauces13'])); $wing_sauces14 = Trim(stripslashes($_POST['wing_sauces14'])); // party platters $chicken_finger_platter = Trim(stripslashes($_POST['chicken_finger_platter'])); $chicken_nugget_platter = Trim(stripslashes($_POST['chicken_nugget_platter'])); $chicken_wing_platter = Trim(stripslashes($_POST['chicken_wing_platter'])); // salads $caesar_salad = Trim(stripslashes($_POST['caesar_salad'])); $house_salad = Trim(stripslashes($_POST['house_salad'])); $cobb_salad = Trim(stripslashes($_POST['cobb_salad'])); $sea_breeze_salad = Trim(stripslashes($_POST['sea_breeze_salad'])); // appetizers $fresh_fruit_platter = Trim(stripslashes($_POST['fresh_fruit_platter'])); $chilled_vegetable_platter = Trim(stripslashes($_POST['chilled_vegetable_platter'])); $cocktail_shrimp = Trim(stripslashes($_POST['cocktail_shrimp'])); $tailgate_chips_platter = Trim(stripslashes($_POST['tailgate_chips_platter'])); $chips_and_salsa = Trim(stripslashes($_POST['chips_and_salsa'])); $spinach_artichoke_dip_platter = Trim(stripslashes($_POST['spinach_artichoke_dip_platter'])); $quesadilla_platter = Trim(stripslashes($_POST['quesadilla_platter'])); // entrees $bbq_ribs_platter = Trim(stripslashes($_POST['bbq_ribs_platter'])); $hawaiian_chicken = Trim(stripslashes($_POST['hawaiian_chicken'])); $mahi_over_rice = Trim(stripslashes($_POST['mahi_over_rice'])); // sandwiches $gourmet_slider_platter = Trim(stripslashes($_POST['gourmet_slider_platter'])); $mini_cheeseburger_platter = Trim(stripslashes($_POST['mini_cheeseburger_platter'])); $club_sandwich_platter = Trim(stripslashes($_POST['club_sandwich_platter'])); $turkey_wrap_platter = Trim(stripslashes($_POST['turkey_wrap_platter'])); $philly_cheese_platter = Trim(stripslashes($_POST['philly_cheese_platter'])); // dessert $chocolate_brownie_platter = Trim(stripslashes($_POST['chocolate_brownie_platter'])); $apple_crisp = Trim(stripslashes($_POST['apple_crisp'])); $mini_gourmet_cheesecakes = Trim(stripslashes($_POST['mini_gourmet_cheesecakes'])); //$10 meal deal $meal_deal_wings = Trim(stripslashes($_POST['meal_deal_wings'])); $meal_deal_grilled_chicken = Trim(stripslashes($_POST['meal_deal_grilled_chicken'])); $meal_deal_burger = Trim(stripslashes($_POST['meal_deal_burger'])); $meal_deal_lemonade = Trim(stripslashes($_POST['meal_deal_lemonade'])); $meal_deal_iced_tea = Trim(stripslashes($_POST['meal_deal_iced_tea'])); $meal_deal_sauces1 = Trim(stripslashes($_POST['meal_deal_sauces1'])); $meal_deal_sauces2 = Trim(stripslashes($_POST['meal_deal_sauces2'])); $meal_deal_sauces3 = Trim(stripslashes($_POST['meal_deal_sauces3'])); $meal_deal_sauces4 = Trim(stripslashes($_POST['meal_deal_sauces4'])); $meal_deal_sauces5 = Trim(stripslashes($_POST['meal_deal_sauces5'])); $meal_deal_sauces6 = Trim(stripslashes($_POST['meal_deal_sauces6'])); $meal_deal_sauces7 = Trim(stripslashes($_POST['meal_deal_sauces7'])); $meal_deal_sauces8 = Trim(stripslashes($_POST['meal_deal_sauces8'])); $meal_deal_sauces9 = Trim(stripslashes($_POST['meal_deal_sauces9'])); $meal_deal_sauces10 = Trim(stripslashes($_POST['meal_deal_sauces10'])); $meal_deal_sauces11 = Trim(stripslashes($_POST['meal_deal_sauces11'])); $meal_deal_sauces12 = Trim(stripslashes($_POST['meal_deal_sauces12'])); $meal_deal_sauces13 = Trim(stripslashes($_POST['meal_deal_sauces13'])); $meal_deal_sauces14 = Trim(stripslashes($_POST['meal_deal_sauces14'])); // box lunches $box_turkey_ruben = Trim(stripslashes($_POST['box_turkey_ruben'])); $box_blt_on_ciabatta = Trim(stripslashes($_POST['box_blt_on_ciabatta'])); $box_club = Trim(stripslashes($_POST['box_club'])); $box_ham_and_cheese = Trim(stripslashes($_POST['box_ham_and_cheese'])); $box_chipolte_shrimp_blt = Trim(stripslashes($_POST['box_chipolte_shrimp_blt'])); $box_turkey_bacon_ranch = Trim(stripslashes($_POST['box_turkey_bacon_ranch'])); $box_buffalo_chicken = Trim(stripslashes($_POST['box_buffalo_chicken'])); $box_veggie = Trim(stripslashes($_POST['box_veggie'])); $box_caesar_salad = Trim(stripslashes($_POST['box_caesar_salad'])); $box_house_salad = Trim(stripslashes($_POST['box_house_salad'])); $box_cobb_salad = Trim(stripslashes($_POST['box_cobb_salad'])); $box_sea_breeze_salad = Trim(stripslashes($_POST['box_sea_breeze_salad'])); // full service catering $theme_package = Trim(stripslashes($_POST['theme_package'])); $theme_package_information = Trim(stripslashes($_POST['theme_package_information'])); $reception = Trim(stripslashes($_POST['reception'])); $reception_information = Trim(stripslashes($_POST['reception_information'])); $specialty_stations = Trim(stripslashes($_POST['specialty_stations'])); $bar_beverage_service = Trim(stripslashes($_POST['bar_beverage_service'])); $bar_beverage_service_information = Trim(stripslashes($_POST['bar_beverage_service_information'])); $breakfast = Trim(stripslashes($_POST['breakfast'])); $breakfast_information = Trim(stripslashes($_POST['breakfast_information'])); $notes = Trim(stripslashes($_POST['notes'])); // payment $payment1 = Trim(stripslashes($_POST['payment1'])); $payment2 = Trim(stripslashes($_POST['payment2'])); $payment3 = Trim(stripslashes($_POST['payment3'])); $payment4 = Trim(stripslashes($_POST['payment4'])); $payment5 = Trim(stripslashes($_POST['payment5'])); $payment6 = Trim(stripslashes($_POST['payment6'])); // confirmation email $confirmation_subject = ""; $confirmation_body = "$full_name,\n\n Thank you for emailing us. A catering manager from your location will get in touch with you shortly.\n\n \n \n"; $Body = ""; $Body .= "CONTACT INFORMATION\n"; $Body .= "\nFull Name: "; $Body .= $full_name; $Body .= "\nTitle: "; $Body .= $title; $Body .= "\nCompany: "; $Body .= $company; $Body .= "\nBilling Address: "; $Body .= $billing_address; $Body .= ", "; $Body .= $billing_city; $Body .= ", "; $Body .= $billing_state; $Body .= ", "; $Body .= $billing_zip; $Body .= "\nPhone: "; $Body .= $phone; $Body .= "\nAlternate Phone: "; $Body .= $alt_phone; $Body .= "\nHow did you hear about us?: "; $Body .= $how_did_you_hear; $Body .= "\n"; $Body .= $terms_conditions_details; $Body .= "\n\nEVENT INFORMATION\n"; $Body .= "\nEvent Date: "; $Body .= $event_date; $Body .= "\nNumber of Guests: "; $Body .= $guests; $Body .= "\nEvent Start Time: "; $Body .= $event_start_time; $Body .= "\nEvent End Time: "; $Body .= $event_end_time; $Body .= "\nEvent Address: "; $Body .= $event_address; $Body .= ", "; $Body .= $event_city; $Body .= ", "; $Body .= $event_state; $Body .= ", "; $Body .= $event_zip; $Body .= "\nType of Event: "; $Body .= $event_type; $Body .= "\nType of Event: Other: "; $Body .= $event_type_other; $Body .= "\nEvent Theme: "; $Body .= $event_theme; $Body .= "\nSpecial Requests: "; $Body .= $special_requests; $Body .= "\nBudget: "; $Body .= $budget; $Body .= "\nType of Service: "; $Body .= $service_type; $Body .= "\n\nWINGS & WINGERS\n"; $Body .= "\nGrilled Wings: "; $Body .= $grilled_wings; $Body .= "\nBuffalo Wings: "; $Body .= $buffalo_wings; $Body .= "\nWingers: "; $Body .= $wingers; $Body .= "\nWing Sauces: "; $Body .= "$wing_sauces1, $wing_sauces2, $wing_sauces3, $wing_sauces4, $wing_sauces5, $wing_sauces6, $wing_sauces7, $wing_sauces8, $wing_sauces9, $wing_sauces10, $wing_sauces11, $wing_sauces12, $wing_sauces13, $wing_sauces14"; $Body .= "\n\nPARTY PLATTERS\n"; $Body .= "\nChicken Finger Platter: "; $Body .= $chicken_finger_platter; $Body .= "\nChicken Nugget Platter: "; $Body .= $chicken_nugget_platter; $Body .= "\nChicken Wing Platter: "; $Body .= $chicken_wing_platter; $Body .= "\n\nSALADS\n"; $Body .= "\nCaesar Salad: "; $Body .= $caesar_salad; $Body .= "\nHouse Salad: "; $Body .= $house_salad; $Body .= "\nCobb Salad: "; $Body .= $cobb_salad; $Body .= "\nSea Breeze Salad: "; $Body .= $sea_breeze_salad; $Body .= "\n\nAPPETIZERS\n"; $Body .= "\nFresh Fruit Platter: "; $Body .= $fresh_fruit_platter; $Body .= "\nChilled Vegetable Platter: "; $Body .= $chilled_vegetable_platter; $Body .= "\nCocktail Shrimp: "; $Body .= $cocktail_shrimp; $Body .= "\nTailgate Chips Platter: "; $Body .= $tailgate_chips_platter; $Body .= "\nChips and Salsa: "; $Body .= $chips_and_salsa; $Body .= "\nSpinach Artichoke Dip Platter: "; $Body .= $spinach_artichoke_dip_platter; $Body .= "\nQuesadilla Platter: "; $Body .= $quesadilla_platter; $Body .= "\n\nENTREES\n"; $Body .= "\nBBQ Ribs Platter: "; $Body .= $bbq_ribs_platter; $Body .= "\nHawaiian Chicken: "; $Body .= $hawaiian_chicken; $Body .= "\nMahi Over Rice: "; $Body .= $mahi_over_rice; $Body .= "\n\nSANDWICHES\n"; $Body .= "\nGourmet Slider Platter: "; $Body .= $gourmet_slider_platter; $Body .= "\nMini Cheeseburger Platter: "; $Body .= $mini_cheeseburger_platter; $Body .= "\nClub Sandwich Platter: "; $Body .= $club_sandwich_platter; $Body .= "\nTurkey Wrap Platter: "; $Body .= $turkey_wrap_platter; $Body .= "\nPhilly Cheese Platter: "; $Body .= $philly_cheese_platter; $Body .= "\n\nDESSERT\n"; $Body .= "\nChocolate Brownie Platter: "; $Body .= $chocolate_brownie_platter; $Body .= "\nApple Crisp: "; $Body .= $apple_crisp; $Body .= "\nMini Gourmet Cheesecakes: "; $Body .= $mini_gourmet_cheesecakes; $Body .= "\n\n$10 MEAL DEAL\n"; $Body .= "\nWings: "; $Body .= $meal_deal_wings; $Body .= "\nGrilled Chicken Breast: "; $Body .= $meal_deal_grilled_chicken; $Body .= "\nBurger: "; $Body .= $meal_deal_burger; $Body .= "\nLemonade: "; $Body .= $meal_deal_lemonade; $Body .= "\nIced Tea: "; $Body .= $meal_deal_iced_tea; $Body .= "\nWing Sauces: "; $Body .= "\n\nBOX LUNCHES\n"; $Body .= "\nSandwiches"; $Body .= "\nTurkey Ruben: "; $Body .= $box_turkey_ruben; $Body .= "\nBLT on Ciabatta Bread: "; $Body .= $box_blt_on_ciabatta; $Body .= "\nClub: "; $Body .= $box_club; $Body .= "\nHam and Cheese: "; $Body .= $box_ham_and_cheese; $Body .= "\n\nWraps"; $Body .= "\nChipolte Shrimp BLT: "; $Body .= $box_chipolte_shrimp_blt; $Body .= "\nTurkey Bacon Ranch: "; $Body .= $box_turkey_bacon_ranch; $Body .= "\nBuffalo Chicken: "; $Body .= $box_buffalo_chicken; $Body .= "\nVeggie: "; $Body .= $box_veggie; $Body .= "\n\nSalad"; $Body .= "\nCaesar Salad: "; $Body .= $box_caesar_salad; $Body .= "\nHouse Salad: "; $Body .= $box_house_salad; $Body .= "\nCobb Salad: "; $Body .= $box_cobb_salad; $Body .= "\nSea Breeze Salad: "; $Body .= $box_sea_breeze_salad; $Body .= "\n\nFULL SERVICE CATERING\n"; $Body .= "\nTheme Package: "; $Body .= $theme_package; $Body .= "\nInformation: "; $Body .= $theme_package_information; $Body .= "\nReception: "; $Body .= $reception; $Body .= "\nInformation: "; $Body .= $reception_information; $Body .= "\nSpecialty Stations: "; $Body .= $specialty_stations; $Body .= "\nBar/Beverage Service: "; $Body .= $bar_beverage_service; $Body .= "\nInformation: "; $Body .= $bar_beverage_service_information; $Body .= "\nBreakfast: "; $Body .= $breakfast; $Body .= "\nInformation: "; $Body .= $breakfast_information; $Body .= "\nNotes: "; $Body .= $notes; $Body .= "\n\nPAYMENT TYPE\n"; $Body .= "$payment1, $payment2, $payment3, $payment4, $payment5, $payment6"; $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>") && mail($EmailFrom, $confirmation_subject, $confirmation_body, "From: <$EmailTo>"); I have a form with a series of text boxes where the User enters specific data, be it text, numeric, or date/time. It is not mandatory to fill in every box, but when I submit the form to be put into a mysql table, I get errors such as "Incorrect time value: '' for column 'starttime' at row 1" "Incorrect decimal value: '' for column 'workkj' at row 1" How can I setup the mysql table to accept blank answers? Or is there something I need to do in php to fix this? Sorry if this is simple... I'm still learning. Thanks for the help! Hi I'm currently having a problem with my form. Users submit an empty field into the database and the next time another user tries to enter it just says username has been taken. I need some help on how to confirm that the username and email field isnt empty when inserted and that the email address is in the correct format.
<?php include "base.php"; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>User Management System (Tom Cameron for NetTuts)</title> <link rel="stylesheet" href="style.css" type="text/css" /> </head> <body> <div id="main"> <?php $username = mysql_real_escape_string($_POST["username"]); $email = mysql_real_escape_string($_POST["email"]); $mxitid = mysql_real_escape_string($_SERVER["HTTP_X_MXIT_USERID_R"]); if(!isset($mxitid)) { $mxitid = "DEFAULT"; } $checkusername = mysql_query("SELECT * FROM Users WHERE mxitid = '".$mxitid."'"); $checkemail = mysql_query("SELECT * FROM Users WHERE email = '".$email."'"); if(mysql_num_rows($checkusername) == 1) { echo "<h1>Error</h1>"; echo "<p>Sorry, that username is taken. Please go <a href=\"register.php\">back</a>and try again.</p>"; } elseif(mysql_num_rows($checkemail) == 1) { echo "<h1>Error</h1>"; echo "<p>Sorry, that email is taken. Please go <a href=\"register.php\">back</a>and try again.</p>"; } elseif ($_POST["register"]) { $username = mysql_real_escape_string($_POST["username"]); if(!isset($mxitid)) $mxitid = mysql_real_escape_string($_SERVER["HTTP_X_MXIT_USERID_R"]); if(!isset($mxitid)) { $mxitid = "DEFAULT"; } $registerquery = mysql_query("INSERT INTO Users (Username,mxitid,email) VALUES('".$username."','".$mxitid."','".$email."')"); if($registerquery) { echo "<h1>Success</h1>"; echo "<p>Your account was successfully created. Please <a href=\"index9.php\">click here to start chatting</a>.</p>"; } } else { ?> <h1>Register</h1> <p>Please enter your details below to register.</p> <p>Keep it clean! or you might get banned!</p> <form method="post" action="register.php" name="registerform" id="registerform"> <fieldset> <label for="username">Username:<br> Using emoticons in your name won't work!</label><input type="text" name="username" id="username" /><br /> <label for="email">Email:<br>(We need your real one to be able to contact you!)<br> If you don't have one make use of your mxit email service.</label><input type="email" name="email" id="email" /><br /> <input type="hidden" name="mxitid" id="mxitid" value="<? $_SERVER['HTTP_X_MXIT_USERID_R']; ?>"/><br /> <input type="submit" name="register" id="register" value="Register" /> </fieldset> </form> <?php } ?> </div> </body> </html>I tried using function check_input($data, $problem='') { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); if ($problem && strlen($data) == 0) { die($problem); } return $data; }but it didnt seems to work Hi, i'm new here and hope i've finally found a forum where i can find the perfect solution for my questions.
Well since a year now i started to work with PHP and still now and then there are some things where i seize on. My question is on of those situations.
I have the following code:
if (isset($_POST)){ foreach ($_POST as $key => $value){ if (!empty($value)){ $update_rma_detail_stmt = $dbh->prepare("UPDATE rma_detail SET $key = ? WHERE rd_rma_nr = ?"); $update_rma_detail_stmt->bindParam(1, $value); $update_rma_detail_stmt->bindParam(2, $getadmrmaid); $update_rma_detail_stmt->execute(); } } }All i want is when there is an empty (not filled in) input field because it is not mandatory the foreach still continuous to the end. When i use if (!empty($value)){It still outputs these error: Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 1366 Incorrect integer value: ' ' However, when i dont use i got an other error: Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect date value: '' It is however so that the datetime is the very first empty field it come across when looping. I think my if (!empty($value)){ is doing the right thing but still gives error's on integers. Can it be? I allready tried to use trim() or array_filter() but because i previously never used it i dont know if i am doing it the right way so any help is welkom! Thanks! Edited by Raz3rt, 20 May 2014 - 02:56 AM. so, I've been trying to build a contact form for about a week now. straight. no kidding. I'm entirely new to php and basically know nothing more than i can assume based on other scripting/coding experience. I know there's probably answers to similar questions all over the place, but I've been trying literally hundreds of different pre-built forms guaranteed to work and solutions to others' problems, etc etc and not a single one has operated correctly for me. I can't really do anything with a "you should try this/that approach" answer, nor can I be assumed to know anything about php; I pretty much just need someone to fix whatever the problem is and paste it back to me as this is the only thing keeping me from launching the site. this is what prints when trying to submit with the dropdown on the default value: Quote Warning: mail() [function.mail]: SMTP server response: 451 See http://pobox.com/~djb/docs/smtplf.html. in D:\Hosting\5810110\html\contact\contact.php on line 32 There was an err0r processing your request. Please notify god@neurot1k.com & include details of what you did [wrong]. this prints when any item other than the default is selected in the dropdown: Quote Warning: mail() [function.mail]: SMTP server response: 451 See http://pobox.com/~djb/docs/smtplf.html. in D:\Hosting\5810110\html\contact\contact.php on line 32 Warning: mail() [function.mail]: SMTP server response: 554 The message was rejected because it contains prohibited virus or spam content in D:\Hosting\5810110\html\contact\contact.php on line 33 There was an err0r processing your request. Please notify god@neurot1k.com & include details of what you did [wrong]. http://email.about.com/cs/standards/a/smtp_error_code_2.htm specifically states to ignore both these errors, yet http://cr.yp.to/docs/smtplf.html specifically states that it's a fault of mine. here's the html: Code: [Select] <div id="formHolder"> <form method="post" action="contact.php"> <table class="contactTable" align="center"> <tr> <td> Subject: </td> <td> <select name="sendto"> <option value="bs from N1K.com">General Inquiry</option> <option value="JOB OFFER">Design Contract</option> <option value="PURCHASE ORDER">Purchase Order/Offer</option> </select> </td> </tr> <tr> <td><font color=red>*</font>Name:</td> <td><input size=25 name="Name"></td> </tr> <tr> <td><font color=red>*</font>Email:</td> <td><input size=25 name="Email"></td> </tr> <tr> <td>Company:</td> <td><input size=25 name="Company"></td> </tr> <tr> <td>Phone:</td> <td><input size=25 name="Phone"></td> </tr> <tr> <td>Subscribe to<br> mailing list: </td> <td><input type="radio" name="list" value="No"> Pf, nothx.<br> <input type="radio" name="list" value="Yes" checked> H3X Y34!<br> </td> </tr> <tr> <td colspan=2>Message:</td> </tr> <tr> <td colspan=2 align=center> <textarea name="Message" rows=5 cols=35></textarea> </td> </tr> <tr> <td colspan=2 align=center> <input type=submit name="send" value="Submit"> </td> </tr> </table> </form> </div><!-- END formHolder --> and here's the php: <?php $to = "god@neurot1k.com" ; $from = $_REQUEST['Email'] ; $name = $_REQUEST['Name'] ; $headers = "From: $from"; $subject = $_REQUEST['sendto'] ; $fields = array(); $fields{"Name"} = "Name"; $fields{"Company"} = "Company"; $fields{"Email"} = "Email"; $fields{"Phone"} = "Phone"; $fields{"list"} = "Mailing List"; $fields{"Message"} = "Message"; $body = "I have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); } $headers2 = "From: god@neurot1k.com"; $subject2 = "autoconfirm from neurot1k.com"; $autoreply = "Thanks for the contact, I'll get back to you as soon as possible, usually within 48 hours. If you have any more questions, please try me on AIM: ycleptCrux"; if($from == '') { print "You have not entered an email, please go back and try again"; } else { if($name == '') { print "You have not entered a name, please go back and try again"; } else { $send = mail($to, $subject, $body, $headers); $send2 = mail($from, $subject2, $autoreply, $headers2); if($send) { print "Thanks, I'll get back to you as soon as possible."; } else { print "There was an err0r processing your request. Please notify god@neurot1k.com & include details of what you did [wrong]."; } } } ?> the form was copy/pasted from http://php.about.com/od/phpapplications/ss/form_mail.htm and then respective variables were changed (email address, dropdown fields, etc). I didn't think it'd be SUCH a problem to copy/paste a pre-written block of code from About.com... HUGE thanks in advance to anyone willing to helo. On all my forms, after I send an empty string to one field, it will stop accepting values when I resubmit. My code passes through the W3C validator Any ideas?? Hello there, I am working on a script that will take a user submitted text and display the text in rainbow. I found a very nice function on the Internet and used it as my base. Here is an example of the code. Code: [Select] function rainbow($text) { /*** initialize the return string ***/ $ret = ''; /*** an array of colors ***/ $colors = array( 'ff00ff', 'ff00cc', 'ff0099', 'ff0066', 'ff0033', 'ff0000', 'ff3300', 'ff6600', 'ff9900', 'ffcc00', 'ffff00', 'ccff00', '99ff00', '66ff00', '33ff00', '00ff00', '00ff33', '00ff66', '00ff99', '00ffcc', '00ffff', '00ccff', '0099ff', '0066ff', '0033ff', '0000ff', '3300ff', '6600ff', '9900ff', 'cc00ff'); /*** a counter ***/ $i = 0; /*** get the length of the text ***/ $textlength = strlen($text); /*** loop over the text ***/ while($i<=$textlength) { /*** loop through the colors ***/ foreach($colors as $value) { if ($text[$i] != "") { $ret .= '<span style="color:#'.$value.';">'.$text[$i]."</span>"; } $i++; } } /*** return the highlighted string ***/ return $ret; } $post[message] = rainbow($post[message]); And it works very well Here is my problem. At times $post[message] will contain some basic html such as a bold tag, user smiley (img tag), a link tag, and so forth. How can I take my function above so that it doesn't edit and add the html font color coding for anything inside html tags where it just skips over them and leaves that part alone? I need this otherwise it will breakup every html tag I might have inside $post[message] and add a font color html tag to it, thus voiding all other html in it. I have an email form that is sending to an email address. There are five fields where the person sending can input their Name, Address, City, State, and Zip. Everything is working, except I want the input from these fields to be the the headers in the PHP email. For instance it submits and send the letter, but I want the senders Name, Address, City, State, and Zip to be posted after the "Sincerely" in the letter sent. Here is what the input boxes of the form looks like: Code: [Select] <p>Sincerely,<br /> <label for="from">Name:</label> <input type="text" name="from" id="name" value="<?php echo $_POST['from'];?>"/><br /> <label for="street">Street:</label> <input type="text" name="street" id="street" value="<?php echo $_POST['street'];?>"/><br /> <label for="city">City:</label> <input type="text" name="city" id="city" value="<?php echo $_POST['city'];?>"/><br /> <label for="zip">Zip:</label> <input type="text" name="zip" id="zip" value="<?php echo $_POST['zip'];?>"/><br /> <label for="email">E-mail:</label> <input type="text" name="email" id="email" value="<?php echo $_POST['email'];?>"/></p> <input type="submit" class="button" value="Submit" /> How do I go about posting the PHP headers in the email upon submission? I have been working on my local machine and haven't had any errors. I just deployed my site live and I'm getting a database error in my auto-complete text box. Any help would be much appreciated! I'm thinking there may be an error in my the way I'm naming the mysql connect names, but the fact that database data is being populated is confusing me. Wondering if something is wrong with the code? Thanks for the help in advance! These are the errors: Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/content/99/7862599/html/gadgetabulous/Database/filename.php on line 3 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/content/99/7862599/html/gadgetabulous/Database/filename.php on line 3 (here is a link if you want to see the error: http://gadgetabulous.com/cellphoneform.php(just type "iphone" in the search box and the error will appear)) Here is my db file: Code: [Select] <?php $q=$_GET['q']; $my_data=mysql_real_escape_string($q); $mysqli=mysqli_connect('host','root','password','dbname') or die("Database Error"); $sql="SELECT name FROM cell_brands WHERE name LIKE '%$my_data%' ORDER BY name"; $result = mysqli_query($mysqli,$sql) or die(mysqli_error()); if($result) { while($row=mysqli_fetch_array($result)) { echo $row['name']."\n"; } } mysql_close($mysqli); ?> Thank you in advance for the help! What I am looking for is that if any field in a database is empty, the form comes back and puts in the word "empty" into the web page, but not the database. I got this right now, it shows the first part fine, but the second part it doesn't show the "Empty" comment... I don't understand why... as far as I can tell the code is fine... Code: [Select] <?php //Nonconformity, Disposition, Comments and Comments & Additional Details echo '<div id="box3">'; if (!empty($row['Nonconformity']) || !empty($row['Disposition']) || !empty($row['Comments']) || !empty($row['CommentsAdditional_Details'])) { echo '<div id="non"><span class="b">Nonconformity: </span><br />' . $row['Nonconformity'] . '</div>'; echo '<div id="dis"><span class="b">Disposition: </span><br />' . $row['Disposition'] . '</div>'; echo '<div id="comm"><span class="b">Comments: </span><br />' . $row['Comments'] . '</div>'; echo '<div id="comma"><span class="b">Comments and/or Additional Details: </span><br />' . $row['CommentsAdditional_Details'] . '</div>';} else if (empty($row['Nonconformity']) || empty($row['Disposition']) || empty($row['Comments']) || empty($row['CommentsAdditional_Details'])) { echo '<div id="non"><span class="b">Nonconformity: </span><br />Empty</div>'; echo '<div id="dis"><span class="b">Disposition: <br /></span>Empty</div>'; echo '<div id="comm"><span class="b">Comments: <br /></span>Empty</div>'; echo '<div id="comma"><span class="b">Comments and/or Additional Details: </span><br />Empty</div>';} echo '</div>'; ?> |