![](https://forums.phpfreaks.com/uploads/set_resources_1/84c1e40ea0e759e3f1505eb1788ddf3c_pattern.png)
taith
Members-
Posts
1,514 -
Joined
-
Last visited
Everything posted by taith
-
uuh... other way around... styles first ;-)
-
<? $url = $_POST['redurl']; header('Location:'. $url); exit; ?>
-
[SOLVED] creating random numbers and adding it to a database
taith replied to runnerjp's topic in PHP Coding Help
i dunno... i didnt make it for classes... maybe thats the issue? -
[SOLVED] Best structure for a function library?
taith replied to pocobueno1388's topic in PHP Coding Help
personally... i make a functions folder... with an index, which glob()s and require_once()'s all the files in that folder, and inside, i have each of my functions seperated(1 per file(for the most part, i think in have one file with 4... but there all dependant on eachother))... for example... get_url.php <? function get_url(){ if(!empty($_SERVER['QUERY_STRING'])) return 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING']; else return 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF']; } ?> thats it. the one with 4 files, is a navigation script i made, allowing you to add/remove topics, and groups, and output... 4 parts of the same program... but thats just me... makes debuging a breeze!... dont have to count lines of code, looking to find that you forgot a {... -
[SOLVED] creating random numbers and adding it to a database
taith replied to runnerjp's topic in PHP Coding Help
<?php function randomkeys($length){ $pattern="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; for($i=0; $i<$length; $i++) $key.=$pattern{rand(0,61)}; return $key; } function addNewUser($username, $password, $email){ $time=time(); if(strcasecmp($username, ADMIN_NAME) == 0) $ulevel=ADMIN_LEVEL; else $ulevel=USER_LEVEL; $key=randomkeys(30); $q="INSERT INTO ".TBL_USERS." VALUES ('$username', '$password', '0', $ulevel, '$email', $time, $key)"; return mysql_query($q, $this->connection); } ?> -
in 2 years, i've never had any issues with my referrer script... and if you just want an unreachable page... just... header('Location: '.get_referrer());
-
boo javascript! lol okok... it has its uses... one of which, isnt automated redirects... <? function get_referrer(){ return (!$ref=@$HTTP_REFERER) ? $_SERVER['HTTP_REFERER'] : $ref; } switch(get_referrer()){ case "http://www.google.com": header('Location: google.php'); break; } exit; ?>
-
index.php <? require_once('common.php'); $body.='<table>'; $body.=' <tr>'; $body.=' <td><span class=text>text</span></td>'; $css.='.text{ text-align:center; }'; $head.='<meta keywords="i like cheese">'; $body.=' </tr>'; #i can set cookies in here, sessions, whatever i need $body.='</table>'; require_once('template.php'); ?> template.php <head> <?=$head?> <style> <?=$css?> </style> </head> <table> <tr> <td><?=$body?></td> </tr> </table> i might also say... this saves ALOT of space on the server... as your using the same template page again and again and again... also is pretty fast!
-
wow... theres alot of confusion for such a simple switch! lol <?php if(empty($bodytag)) $bodytag='main'; ?> <body class="<?=$bodytag?>"> then on any page you want to change the class, just give $bodytag a value...
-
Website Database Layout Design: Logical, Instinctive or Visual????
taith replied to yandoo's topic in PHP Coding Help
if it were me... i'd just set up some statistic handeling for a week... and put them in order of which one was used more often... lol from experience... i'd have to agree name username department -
if they turn off cookies, it turns off any/every form of cookies... javascript, php, meta...
-
personally... i learned my programming so i template... i dealt with this all the time(and got fed up )... setcookie(); $head.=''; $body.='<span class="asdf">text</span>'; require_once('template.php'); then on your template page <?=$head?> <table> <tr> <td><?=$body?></td> </tr> </table> basically... your not outputing any data, until it hits the template page, where all your variables get output :-) you can do stuff in/out of order and nothing really cares(html/css wise)... lol... as long as your css is a varialbe being output, and your body uses them css, everythings happy
-
declaring the string an int... $string=213hlsdf34; $int=(INT)$string;
-
or... is_numeric()
-
yup! just store the counter into the database... instead of in a session :-)
-
sorry... i dont fully understand modulo... but i think this'd work... $_SESSION[counter]++; if(($_SESSION[counter]%2)==0) header('Location: '); else header('Location: ');
-
foreach($_POST[reason] as $val){ $reason[].='\'reason\'=`'.$val.'`'; } $reason=implode('||',$reason); foreach($_POST[region] as $val){ $region[].='\'region\'=`'.$val.'`'; } $region=implode('||',$region); mysql_query("SELECT * FROM `table` WHERE (($reason) && ($region))");
-
[SOLVED] nsert character into variable for displaying
taith replied to Dragen's topic in PHP Coding Help
somin like this should do :-) <?php function split($string, $limit, $add){ for($i=0;$i<=strlen($string);$i++){ $k++; if($k==$limit){ $string2.=$add; $k=0; } $string2.=$string{$i}; } return trim($string2); } ?> -
mine does all levels of files ;-)
-
sorry guys... i'm going to simplify that with glob() http://ca3.php.net/manual/en/function.glob.php it'll grab any/all files in a directory with a * and all php files with a *.php... it acts similar to the dos version(i feel old... stop laughing )
-
not tested... but i think it'll work... lol <?php $out=array(); function get_all($dir){ $files=glob($dir); if(empty($files)) return array(); foreach($files as $file){ if(is_dir($file)) $out=array_merge($out,get_all($file.'/*')); else $out[]=$file; } return $out; } print_r(get_all('../divinelive/*')); ?> sorry... edited... now it works... lol then you just do a foreach(){} to grab the filetime(), and remove accordingly :-)
-
tinymce!
-
[SOLVED] breaking up the query string dynamicly?
taith replied to dj-kenpo's topic in PHP Coding Help
huge security risk... for example... anybody could type in ?month=12&year=2006&security=1|0|1|1... and if you have a $_SESSION[security], it just got changed to 1|0|1|1, and if you use that way of securing... they then can have full access... or whatnot...