-
Posts
9,409 -
Joined
-
Last visited
-
Days Won
1
Everything posted by MadTechie
-
sounds like your using an Online Control Panel!, did you create it ?
-
Making a redirect faster when posting to same page
MadTechie replied to jjmusicpro's topic in PHP Coding Help
try this <TD width="64%" height="47"><form action="process.php?groupid=<?php echo $_GET['groupid'];?>" method="POST"> <div align="center"> <input type="text" maxlength="10" class="searchBox" name="zipcode_entered_search" size="8" /> <input name="Submit" type="image" id="Submit" src="handyman_files/go_button.gif" alt="Request Service from your local Mr. Handyman!"> </div> </form></TD> <?php error_reporting(E_ALL); require_once ('connect.php'); require_once ('opendb.php'); $groupid_sent = (int)$_GET['groupid']; $query = "SELECT * FROM metrogroups WHERE groupid=$groupid_sent"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result, MYSQL_ASSOC); $groupname = $row['groupname'] ; if( isset($_POST['Submit']) ) { $zipcode = $_POST['zipcode_entered_search']; $query2 = "INSERT INTO zipcodes_searched (zipcode,time_date) VALUES ('$zipcode', NOW())"; $result2 = mysql_query($query2); $query = "SELECT * FROM zipcodes WHERE zipcode='$zipcode' and on_off=1"; $result = mysql_query($query) or die(mysql_error()); $count = mysql_num_rows($result); switch($count) { case 0: header( "location: nf.php?groupid=" . $_GET['groupid'] . "?zipcode_entered_search=" . $_GET['zipcode_entered_search'] ."\">"); exit; break; case 1: $row = mysql_fetch_array($result, MYSQL_ASSOC); $site = $row['redirect_url'] ; header("location: $site"); exit; break; default: $row = mysql_fetch_array($result, MYSQL_ASSOC); header( "location: shared.php?groupid=" . $_GET['groupid'] . '?zipcode_entered_search=' . $_GET['zipcode_entered_search'] ."\">"); exit; break; } } else { echo "Nothing submitted!"; } ?> -
ahh nope but heres an basic example that should (your need to update for PNG & GIF) (see the switch's) if( is_file($dir."/".$random_image) && in_array($ext, $images_ext) ) { resize($dir."/".$random_image, 100,"jpg"); }else{ readfile($dir."error/error.gif"); } exit; function resize($image, $thumbWidth, $type) { switch($type) { case "jpg": $img = imagecreatefromjpeg($image); break; } $width = imagesx( $img ); $height = imagesy( $img ); // calculate thumbnail size $new_width = $thumbWidth; $new_height = floor( $height * ( $thumbWidth / $width ) ); // create a new temporary image $tmp_img = imagecreatetruecolor( $new_width, $new_height ); // copy and resize old image into new image imagecopyresized( $tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height ); switch($type) { case "jpg": imagejpeg( $tmp_img); break; } }
-
Welcome, please check the keys as well
-
Few extra words.. i am not sure but i think this line ${$key} = mysql_real_escape_string($value); may mess it up (on the insert), but i assume your attempting to protect yourself from SQL injections, but you have missed one thing..the fieldnames maybe try this $newkey = mysql_real_escape_string($key); ${$newkey} = mysql_real_escape_string($value); or (if the value is failing) $newkey = mysql_real_escape_string($key); ${$newkey} = $value;
-
ok read comments <?php //if adv-edit is submitted, update record if ( isset($_POST['advanced_edit']) ) { unset($_POST['advanced_edit']); //don't need this //prepare items for insertion into database $iso_format = true; foreach ($_POST as $key => $value) { if (in_array($key, $adv_expected)) { //Don't Filter yet (will messup the check) if( !preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/', $value) ) { //No point continuing, it failed $iso_format = false; break; }else{ //Thats OK, set the value for the SQL ${$key} = mysql_real_escape_string($value); } } } // === with true false value, (good pratice) if ($iso_format === true) //swapped (just seams right, === true) { $sql = "UPDATE table SET date_new = '$adv_received', date_proofed = '$adv_proofed', date_approved = '$adv_approved', date_printed = '$adv_printed', date_inserted = '$adv_inserted', date_mailed = '$adv_mailed', date_seed = '$adv_seed' WHERE tracking_number = '$tracking_number'"; }else { $iso_error = "Please use the provided date format of yyyy-mm-dd"; $iso_error_main = "There was an error with the dates inputed in the \"Advanced Edit\" area"; } } ?> of course its untested EDIT: bug fix
-
can you do a print_r($_POST); at the top of your script and post the results i assume you have a submit button value thats messing it up (if all the values MUST be date formatted)
-
for the most part it looks ok, can be cleaned up but still ok i'll change the last part to if( is_file($dir."/".$random_image) && in_array($ext, $images_ext) ) { readfile($dir."/".$random_image); }else{ readfile($dir."error/error.gif"); } exit; you may have a problem in the block switch(strtolower($ext)), as your calling the scrip again, which could, have a never ending effect
-
the problem is here // see comments <?php foreach ($_POST as $key => $value) { if (in_array($key, $adv_expected)) { ${$key} = mysql_real_escape_string($value); $iso_format = preg_match('{[0-9]{4}-[0-9]{2}-[0-9]{2}}', ${$key}); //checks each item } }//loop ends if ($iso_format == false) { //outside the loop (so only checks the LAST item) ?> May i ask why your looping through the POST ?, do you know the element name you wish to check ?
-
welcome, please click solved bottom left
-
try this regex iso_format = preg_match('/[0-9]{4}-[0-9]{2}-[0-9]{2}/', ${$key}) Updated: messed it up EDIT: infact this is more correct iso_format = preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/', ${$key})
-
I assume you chaged the $_GET to $_POST for one
-
LOL, my bad || should be | this should work <?php $email = 'xyz@mydomain.com'; echo $email; echo '<br><br>'; // test block or *.EXT and *.EXT1 emails //if ( preg_match( "#\.EXT$#i", $email ) ) { if ( preg_match( "#(?:\.EXT|\.EXT1)$#i", $email ) ) { echo 'The email address you entered is not allowed.'; exit; } ?> || = OR in PHP | = OR in RegEx
-
can you click solved (Bottom left) if it is solved cheers
-
Humm.. i tested it and it works for me! well the php, side not sure about the js or html
-
the Following are example of what will fail tedsfsdst.ext tfdsfest.eXt tefdsfsdst.co.Uk tefdsfsdst.eXt1 tcsdadfdsfsdest.ext2 EDIT: remove ||\.co\.uk to allow the .co.uk
-
hope this helps // test block of *.EXT emails if ( preg_match( "#(?:\.EXT||\.co\.uk||\.EXT1||\.EXT2)$#i", $email ) ) { //NOTE the i after the # (for case insensitive) echo 'The email address you entered is not allowed.'; exit; }
-
This is a HTML/CSS Question try googling Online WYSIWYG Editor
-
try this foreach ($_POST as $key => $val) { echo "$key = $val<BR>"; } EDIT: removed an extra} (typo)
-
this should do it <?php $data = $_GET['data']; $errors; //is alphanumeric function isAlphaNum($input) { global $errors; if(!eregi("^([0-9a-zA-Z])*$", $input)){ $errors[]='* must only contain alphanumeric characters'; } } //check if length function checkLength($data,$max,$min) { global $errors; if($data=='' || strlen(trim($data)) < $min){ $errors[]='* must be at least '.$min.' characters'; } if($data=='' || strlen(trim($input)) > $max){ $errors[]='* must can not exceed '.$max.' characters'; } } //check for errors function isErrors() { global $errors; if (isset($errors) && count($errors) > 0){ return true; }else{ return false; } } //list errors function listErrors($delim = ' '){ global $errors; if (isset($errors) && count($errors) > 0){ return implode($delim,$errors); } } switch($_GET['field']){ case'userid': checkLength($data,255, 3); isAlphaNum($data); if(isErrors()){ ?> <!--passes errors for display as well as showing a red x symbolizing an error--> <script type="text/javascript"> window.addEvent('domready', function(){ $('iconuserid').setStyle('background-position','0 50%'); $('erruserid').setStyle('visibility','visible').empty().appendText(<?=listErrors();?>); }); </script> <?php }else{ ?> <!--displays a green check symbolizing no errors--> <script type="text/javascript"> window.addEvent('domready', function(){ $('iconuserid').setStyle('background-position','0 0'); $('erruserid').setStyle('visibility','hidden').empty(); }); </script> <?php } break; case'pass': checkLength($data,16,6); isAlphaNum($data); if(isErrors()){ ?> <!--passes errors for display as well as showing a red x symbolizing an error--> <script type="text/javascript"> window.addEvent('domready', function(){ $('iconpass').setStyle('background-position','0 50%'); $('errpass').setStyle('visibility','visible').empty().appendText(<?=listErrors();?>); }); </script> <?php }else{ ?> <!--displays a green check symbolizing no errors--> <script type="text/javascript"> window.addEvent('domready', function(){ $('iconpass').setStyle('background-position','0 0'); $('errpass').setStyle('visibility','hidden').empty(); }); </script> <?php } break; } ?>
-
So solved ?
-
do you mean this ? <?php $test = '<a href="(testing123_-,)-page">(testing123_-,)-page</a>'; if (preg_match('/[a-z0-9()_,-]*(?=-)-page/i', $test)) { echo "found"; } else { echo "nothinf found"; } //also //preg_match_all('/[a-z0-9()_,-]*(?=-)-page/si', $test, $result, PREG_PATTERN_ORDER); //$result = $result[0]; ?> please move to RegEx Section!
-
Database driven tool tips, possibly str_replace?
MadTechie replied to powelly's topic in PHP Coding Help
maybe this <?php $start = "<span class=\'link\'><a href=\'javascript: void(0)\'>"; $end= "<span>popup text goes here</span></a></span>"; $content = "This <u>tests</u> the test!"; $content = preg_replace('%(<u>([^>]*)</u>)%si', "$start\2$end", $content ); ?> -
echo $row="['r_no']"; should be echo $row['r_no'];
-
try this <?php $data = $_GET['data']; $errors; //is alphanumeric function isAlphaNum($input) { global $errors; if(!eregi("^([0-9a-zA-Z])*$", $input)){ $errors[]='* must only contain alphanumeric characters'; } } //check if length function checkLength($input,$max,$min) { global $errors; if($data=='' || strlen(trim($data)) < $min){ $errors[]='* must be at least '.$min.' characters'; } if($data=='' || strlen(trim($input)) > $max){ $errors[]='* must can not exceed '.$max.' characters'; } } //check for errors function isErrors() { global $errors; if (isset($errors) && count($errors) > 0){ return true; }else{ return false; } } //list errors function listErrors($delim = ' '){ global $errors; if (isset($errors) && count($errors) > 0){ return implode($delim,$errors); } } switch($_GET['field']){ case'userid': checkLength($data,3,255); isAlphaNum($data); if(isErrors()){ ?> <!--passes errors for display as well as showing a red x symbolizing an error--> <script type="text/javascript"> window.addEvent('domready', function(){ $('iconuserid').setStyle('background-position','0 50%'); $('erruserid').setStyle('visibility','visible').empty().appendText(<?=listErrors();?>); }); </script> <?php }else{ ?> <!--displays a green check symbolizing no errors--> <script type="text/javascript"> window.addEvent('domready', function(){ $('iconuserid').setStyle('background-position','0 0'); $('erruserid').setStyle('visibility','hidden').empty(); }); </script> <?php } break; case'pass': checkLength($data,6,16); isAlphaNum($data); if(isErrors()){ ?> <!--passes errors for display as well as showing a red x symbolizing an error--> <script type="text/javascript"> window.addEvent('domready', function(){ $('iconpass').setStyle('background-position','0 50%'); $('errpass').setStyle('visibility','visible').empty().appendText(<?=listErrors();?>); }); </script> <?php }else{ ?> <!--displays a green check symbolizing no errors--> <script type="text/javascript"> window.addEvent('domready', function(){ $('iconpass').setStyle('background-position','0 0'); $('errpass').setStyle('visibility','hidden').empty(); }); </script> <?php } break; } ?>