Jump to content

Search the Community

Showing results for tags 'validation'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. HI i have following file which look for License file and do encryption and decryption of contents then if matches it forward the DB queries . I want to bypass the license check but keep the functionality as it is . I am not php expert please help <?php class FreeSwitch { public $request = array( ); public $cdr_variable = array( ); public $auth_arry = array( ); public $cdrlogdata = NULL; public $flag = 0; public $fh = NULL; public $fhquery = NULL; public $lstr = NULL; public $xmldata = NULL; public $return_array = array( ); public $mac_addr = NULL; public $auth_key = "2513^%edpceswitchv#@)KHGTRESBGFCD(NH^%#@\$%^&*N{}IU?\\|!@gh!12412ast8765%432133df121212x1as21%#&*#&jdh1asa!kdgakjakssjdhshmhsyw092)8@#!@)*9&&%^-+\$#2fyFADhdjshdijs"; public function GetAddress($os_type) { switch( strtolower($os_type) ) { case "linux": $this->forLinux(); break; case "solaris": break; case "unix": break; case "aix": break; default: $this->forWindows(); break; } $temp_array = array( ); foreach( $this->return_array as $value ) { if( preg_match("/[0-9a-f][0-9a-f][:-]" . "[0-9a-f][0-9a-f][:-]" . "[0-9a-f][0-9a-f][:-]" . "[0-9a-f][0-9a-f][:-]" . "[0-9a-f][0-9a-f][:-]" . "[0-9a-f][0-9a-f]/i", $value, $temp_array) ) { $this->mac_addr[] = $temp_array[0]; } } unset($temp_array); return $this->mac_addr; } public function encrypt($string) { $result = ""; for( $i = 0; $i < strlen($string); $i++ ) { $char = substr($string, $i, 1); $keychar = substr($this->auth_key, $i % strlen($this->auth_key) - 1, 1); $char = chr(ord($char) + ord($keychar)); $result .= $char; } return base64_encode($result); } public function decrypt($string) { $result = ""; $string = base64_decode($string); for( $i = 0; $i < strlen($string); $i++ ) { $char = substr($string, $i, 1); $keychar = substr($this->auth_key, $i % strlen($this->auth_key) - 1, 1); $char = chr(ord($char) - ord($keychar)); $result .= $char; } return $result; } public function forWindows() { @exec("ipconfig /all", $this->return_array); if( $this->return_array ) { return $this->return_array; } $ipconfig = $_SERVER["WINDIR"] . "system32ipconfig.exe"; if( is_file($ipconfig) ) { @exec($ipconfig . " /all", $this->return_array); } else { @exec($_SERVER["WINDIR"] . "systemipconfig.exe /all", $this->return_array); } return $this->return_array; } public function forLinux() { @exec("ifconfig ", $this->return_array); return $this->return_array; } public function manageKey() { $this->writelog($this->request["hostmac"]); if( file_exists("license") ) { $dump_linfo = file("license"); $response = json_decode($this->decrypt($dump_linfo[0])); $this->GetAddress(PHP_OS); foreach( $response as $value ) { $linfo[] = trim($value); } $dt = date("Ymd"); if( $linfo[2] <= $dt ) { return 0; } if( $linfo[3] == "00:00:00:00:00:00" ) { return 0; } if( in_array($linfo[3], $this->mac_addr) ) { $reg = $this->getRegNum(); if( $reg < $linfo[0] ) { return 1; } return 0; } } return 0; } public function dialplanstatus() { $this->writelog($this->request["hostmac"]); if( file_exists("license") ) { $dump_linfo = file("license"); $response = json_decode($this->decrypt($dump_linfo[0])); $this->GetAddress(PHP_OS); foreach( $response as $value ) { $linfo[] = trim($value); } $dt = date("Ymd"); if( $linfo[2] <= $dt ) { return 0; } if( $linfo[3] == "00:00:00:00:00:00" ) { return 0; } if( in_array($linfo[3], $this->mac_addr) ) { $calls = $this->runningcall(); if( $calls < $linfo[1] ) { return 1; } return 0; } } return 0; } public function runningcall() { $value = 0; $query = sprintf("SELECT count( DISTINCT uuid) FROM `live_activecall`"); $this->db->query($query); $rs = $this->db->resultset(); foreach( $rs[0] as $key => $value ) { return $value; } return $value; } public function logfile_open() { $this->fh = fopen(LOGFILE, "a"); } public function logfile_openquery() { $this->fhquery = fopen(QUERYLOGFILE, "a"); } public function writelogquey($log) { $log = $log . "\n"; fwrite($this->fhquery, $log); } public function writelog($log) { date_default_timezone_set("Asia/Kolkata"); $datestr = date("M d H:i:s"); $log = "" . $datestr . " :: " . $log . "\n"; fwrite($this->fh, $log); } public function set_requestdata($_REQUEST) { $this->xmldata = serialize($_REQUEST); foreach( $_REQUEST as $key => $value ) { $this->lstr .= "" . "[" . $key . " : " . urldecode($value) . ]"; $this->request[$key] = mysql_real_escape_string(trim(urldecode($value))); } } public function set_flag() { $this->flag = 1; } public function reset_flag() { $this->flag = 0; } public function blank_responce() { $this->responce = "<?xml version=\"1.0\"?>\n <document type=\"freeswitch/xml\">\n <section name=\"dialplan\" description=\"Regex/XML Dialplan\">\n <context name=\"default\"> \n <action application=\"info\"/>\n <action application=\"respond\" data=\"503\"/>\n <action application=\"hangup\"/>\n </context>\n </section>\n </document>"; } public function get_cdrvariable($str) { $str = json_decode(json_encode((array) simplexml_load_string($str)), 1); $this->xmldata = serialize($str); foreach( $str as $key => $value ) { if( $key == "variables" && is_array($value) ) { foreach( $value as $key1 => $value1 ) { $this->cdr_variable[$key1] = mysql_real_escape_string(trim(urldecode($value1))); $this->cdrlogdata .= "" . "[" . $key1 . " : " . urldecode($value1) . "]"; $this->cdrlogdata1 .= "" . $key1 . " : " . urldecode($value1) . "\n"; } } } } public function minute_calculation($rate, $inittine, $credit) { $this->timeout = intVal($credit / $rate); } public function getRegNum() { $value = 0; $query = sprintf("SELECT count(registrations.reg_user) FROM `registrations`"); $this->db->query($query); $rs = $this->db->resultset(); foreach( $rs[0] as $key => $value ) { return $value; } return $value; } } ?>
  2. <?php /* Template Name: Warranty New */ //Include the database class require("report/db.class1.php"); ?> <script type="text/javascript" src="/addjs/jquery_003.js"></script> <script type="text/javascript" src="/addjs/chainedselects.js"></script> <script type="text/javascript" src="/addjs/contentwarranty.js"></script> <link rel="stylesheet" href="/Reports/warranty.css" type="text/css" media="screen" /> <script src="http://code.jquery.com/jquery-1.10.2.js"></script> <script src="http://code.jquery.com/jquery-1.10.2.min.js"></script> <script type='text/javascript' src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <link rel="stylesheet" href="http://code.jquery.com/ui/1.9.0/themes/base/jquery-ui.css" /> <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script> <script src="/Reports/jquery.validate.js"></script> <script src="http://jquery.bassistance.de/validate/additional-methods.js"></script> <script type="text/javascript"> $(function() { var scntDiv = $('#p_scents'); var i = $('#p_scents div').size() + 1; $('#addScnt').on('click', function() { if ($('input#wproserial[]'+(i-1)).val() != '') { $('<table class="multiple-rows" ><tr class="prod-row prod-row"><td><input type="text" name="wwarrantycard[]'+i+'" id="wwarrantycard'+i+'" class="textinput2 required" autocomplete="off" value=""/></td><td><select class="selectbox " id="maker'+i+'" name="makes[]'+i+'"></select></td><td><select name="types[]'+i+'" id="typer'+i+'" class="selectbox "></select></td><td><select name="models[]'+i+'" id="modelr'+i+'" class="selectbox " ></select></td><td><input name="wproserial[]'+i+'" id="wproserial'+i+'" type="text" value="" class="textinput3"></td><td width="20px" style="text-align:center"><a href="javascript:void(0);" id="remScnt'+i+'" class="remScnt">X</a></td></tr></table>').appendTo(scntDiv); } else { alert('Enter your product first!'); $('input#wproserial[]'+(i-1)).focus(); } var1="maker"+i; var1_1=document.getElementById(var1); var2="typer"+i; var2_1=document.getElementById(var2); var3="modelr"+i; var3_1=document.getElementById(var3); initListGroup('vehicles', var1_1, var2_1, var3_1, 'cs'); document.getElementById(var1).selectedIndex=""; document.getElementById(var2).selectedIndex="" document.getElementById(var3).selectedIndex="" i++; return false; }); $('#p_scents').on('click', '.remScnt', function() { if (i > 1) { $(this).parents('table').remove(); i--; } return false; }); }); </script> <script type="text/javascript"> $(function() { $( "#wdatepurchase" ).datepicker({ dateFormat: 'dd-mm-yy', }); $( "#wdob" ).datepicker({ dateFormat: 'dd-mm-yy', changeMonth: true, changeYear: true, yearRange: "1950:2003", onSelect: function() { $( "#datepicker" ).trigger('blur'); } }); }); $(document).ready(function() { $.validator.addMethod("dateRule", function(value, element) { return value.match(/^(0[1-9]|[12][0-9]|3[01])[- //.](0[1-9]|1[012])[- //.](19|20)\d\d$/); }, "Please enter a date in the format dd/mm/yyyy" ); $('form.warregform').on('submit', function(event) { // adding rules for inputs with class 'first' $('#wfirstname').each(function() { $(this).rules("add", { required: true, minlength: 3, messages: { required: "Type your first name!", minlength: jQuery.format("Please, at least {0} character are necessary!") } }) }); // adding rules for inputs with class 'last' $('#wlastname').each(function() { $(this).rules("add", { required: true, minlength: 3, messages: { required: "Type your last name!", minlength: jQuery.format("Please, at least {0} character are necessary!") } }) }); // adding rules for inputs with class 'last' $('#wyourphone').each(function() { $(this).rules("add", { required: true, number: true, minlength: 9, messages: { required: "Type you contact number! (eg. 015679322)!", minlength: jQuery.format("Please, at least {0} number are necessary!") } }) }); // adding rules for inputs with class 'last' $('#wdatepurchase').each(function() { $(this).rules("add", { required: true, minlength: 10, dateRule: true, messages: { required: "Insert your Purchase Date (dd-mm-yyyy)!", date: "Please enter a valid date.", minlength: jQuery.format("Please, at least {0} are necessary!") } }) }); // adding rules for inputs with class 'comment' $('input.textinput2').each(function() { $(this).rules("add", { required: true, number: true, minlength: 3, messages: { required: "Type warranty cards number!", minlength: jQuery.format("Please, at least {0} number are necessary") } }) }); // adding rules for inputs with class 'comment' $('select.selectbox').each(function() { $(this).rules("add", { required: true, messages: { required: "", } }) }); // adding rules for inputs with class 'comment' $('input.textinput3').each(function() { $(this).rules("add", { required: true, minlength: 3, remote: "report/user_check.php", messages: { required: "Type Serial number!", minlength: jQuery.format("Please, at least {0} character are necessary"), remote: jQuery.format("{0} is already taken"), // remote: 'This email address has already been used' } }) }); // adding rules for inputs with class 'last' $('#wshoplocation').each(function() { $(this).rules("add", { required: true, messages: { required: "Choose Shop Location!", } }) }); // test if form is valid if($('form.warregform').validate().form()) { console.log("validates"); } else { console.log("does not validate"); } }) // initialize the validator $('form.warregform').validate(); }); </script> <?php $hasErrors = false; //If form was submitted if (isset($_POST['btnSubmit'])) { for ( $i=0;$i<count($_POST['wwarrantycard']);$i++) { { $wwarrantycard = $_POST['wwarrantycard'][$i]; $makes = $_POST['makes'][$i]; $types = $_POST['types'][$i]; $models = $_POST['models'][$i]; $wproserial = $_POST['wproserial'][$i]; } } if(empty($_POST['wfirstname'])){ $nameErr = "With more than 3 letters!"; $hasErrors = true; }if(empty($_POST['wlastname'])){ $nameErr = "With more than 3 letters!"; $hasErrors = true; }else if (empty($_POST['wyourphone'])){ $phoneErr = "With more than 7 Numeric! (eg. 015679322)"; $hasErrors = true; }else if(strlen($_POST['wyourphone']) <= 7){ $phoneEErr = "With more than 7 Numeric! (eg. 015679322)"; $hasErrors = true; }else if (empty($wwarrantycard)){ $wcardErr = "Missing insert product after you click add more product. Please insert and try again!!!"; $hasErrors = true; }else if (empty($makes)){ $wcardErr = "Missing insert product after you click add more product. Please insert and try again!!!"; $hasErrors = true; }else if (empty($types)){ $wcardErr = "Missing insert product after you click add more product. Please insert and try again!!!"; $hasErrors = true; }else if (empty($wproserial)){ $wcardErr = "Missing insert product after you click add more product. Please insert and try again!!!"; $hasErrors = true; }else if (empty($_POST['wshoplocation'])){ $shopErr = "Please Select Shop Location."; $hasErrors = true; } else{ } } ?> <?php if (!isset($_POST['btnSubmit']) || $hasErrors) { ?> <body onLoad="initListGroup('vehicles', document.warrantyform.maker, document.warrantyform.typer, document.warrantyform.modelr, 'cs'); resetListGroup('vehicles');" > <div class="divider"></div> <div class="clear"></div> <form name="warrantyform" id="warrantyform" class="warregform" enctype="multipart/form-data" autocomplete="OFF" method="post"> <div class="warrleft"> <label class="labeln"><strong>First Name: * </strong> <span id="nameInfo"></span></label> <label for="wfirstname" class="error"></label> <input class="textinput " type="text" name="wfirstname" id="wfirstname" size="30" maxlength="60" value="" autocomplete="off"/> </div> <div class="warrleft"> <label class="labeln"><strong>Last Name: * </strong> <span id="nameInfo"></span></label> <label for="wlastname" class="error"></label> <input class="textinput " type="text" name="wlastname" id="wlastname" size="30" maxlength="60" value="" autocomplete="off"/> </div> <div class="clear"></div> <div class="warrleft"> <label class="labeln"><strong>Your Email: </strong> <span id="emailInfo">NOTE: Warranty confirmation will be sent to your email address</span></label> <input class="textinput " type="text" name="wyouremail" id="wyouremail" size="30" maxlength="60" value="" autocomplete="off"/> </div> <div class="warrleft"> <label class="labeln"><strong>Contact Number: * </strong> <span id="wcontactInfo"></span></label> <label for="wyourphone" class="error"></label> <input class="textinput " type="text" name="wyourphone" id="wyourphone" size="30" maxlength="60" value="" autocomplete="off"/> </div> <div class="clear"></div> <div class="warrleft"> <label class="labeln"><strong>Gender: </strong></label><br/> <select name="wgender" id="wgender" > <option value="Male">Male</option> <option value="Female">Female</option> </select> </div> <div class="warrleft"> <label class="labeln"><strong>Date Of Birth: </strong></label><br/> <input class="textinput " type="text" name="wdob" id="wdob" size="30" maxlength="60" value="" autocomplete="off" readonly/> </div> <div class="clear"></div> <div class="warrleft"> <label class="labeln"><strong>Company Name: </strong></label><br/> <input type="text" maxlength="100" value="" name="wcompanyname" id="wcompanyname" class="textinput" autocomplete="off"> </div> <div class="warrleft"> <label class="labeln"><strong>Job Title: </strong></label><br/> <input type="text" maxlength="100" value="" name="wjobtitle" id="wjobtitle" class="textinput" autocomplete="off"> </div> <?php $todays_date = date("d-m-Y"); ?> <div class="warrleft"> <label class="labeln"><strong>Date of Purchase: * </strong></label> <label for="wdatepurchase" class="error"></label> <input type="text" maxlength="100" value="<?php echo $todays_date; ?>" name="wdatepurchase" id="wdatepurchase" class="textinput" autocomplete="off"> </div> <div class="clear"></div> <span id="wcardInfo"></span> <table class="multiple-rows" > <tr class="prod-row2"> <td><label><strong>Warranty Card No: *</strong> </label></td> <td><label><strong>Product Category *</strong></label></td> <td><label><strong>Sub Category *</strong></label></td> <td><label><strong>Model Name *</strong></label></td> <td><label><strong>Serial Number *</strong></label></td> <td width="20px"> </td> </tr> <tr class="prod-row prod-row"> <td><input type="text" name="wwarrantycard[]" id="wwarrantycard0" value="" class="textinput2 " autocomplete="off"/></td> <td><select name="makes[]" id="maker" class="selectbox "></select></td> <td><select name="types[]" id="typer" class="selectbox "></select></td> <td><select name="models[]" id="modelr" class="selectbox "></select></td> <td><input name="wproserial[]" id="wproserial0" type="text" value="" class="textinput3 " autocomplete="off"></td> <td> </td> </tr> </table> <div id="p_scents"></div> <div class="addproducts"><a href="javascript:void(0);" id="addScnt">Add another product</a></div> <div class="clear"></div> <div class="warrleft"> <label class="labeln"><strong>Shop Location: * </strong><span id="wshopInfo"></span></label> <label for="wshoplocation" class="error"></label> <select name="wshoplocation" id="wshoplocation" > <option value="">Select Shop</option> <option value="I-Qlick">I-Qlick</option> <option value="CS_KTH">CS_KTH</option> <option value="CS_Ahhoo">CS_Ahhoo</option> <option value="CS_Sunsimexco">CS_Sunsimexco</option> <option value="Other">Other</option> </select> </div> <div class="warrleft"> <label class="labeln"><strong>Rate Shop Service:</strong></label> <select class="" name="wrate" id="wrate"> <option value="Very Good">Very Good</option> <option value="Good">Good</option> <option value="Normal">Normal</option> <option value="Bad">Bad</option> </select> </div> <div class="clear"></div> <div class="warrleft"> <input type="checkbox" name="wpromo" id="wpromo" value="Yes" /> <strong>I want to receive i-Qlick's promotions by email.</strong></p> </div> <div class="clear"></div> <div class="warrleft"> <input id="go" name="btnSubmit" type="submit" value="Submit" class="btn"/> <!--<input id="go" name="btnSubmit" type="submit" value="Submit" class="btn" onClick="targetGroup('textinput2');"/>--> <input type="reset" value="Reset" onClick="resetListGroup('vehicles')" > </div> </form> <!--<script type="text/javascript" src="<php bloginfo( 'url' ); ?>/Reports/validation.js"></script>--> <?php } ?> above is My Html Files... I can't check validation with existing database, this serial no. is already register or not. every input data is showing message "is already taken". so i can't submit. My Serial no input field is unlimited. user_check.php <?php include("db.class1.php"); if (isset($_POST['wproserial'])) { //create instance of database class $db = new mysqldb(); $db->select_db(); for ( $i=0;$i<count($_POST['wproserial']);$i++) { { $wproserial = $_POST['wproserial'][$i]; } } //$query = "SELECT * FROM products WHERE SerailNo"; //$query = "SELECT * FROM products WHERE SerailNo='".$wproserial."'"; //$query = "SELECT * FROM products WHERE SerailNo='$wproserial'"; $query = "SELECT * FROM `products` WHERE `SerailNo` = '".mysql_real_escape_string($wproserial)."'"; //$query = "SELECT EXISTS (SELECT * FROM products WHERE SerailNo='".mysql_real_escape_string($wproserial)."')"; if($db->num_rows($db->query($query)) < 1) { /*return true; }else { return false; } */ $valid = 'true'; }else { $valid = 'false'; } echo json_encode($valid); } ?>
  3. Hi! I read that for security reasons, the ideal is that the form data is validated two times ever. The first on the client side with javascript code and a second time on the server side with PHP code. The validation with javascript I have (almost) ready. However, I'm having problems with PHP validation ... <html> <head> <title>Formulario</title> <script type="text/javascript"> function frmRegisterValidate (){ var frmRegisterError = document.getElementById("frmRegisterError"); var frmRegisterUN = document.getElementById("frmRegisterUN").value; var frmRegisterPW = document.getElementById("frmRegisterPW").value; if (frmRegisterUN == "") { frmRegisterError.value = "Type your username"; return false; } else if (frmRegisterPW == "") { frmRegisterError.value = "Type your password"; return false; } document.getElementById("frmRegister").submit(); } </script> </head> <body> <form method="post" action="frmRegister.php" id="frmRegister" name="frmRegister" accept-charset="utf-8"> <label>Nombre de usuario: </label> <input type="text" id="frmRegisterUN" value="" name="frmRegisterUN" /> <br /> <label>Informe una contrasena: </label> <input type="text" value="" id="frmRegisterPW" name="frmRegisterPW"> <br /> <label>Se encontro un error: </label> <input type="text" value="" id="frmRegisterError" name="frmRegisterError"/> <br /> <input type="button" value="REGISTER" id="frmRegister_Button" onClick="frmRegisterValidate ()"/> </form> </body> </html> <?php if (!empty ($_POST['frmRegisterUN'])) { $frmRegisterUN = $_POST['frmRegisterUN']; } else { $frmRegisterUN = NULL; echo "Type your username <br />"; } if (!empty ($_POST['frmRegisterPW'])) { $frmRegisterPW = $_POST['frmRegisterPW']; } else { $frmRegisterPW = NULL; echo "Type your password <br />"; } ?> This is a very simplified version of the form that I am developing. As you can see, I can do data validation in both javascript and PHP ... My question is: with the PHP code, how should I do so that the error message is displayed in the value of the input called frmRegisterError equal to that done with javascript?
  4. is there a way we can count the number of link enter in fckeditor while form submission and if number of links exceeds 3, it shows a popup window. thanks and regards, jass.
  5. Hi! I need help! No other forum is helping me and it's a bit urgent. I have searched all over the internet and tried over 30 different codes but I can't get this to work. Im very new to php and that probably why. What I want help with: 1. I want my form to be validated server side. When the name or message field is left empty a errormessage(please fill in name, please fill in message) should be shown above the form on the SAME page without reloading or redirecting. 2. Check so that the email entered in the email field is a valid email and not just filled out. 3. If everything is filled out correctly the form should be sent and a message is displayed above the form just like the error-messages for the fields. Php: <?php $name = $_POST['name']; $email = $_POST['email']; $phone = $_POST['phone']; $message = $_POST['message']; $recipient = "info@mydomain.com"; $subject = "Via Webbkontakt"; $formcontent = "Namn: $name <br/> Email: $email <br/> Telefon: $phone <br/><br/> Meddelande:<br/><br/> $message"; $headers = "From: " ."MyDomain<info@mydomain.com>" . "\r\n"; $headers .= "Reply-To: ". "$email" . "\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=utf-8\r\n"; if(@mail($recipient, $subject, $formcontent, $headers)) { echo "successful"; } else { echo "error"; } ?> Html: <form class="form" id="contactus" action="php/mail.php" method="post" accept-charset="UTF-8"> <label for="nametag">Namn<FONT COLOR="#FF0060">*</FONT></label> <input name="name" value="" type="text" id="name"> <label for="emailtag">Email<FONT COLOR="#FF0060">*</FONT></label> <input name="email" value="" type="text" id="email"> <label for="phonetag">Telefon</label> <input name="phone" type="text" id="phone" value="" /> <label for="messagetag">Meddelande<FONT COLOR="#FF0060">*</FONT></label> <textarea name="message" id="message" value="" style="width: 87%; height: 200px;"></textarea> <label class="placeholder"> </label> <button class="submit" name="submit">Skicka</button> </form>
  6. I'm trying to create a field that will validation US phone numbers, and afterwards I will be attempting a field to validate income. So far, for the phone numbers, I have implemented the following regex expression and PHP. The regex has worked in someone elses implementation, however when I utilize it in this implementation it always returns an error that the phone number isn't valid. I'm having a difficult time seeing where the difficulty is: //1. Add a new form element... add_action('register_form','myplugin_register_form2'); function myplugin_register_form2 (){ $phone_number = ( isset( $_POST['phone_number'] ) ) ? $_POST['phone_number']: ''; ?> <p id="phone_number"> <label for="phone_number"><?php _e('Phone Number <font size="1">(XXX XXX XXXX)</font>','mydomain') ?><br /> <input type="text" name="phone_number" id="phone_number" class="input" size="25" style="text-align:right" maxlength="14" /> </p> <?php } //2. Add validation. In this case, we make sure phone_number is required. add_filter('registration_errors', 'myplugin_registration_errors2', 10, 3); function myplugin_registration_errors2 ($errors, $sanitized_user_login, $user_email) { $sPattern = "/^ (?: # Area Code (?: \( # Open Parentheses (?=\d{3}\)) # Lookahead. Only if we have 3 digits and a closing parentheses )? (\d{3}) # 3 Digit area code (?: (?<=\(\d{3}) # Closing Parentheses. Lookbehind. \) # Only if we have an open parentheses and 3 digits )? [\s.\/-]? # Optional Space Delimeter )? (\d{3}) # 3 Digits [\s\.\/-]? # Optional Space Delimeter (\d{4})\s? # 4 Digits and an Optional following Space (?: # Extension (?: # Lets look for some variation of 'extension' (?: (?:e|x|ex|ext)\.? # First, abbreviations, with an optional following period | extension # Now just the whole word ) \s? # Optionsal Following Space ) (?=\d+) # This is the Lookahead. Only accept that previous section IF it's followed by some digits. (\d+) # Now grab the actual digits (the lookahead doesn't grab them) )? # The Extension is Optional $/x"; // /x modifier allows the expanded and commented regex $aNumbers = array( '123-456-7890x123', '123.456.7890x123', '123 456 7890 x123', '(123) 456-7890 x123', '123.456.7890x.123', '123.456.7890 ext. 123', '123.456.7890 extension 123456', '123 456 7890', '123-456-7890ex123', '123.456.7890 ex123', '123 456 7890 ext123', '456-7890', '456 7890', '456 7890 x123', '1234567890', '() 456 7890' ); foreach($aNumbers as $sNumber) { if (!preg_match($sPattern, $phone_number, $aMatches)) { $errors->add( 'phone_number_error', __('<strong>ERROR</strong>: You must include a valid phone number.','mydomain') ); return $errors; } } if ( empty( $_POST['phone_number'] ) ) $errors->add( 'phone_number_error', __('<strong>ERROR</strong>: You must include a valid phone number.','mydomain') ); return $errors; } //3. Finally, save our extra registration user meta. add_action('user_register', 'myplugin_user_register2'); function myplugin_user_register2 ($user_id) { if ( isset( $_POST['phone_number'] ) ) update_user_meta($user_id, 'phone_number', $_POST['phone_number']); }
  7. Hi, I'm trying to make some kind of validation for my form but I've tried everything from Javascript to PHP and I can't seem to get it to work? I'll put my javascript code below but I would much rather use PHP as the validator as I don't like using alert boxes. The problem is that it's validating at all and any method that I try it just skips it and carrys on with the registration. For example I put "dd" as my username, email and password and it accepted it. Help would be much appreciated, thanks. The Javascript: <script type="text/javascript"> function validateForm(formElement) { if(formElement.username.length < 5) { alert('Username must be more than 5 characters.'); return false; } if(formElement.email.length < 5) { alert('Email must be more than 5 characters.'); return false; } if(formElement.password.length < { alert('Password should be more than 8 characters.'); return false; } } </script> The Form: <div id="register-section-wrapper"> <div id="inner-register-container"> <form action="" method="post" name="register_form" id="register_form" onsubmit="return validateForm(this);"> <table border="0" id="table-register"> <th colspan="2"> <h1>Register</h1> </th> <tr> <td> <p>Username:</p> </td> <td> <input type="text" name="username" id="username" class="frm-style" required /> </td> </tr> <tr> <td> <p>Email:</p> </td> <td> <input type="text" name="email" id="email" class="frm-style" required /> </td> </tr> <tr> <td> <p>Password:</p> </td> <td> <input type="password" name="password"id="password" class="frm-style" required /> </td> </tr> <tr> <td> <p>Retype Password:</p> </td> <td> <input type="password" name="cpassword" class="frm-style" required /> </td> </tr> <tr> <th colspan="2"> <input class="frm-submit-register" name="register" type="submit" value="Submit" onclick="return validateForm(this.form);" /> <th> </tr> </table> </form> The OLD PHP Validation: <?php $error_msg = ""; if(isset($_POST['register'])) { if(empty($_POST['username'])) { $error_msg = "Please enter your username."; } else { return true; } if($_POST['username'] < 5) { $error_msg = "Username must be more than 5 characters."; } else { return true; } } ?>
  8. Hi there. I'm a beginner so hopefully someone can help me. Say I have a paypal button on my site, that after using it to pay, takes you to a page with a download link on it that allows you to download a file on my sites server. How can I make it so that people can't just bypass the payment process by typing in the url of the download link page? I've looked into PayPal IPN but I find it hard to understand the underlying code, and wonder if there's another way. Any actual coding examples would be gratefully appreciated.
  9. Hi everybody can someone help me to make an email validtion system in my code, and help me find a way to check if the username is taken, and if possible where i should put the code in, im new in this and i find it very hard Here is my registration site <?php session_start();session_destroy(); session_start(); if($_GET["Brugernavn"] && $_GET["Email"] && $_GET["Password1"] && $_GET["Password2"] ) //tjekker alle data { if($_GET["Password1"]==$_GET["Password2"]) //Her tjekker jeg at begge indtastede password er ens { $Server="localhost"; $Brugernavn="root"; $conn= mysql_connect($Server,$Brugernavn)or die(mysql_error()); mysql_select_db("test",$conn); //Her opretter jeg en forbindelse til databasen $sql="insert into Brugere (Brugernavn,Email,Password)values('$_GET[brugernavn]','$_GET[Email]','$_GET[Password1]')"; //Her indsætter jeg de indtastede værdier ind i tabellen i min database $result=mysql_query($sql,$conn) or die(mysql_error()); echo "<h1>Du er nu blevet registreret</h1>"; //Hvis alt passer kommer teksten "Du er nu osv." frem echo "<a href='Startside.php'>Gå til startside</a>"; //Hvis alt passer kommer der et link der sender brugeren til startsiden } else echo "Passwordende passer ikke sammen, prøv igen"; //Hvis passwordne ikke passer, udskriver jeg teksten "Passwordende passer osv." } else echo"Data er fucked"; ?>
  10. How to add country code if user doesn't enter the country code when they register? If user did enter the country code it will skip and store it into database, if user doesn't enter then system will add the country code and store to database. How can I do that?
  11. Hi, I have a page that was custom written by a developer some time ago, the page has an email entry text area which currently has some form of checking on it but as to how it works I do not know! The code is as follows :- //Add E-mail Address $sql6 = "SELECT email FROM carts WHERE cartid='".$cart."'"; $result6 = mysql_query($sql6); $emailaddress = ''; while ( $row6 = @mysql_fetch_array($result6, MYSQL_BOTH) ) { $addemail .= ' <form method="post" action="cart2.php" name="emailform"> '; $addemail .= ' E-mail Address: <input type="text" style="background:#cfc" "border-color": "#0c0" name="email" value="'.$row6['email'].'" size="19" /><input type="hidden" name="cartid" value="'.$cart.'" />'; if ( $emailerror != '' ) { $addemail .= '<img src="images/email_error.png" width="16" height="16" hspace="4" alt="E-mail Error" />'; } $addemail .= ' <input type="image" name="Add E-mail Address" alt="Add E-mail Address" src="images/confirmemail.gif" style="vertical-align:middle" /> </form> '; if ( $row6['email'] == '' ) { $emailpresent = 0; } else { $emailpresent = 1; } } $addemail .= ' </td> </tr> '; } ?> The text input box has a green background, if the email address is invalid the page reloads but an error image appears next to the text box. What I'd also like to do is if this happens change the colour of the text box. Is this possible? I'm not a programmer, just trying to get my way through this. Thanks for any help
  12. Hi there, I am having the following ad posting page. But i m really confused of applying a input validation. I just want to display error when there is any field which left unfilled. Error should be displayed near the field. In case of email i want to show whether the email is already available in the database or not. if available i will show available. if not available then i will show the same. All the validations should happen when i click submit button. If everything is filled, then the submit button should take me to next page. Can anyone help me with this. I m terrible in search for it. my code: <?php include("conndb.php"); function createoptions($table , $id , $field) { $sql = "select * from $table ORDER BY $field"; $res = mysql_query($sql) or die(mysql_error()); while ($a = mysql_fetch_assoc($res)) echo "<option value=\"{$a[$id]}\">$a[$field]</option>"; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Post a Free Ad</title> <link href="loginmodule.css" rel="stylesheet" type="text/css" /> <style> #entrydt1 { margin-left: 100px; } #orderid1 { margin-left: 107px; } #orderdt1 { margin-left: 94px; } #itemid { margin-left: 142px; } #qtyid { margin-left: 122px; } #packid { margin-left: 120px; } #qtynoid { margin-left: 80px; } #Poid { margin-left: 80px; } #resetid { margin-left: 80px; } #clearid { margin-left: 80px; } #Name { margin-left: 50px; width: 100px; } </style> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" charset="utf-8"> $(function(){ $("select#MRP").change(function(){ var qty = $('#subcat2').val(); var MRP = $('#MRP').val(); var t7 = $('#t7').val(); var total = (qty * (MRP*(t7/100))); $("#amount").val(total); }) }) $(function(){ $("select#category").change(function(){ $.getJSON("select.php",{category: $(this).val(), ajax: 'true'}, function(j){ var options = ''; for (var i = 0; i < j.length; i++) { options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>'; } $("select#subcategory").html(options); }) }) $("select#subcategory").change(function(){ $.getJSON("select.php",{subcategory: $(this).val(), ajax: 'true'}, function(j){ var options = ''; for (var i = 0; i < j.length; i++) { options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>'; //options = '<input type="text" id="subcat2" name="subcat2" value="' + j[i].optionDisplay + '" />'; } /*$("select#subcategory2").html(options);*/ }) }) }) $(function(){ $("select#category").change(function(){ $.getJSON("select.php",{category: $(this).val(), ajax: 'true'}, function(j){ var options = ''; for (var i = 0; i < j.length; i++) { options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>'; } $("select#subcategory").html(options); }) }) $("select#subcategory").change(function(){ $.getJSON("select.php",{subcategory: $(this).val(), ajax: 'true'}, function(j){ var options = ''; for (var i = 0; i < j.length; i++) { options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>'; //options = '<input type="text" id="subcat2" name="subcat2" value="' + j[i].optionDisplay + '" />'; } ("select#subcategory2").html(options); }) }) }) </script> </script> </head> <body> <h1>Post a Free Ad</h1> <form method="post" name="form" action="preview.php"> <table border='0'> <tr> <td><label for="name">Enter the name of the product or service you want</label></td> <td> <input type="text" name="ad" size=20 value=""/></td> </tr> <tr> <td> Select your Category</td> <td><select name="cat" id="category" style="width:11em;"> <option value="-1">--Select--</option> <?php createoptions("category", "cat_id", "category"); ?> </select> </td> </tr> <tr> <td> Select Subcategory </td> <td><select name="subcat" id="subcategory" style="width:11em;"> </select> </td> </tr> <tr> <td>Ad Type </td> <td><input type="radio" name="adtype" value="I Am Offering">I Am Offering <input type="radio" name="adtype" value="I Am Looking For">I Am Looking For </td> </tr> <tr> <td>Ad Title <font color="red">*</font></td> <td><input type="text" name="title" value="" style="width:15em;"></td> </tr> <tr> <td>Location<font color="red">*</font></td> <td><input type="text" name="location" value="" style="width:15em;"></td> </tr> <tr> <td>Addtional Details</td> <td><textarea name="info" rows="5" cols="50"></textarea></td> </tr> <tr> <td> <font face="arial" color="green" size="5"/> Verification Details here!! </td> </tr> <tr> <td>Email </td> <td><input type="text" name="email" value="" style="width:15em;" / > </td> </tr> <tr> <td>Mobile </td> <td><input type="text" name="mobile" value="" style="width:15em;" / > </td> </tr> <td> <input type="submit" name="submit" value="Preview Ur Ad"/></td> </tr> </table> <br /> <br /> </form> </body> </html>
  13. Dear all, I have having a text area field which has a limit of 100 characters only. Now, i also want to validate it such that it should only contain letter's (alphabet A-Z .a-z). It should not contain any number or @ symbol. If such things entered it should throw me an error saying invalid arguments like that. I know it can be done with regular expressions. But i m not aware of how to do. Can some one help with that. Here is my script. <script language="javascript" type="text/javascript"> function limitText(limitField, limitCount, limitNum) { if (limitField.value.length > limitNum) { limitField.value = limitField.value.substring(0, limitNum); } else { limitCount.value = limitNum - limitField.value.length; } } </script> <tr> <td valign="top" align="left">Description</td> <td valign="top">:</td> <td align="left"><textarea name="limitedtextarea" onkeydown="limitText(this.form.limitedtextarea,this.form.countdown,100);" onkeyup="limitText(this.form.limitedtextarea,this.form.countdown,100);"> </textarea><br> <font size="1">(Maximum characters: 100)<br> You have <input readonly type="text" name="countdown" size="3" value="100"> characters left.</font></td> </tr>
  14. Dear all, I have having a text area field which has a limit of 100 characters only. Now, i also want to validate it such that it should only contain letter's (alphabet A-Z .a-z). It should not contain any number or @ symbol. If such things entered it should throw me an error saying invalid arguments like that. I know it can be done with regular expressions. But i m not aware of how to do. Can some one help with that. Here is my script. <script language="javascript" type="text/javascript"> function limitText(limitField, limitCount, limitNum) { if (limitField.value.length > limitNum) { limitField.value = limitField.value.substring(0, limitNum); } else { limitCount.value = limitNum - limitField.value.length; } } </script> <tr> <td valign="top" align="left">Description</td> <td valign="top">:</td> <td align="left"><textarea name="limitedtextarea" onkeydown="limitText(this.form.limitedtextarea,this.form.countdown,100);" onkeyup="limitText(this.form.limitedtextarea,this.form.countdown,100);"> </textarea><br> <font size="1">(Maximum characters: 100)<br> You have <input readonly type="text" name="countdown" size="3" value="100"> characters left.</font></td> </tr>
  15. Hi fellow geeks I need some help in creating my first website. I am stuck with email validation, I have checked plenty of links from google but I am just not able to get through with email validation. I would be greatful if you can help me with it. This is the code where I am facing issues.. if(preg_match('/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/',$eml)) { die("invalid email address"); $flag=false; } now whenever I try inserting a valid email address, it pops up an error as: Warning: preg_match() [function.preg-match]: No ending delimiter '^' found in C:\xampp\htdocs\cms_xhtml\customerinsert.php on line 159 please give me a solution to this issue or give me some other email validation code which can replace the above mentioned code. Thank you again, gracias
  16. Hello there, I have a script that I have created. The purpose of the script is a grade entry form. What it does, is the user enters the first and last name, course number, and the grade. The grade is converted from a number grade to a letter, such as A or A+ and redisplayed back to the user, as well as appended to a text file. The problem I am having is that I need to make sure that a valid number (between 0 and 100) is entered into the grade form, and make sure that it doesnt contain any letters, or just letters at all. Currently I have it so that if it contains a number, such as 50, it will convert it to the letter grade as required. If I enter 101, it will redisplay the page and make the user enter a correct grade. If a number such as 60 is entered with a letter, it will also make the user re-enter the information. However, if just letters are entered, it processes the form and displays the output as the same letters that were entered (when it should redisplay the page and ask the user to enter the correct information). Also, it will not display the output as (A+) or (A-) for the grades in those categories. Instead I had to put it to display (Aplus) or (Aminus), as it would not seem to print symbols in the output. If there are any suggestions as to what I have been doing wrong, that would be great. The way the program works is the user enters the information initially into an html version of the page that has to send the information to this php version. If the user enters anything incorrectly, then the php page just echo's back a copy of the original page, but displays a message notifying the user that there was an error. The code is attached below. Thanks in advance! process_EnterGrades.php
  17. Basically I've a Contact Form where a user fills in Name, Email Address and Comments and then there is aSubmit button. If I just hit "Submit" without filling in anything or wrong information, it takes me to this page,send_form_email.php. This page has all the validators in it. I want it to sort of (I say sort of because I still need to check whether they input everything correctly) bypass this page and go to "submitted-contact.php" page (it's going to this page but its not showing the following as specified in the 2) where it displays one of the 2 things: 1) Login Success 2) Try Again! Right now, there's nothing showing. :| send_form_email.php has this at the very top and it calls header location to the page, submitted-contact.php SEND_FORM_EMAIL CODE [/b] [b]<?php session_start(); $_SESSION['error']=true; $_SESSION['error']=false; ?> <?php if(isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "blah@hotmail.com"; $email_subject = "Your email subject line here"; function died($error) { // your error code can go here echo $error; die(); } // validation expected data exists if(!isset($_POST['first_name']) || !isset($_POST['email']) || !isset($_POST['comments'])) { died(''); } $first_name = $_POST['first_name']; // required $email_from = $_POST['email']; // required $comments = $_POST['comments']; // required $error_message = ""; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(!preg_match($email_exp,$email_from)) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$first_name)) { $error_message .= 'The First Name you entered does not appear to be valid.<br />'; } if(strlen($comments) < 2) { $error_message .= 'The Comments you entered do not appear to be valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Form details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "First Name: ".clean_string($first_name)."\n"; $email_message .= "Email: ".clean_string($email_from)."\n"; $email_message .= "Comments: ".clean_string($comments)."\n"; // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); $sendit= @mail($email_to, $email_subject, $email_message, $headers); if($sendit){ header('Location:submitted-contact.php'); }else{echo "Email failed to send";} } ?> SUBMITTED-CONTACT.PHP CODE <!DOCTYPE html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"><style type="text/css"></style> <title>CKK Internet Marketing</title> <link href="style.css" rel="stylesheet" type="text/css" media="all"> <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Lato"> <link rel="shortcut icon" href="images/favicon.ico" /> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <script src="js/jquery.sticky.js"></script> <script src="js/jquery.cycle.all.js"></script> <script src="js/jquery.smoothscroll.js"></script> <script> $(document).ready(function(){ $(".navigation").sticky({topSpacing:0}); }); </script> <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-27381915-2']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> </head> <body class="submitted"> <div class="navigation"> <div class="container"> <a href="#"><img src="images/logo.png"</a> <ul> <li><a href="/">Home</a></li> <li><a href="/about">About Us</a></li> <li><a href="/service">Services</a></li> <li><a href="/blog">Blog</a></li> <li><a href="/index.html#contact">Contact</a></li> </ul> </div> </div> <div id="submitted-content-2"> <div class="content container"> <?php if (!isset($_SESSION['flunk'])){ $myString = "MESSAGE FLUNKED!"; echo $myString; }else (!isset($_SESSION['pass'])){ $myString2 = "MESSAGE PASSED!"; ?> <div class="clear"></div> </div> </div> </div> <div class="clear"></div> <div class="footer"> <div class="container"> </div> </div> </body> </html> The php code in submitted-contact.php, the following code is in the right location but just the wrong syntax? <div id="submitted-content-2"> <div class="content container"> <?php if (!isset($_SESSION['flunk'])){ $myString = "MESSAGE FLUNKED!"; echo $myString; }else (!isset($_SESSION['pass'])){ $myString2 = "MESSAGE PASSED!"; ?> <div class="clear"></div> </div> </div> </div> Basically, I want to commute from send_form_email.php to submitted-contact.php one of the two things: 1) If user inputted everything well on the Contact Page, show them, "You're logged in" 2) If user inputted wrong information or did not fill in everything on the Contact Page, show them, "Try Again" I want that to be shown withing my <div class="content container"> Sorry, I know this was a long post but I really could use a hand on this. I have been trying to figure this out for the past couple of days! :| Thanks guys D3158
  18. Hi all, I have a contact form that works fine, I just need some REALLY BASIC validation added. As long as someone types in ANYTHING into the Name and Email fields to send the form. I would really appreciate some really simple validation that would work with what I have. I honestly have no idea how I got this far. THANKS IN ADVANCE! Here is the form code: -------------- <form method="post" action="sendmailscript.php"> <fieldset> <legend>Contact Information:</legend> <div> <label>Name*</label> <input name="name" type="text" required="required"/> <br /> </div> <div> <label>Company Name</label> <input name="company" type="text"/> <br /> </div> <div> <label>Phone Number</label> <input name="phone" type="tel" /> <br /> </div> <div> <label>Email Address*</label> <input name="email" type="email" required="required" /> <br /> </div> <div> <label>Website Address</label> <input name="website" type="url" /> <br /> </div> </fieldset> <fieldset> <legend>Preferred Meeting Type:</legend> <div> <label> </label> <input type="radio" name="meeting" value="Go To Meeting" /> <span class="checkboxDesc">Set Up A Go To Meeting Online Demo</span><br /> <label> </label> <input type="radio" name="meeting" value="Face To Face" /> <span class="checkboxDesc">Contact Me About A Face-To-Face Meeting</span><br /> <label> </label> <input type="radio" name="meeting" value="Would Like More Information" /> <span class="checkboxDesc">More Information</span><br /> </div> </fieldset> <fieldset> <legend>I'm Interested In:</legend> <div> <label>Request Information On:</label> <input type="checkbox" name="services[]" value="Call Tracking Telephone Numbers" /> <span class="checkboxDesc">Call Tracking Telephone Numbers</span><br /> <input type="checkbox" name="services[]" value="Design, Print & Mail Direct Mail Packages" /> <span class="checkboxDesc">Design, Print & Mail Packages</span><br /> <input type="checkbox" name="services[]" value="Direct Mail List Purchase" /> <span class="checkboxDesc">Direct Mail List Purchase</span><br /> <input type="checkbox" name="services[]" value="Printing & Graphic Design Services" /> <span class="checkboxDesc">Printing & Graphic Design Services</span><br /> <input type="checkbox" name="services[]" value="Website Design Services" /> <span class="checkboxDesc">Website Design Services</span><br /> <input type="checkbox" name="services[]" value="QR Codes & Landing Pages" /> <span class="checkboxDesc">QR Codes & Landing Pages</span><br /> <input type="checkbox" name="services[]" value="Mobile Websites" /> <span class="checkboxDesc">Mobile Websites</span><br /> <input type="checkbox" name="services[]" value="Sales & Lead Tracking Software" /> <span class="checkboxDesc">Sales & Lead Tracking Software</span><br /> <input type="checkbox" name="services[]" value="Marketing & Sales Consulting Services" /> <span class="checkboxDesc">Marketing & Sales Consulting Services</span><br /> </div> <div> <label>Message</label> <textarea name="message" id="message" rows="5" required="required" /> </textarea> </div> </fieldset> <input type="submit" name="submit" value="Submit" class="button" /> </form> ______________ Here is the php code: ----------- <?php $EmailTo = "me@me.com"; $Subject = "Request Form"; $Name = Trim(stripslashes($_POST['name'])); $Company = Trim(stripslashes($_POST['company'])); $Tel = Trim(stripslashes($_POST['phone'])); $Email = Trim(stripslashes($_POST['email'])); $Website = Trim(stripslashes($_POST['website'])); $Meeting = $_POST['meeting']; $Services = Implode("\n", $_POST['services']); $Message = Trim(stripslashes($_POST['message'])); $mailheader .= "Reply-To: $Email \r\n"; // prepare email body text $Body = ""; $Body .= "Name: "; $Body .= $Name; $Body .= "\n"; $Body .= "Company: "; $Body .= $Company; $Body .= "\n"; $Body .= "Phone: "; $Body .= $Tel; $Body .= "\n"; $Body .= "Email: "; $Body .= "$Email"; $Body .= "\n"; $Body .= "Website: "; $Body .= $Website; $Body .= "\n\n"; $Body .= "Preferred Meeting Type: \n"; $Body .= $Meeting; $Body .= "\n\n"; $Body .= "I'm Interested In: \n"; $Body .= $Services; $Body .= "\n\n"; $Body .= "Message: \n"; $Body .= $Message; // send email $success = mail($EmailTo, $Subject, $Body, "From: <$Email>"); // redirect to success page if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=thanks.html\">"; } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; } ?>
  19. I know how to validate URL in PHP by using the FILTER_VALIDATE_URL or simply, using regular expression. However, I want to know how I can validate a URL to see if it contains file. For example: www.xxxx.com/abc.exe, www.xxxx.com/abc/abc.jpg, etc... As you see, the links contain a file, one has an executable and the other has an image. I want to know, how I can validate a URL to know if it has a file or not? Because I do not want URL with contain file to be in my form! So, any regular expression or other way to do that?
  20. Hi there, I'm a newbie to PHP but am gradually implementing it more into sites and learning as I go. I recently found an article regarding PHP contact forms, the code for this is below. So far so good, I've managed to get the example to work. Please can someone explain why it is that the Spam check validation seems to take place before everything else? If the field is left blank or the total is wrong the error message seems to take priority even though one of the other fields before it is blank? Is it something to do with this being numerical? Thanks in advance. Nick <div id="contentForm" align="center"> <!-- The contact form starts from here--> <?php $error = ''; // error message $name = ''; // sender's name $email = ''; // sender's email address $subject = ''; // subject $message = ''; // the message itself $spamcheck = ''; // Spam check if(isset($_POST['send'])) { $name = $_POST['name']; $email = $_POST['email']; $subject = $_POST['subject']; $message = $_POST['message']; $spamcheck = $_POST['spamcheck']; if(trim($name) == '') { $error = '<div class="errormsg">Please enter your name!</div>'; } else if(trim($email) == '') { $error = '<div class="errormsg">Please enter your email address!</div>'; } else if(!isEmail($email)) { $error = '<div class="errormsg">You have enter an invalid e-mail address. Please, try again!</div>'; } if(trim($subject) == '') { $error = '<div class="errormsg">Please enter a subject!</div>'; } else if(trim($message) == '') { $error = '<div class="errormsg">Please enter your message!</div>'; } else if(trim($spamcheck) == '') { $error = '<div class="errormsg">Please enter the number for Spam Check!</div>'; } else if(trim($spamcheck) != '5') { $error = '<div class="errormsg">Spam Check: The number you entered is not correct! 2 + 3 = ???</div>'; } if($error == '') { if(get_magic_quotes_gpc()) { $message = stripslashes($message); } // the email will be sent here // make sure to change this to be your e-mail $to = "this@emailaddress.co.uk"; // the email subject // '[Contact Form] :' will appear automatically in the subject. // You can change it as you want $subject = '[Website Contact Form] : ' . $subject; // the mail message ( add any additional information if you want ) $msg = "From : $name \r\ne-Mail : $email \r\nSubject : $subject \r\n\n" . "Message : \r\n$message"; mail($to, $subject, $msg, "From: $email\r\nReply-To: $email\r\nReturn-Path: $email\r\n"); ?> <!-- Message sent! (change the text below as you wish)--> <div style="text-align:center;"> <p class="grey">Thank you for your enquiry.<br><br> Your message has been sent. </p> </div> <!--End Message Sent--> <?php } } if(!isset($_POST['send']) || $error != '') { ?> <!--Error Message--> <?=$error;?> <form method="post" name="contactform" id="contactform" class="rounded" action=""> <div class="field"> <label for="name"><span class="required">*</span> Full Name:</label> <input name="name" type="text" class="input" id="name" value="<?=$name;?>" /> </div> <div class="field"> <label for="email"><span class="required">*</span> Email: </label> <input name="email" type="text" class="input" id="email" value="<?=$email;?>" /> </div> <div class="field"> <label for="subject"><span class="required">*</span> Subject: </label> <input name="subject" type="text" class="input" id="subject" value="<?=$subject;?>" /> </div> <div class="field"> <label><span class="required">*</span> Message: </label> <textarea name="message" class="input textarea" id="message"><?=$message;?></textarea> </div> <div class="field"> <label><span class="required">*</span> Spam Check: <b>2+3=</b></label> <input name="spamcheck" type="text" class="input" id="spamcheck" size="4" value="<?=$spamcheck;?>" /><br /><br /> </div> <!-- Submit Button--> <input name="send" type="submit" class="button" id="send" value="Submit" /> </form> <!-- E-mail verification. Do not edit --> <?php } function isEmail($email) { return(preg_match("/^[-_.[:alnum:]]+@((([[:alnum:]]|[[:alnum:]][[:alnum:]-]*[[:alnum:]])\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)$|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i" ,$email)); } ?> <!--End of Contact Form--> </div>
  21. Hello people! I want to know some security features for file upload in PHP. I did read many stuffs, but not all have answered my questions. To start, I am more on front-end than back-end, so I am not a professional in PHP, but I do know several things in PHP (Procedural). I did create a file upload system before, which was to upload image, including security and validation. Anyway, I am planning to create a similar system again but I want to know more on things which I have applied before. Here are my questions: 1/ When validating file formats, which is better, validating by MIME or regular expression? I used regular expression before, because I have read MIME can be changed, even that I am curious. Here is an example of regular expression which accepts only JPG and GIF files: /\.(gif|jpg)$/i 2/ Can we upload file like EXE without affecting the server? I do not want the EXE file to execute now on the server, or simply, if it is infected, it can ruin the server. Is there a solution to tackle this or it is not recommended? Because many file hosting let you upload EX, RAR, ZIP, script formats etc... 3/ What other security measures should I take into account on file upload? All uploaded files will be in a folder, and the user will get their links to download. 4/ This question is not on security but mostly on cron job. Normally, file uploaded will be stored in a folder but not forever on the sever. I want that each 3 days, each file which has been uploaded, is deleted from the folder. I am not saying all files have to be deleted simultaneously, but each file which is more than 3 days. For example, I upload one today, on Sunday it will be deleted. If I upload another one tomorrow, on Monday it will be deleted. For this, a person told me to store the timestamps in a database and the name of the file. How to proceed the deletion with cron job? Thank!
  22. I have a form which contains a dynamic number of text fields that are intended for shoppers to input a positive number only. I separated the validation into a function. It is working well for me so far, but given that security is such a major concern I thought I would ask for comments from the forum. Here's the function: function validate($array){ if (count($array) > 0) { foreach($array as $product){ if(is_numeric($product[0]) && $product[0] >= 0){ return true; } else{ return false; } } } } When the form is sent, the returning page does a little bit of it's own configuring; functions relevant to the page itself and the user's context. Then the script checks to see if input was sent. Then it validates the data before attempting to use it. There are even checks further down in the script that continue to compare it as though it is numeric, and that it is greater than or equal to zero. Is this sufficient?
×
×
  • Create New...

Important Information

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