-
Posts
9,409 -
Joined
-
Last visited
-
Days Won
1
Everything posted by MadTechie
-
i think you need to re-praise the question.. whats the goal? as wildteen88 solution is what i thought you wanted! either that or you wish parse code from another source, e.g. you have some "text" in a database and what that to be executable.. if thats the case then you could use eval. ie <?php $code = 'echo "testing";'; eval($code); ?>
-
[SOLVED] [PROBLEM] need help with this code.
MadTechie replied to richarro1234's topic in PHP Coding Help
$fontcol=red; should be $fontcol="red"; etc etc -
How to add email validation to existing code?
MadTechie replied to forgottenglory's topic in PHP Coding Help
well you don't seam to get what i am saying so.. i'm just going to drop it.. -
How to add email validation to existing code?
MadTechie replied to forgottenglory's topic in PHP Coding Help
please re-read my last post! -
[SOLVED] [PROBLEM] need help with this code.
MadTechie replied to richarro1234's topic in PHP Coding Help
OK basically your looping twice $query = mysql_query("SELECT * from todo Order by percentage"); while ($r = mysql_fetch_array($query)) { then $results= mysql_query("SELECT * FROM todo Order by percentage desc"); try this (untested and was quick review) <link rel="stylesheet" type="text/css" href="stylenews.css"> <? include('data.php'); //include("funktioner.php"); mysql_connect($server,$anvandare, $losen); mysql_select_db($databas); ?> <center><?=$note?></center> <div align="center"> <center> <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#5D6765" width="95%" id="AutoNumber1"> <tr> <td width="100%"><br> <? $results= mysql_query("SELECT * FROM todo Order by percentage desc"); $id = "id"; $name = "name"; $description = "description"; $left_to_do = "left to do"; $percentage = "percentage"; if ($r[$percentage] <= 25) { $fontcol=red; } if ($r[$percentage] >= 25) { $fontcol=orange; } if ($r[$percentage] >= 50) { $fontcol=yellow; } if ($r[$percentage] >=75) { $fontcol=green; } if ($r[$percentage] >=100) { $fontcol=green; } echo mysql_error(); if (mysql_Numrows($results)>0) //if there are records in the fields { $numrows=mysql_NumRows($results); //count them $x=0; while ($x<$numrows){ //loop through the records $theid=mysql_result($results,$x,$id); $thename=mysql_result($results,$x,$name); $thedescription=mysql_result($results,$x,$description); $theltd=mysql_result($results,$x,$left_to_do); $thepercentage=mysql_result($results,$x,$percentage); ?> <table width="100%"> <tr> <th class="subcat" width="60%"> <font size="3"><?=$thename?>:</font> </th> <th class="subcat"> <font size="2">Done so far: <font color="<?=$fontcol?>"><?=$thepercentage?>%</font> </th> </tr> <tr> <td colspan="2" class="row2"> Design Page.<BR> <?=$theltd?></td> </tr> </table> <BR> <? $x++; } } else { ?> <center><b>There is nothing left to do !</b></center> <br> <? } ?> </td> </tr> </table> </center> </div> <?php } ?> -
[SOLVED] [PROBLEM] need help with this code.
MadTechie replied to richarro1234's topic in PHP Coding Help
after a 10 second look shouldn't $r[$percentage] be $r['percentage'] EDIT: Ok not sure of the problem.. if you only wanted the first record then why are you looping ? -
How to add email validation to existing code?
MadTechie replied to forgottenglory's topic in PHP Coding Help
Erm.. what! i assume you mean if javascript is disabled.. yes you could use meta tags ie <META http-equiv="refresh" content="5;URL=register.php"> but personally i would use header() for the redirect, but without knowing the full code, that could be a tin of worms. but 90% of the signup pages i write i use JS to check the email, then re-check via php (saves server processing) -
How to add email validation to existing code?
MadTechie replied to forgottenglory's topic in PHP Coding Help
@xyn: as a side note you don't need to the A-Z if you use the i at the end, other than that its the basically the same as mine without the redirect, as requested -
Kinda, sorry got the quick message, was on the phone at the same time.. basically we need more info.. mainly what the error is.. it could be anything from IE is crashing or not finding the site to a php error.. now by creating a simple script we have a test base.. also it will give us more info if the script fails then i can only assume theirs a problem with the XAMP side or thing.. if it works then we still need the error to workout the problem.. the most common problem i find the the use of short tags ie <? should be <?php
-
How to add email validation to existing code?
MadTechie replied to forgottenglory's topic in PHP Coding Help
Try this <?php if (!preg_match('/^\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b$/i', $email)) { echo ' Invalid Email Address <script type="text/javascript"> <!-- window.location = "register.php" //--> </script>'; } ?> timed example <?php if (!preg_match('/^\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b$/i', $email)) { echo ' Invalid Email Address <script type="text/javascript"> <!-- function register(){ window.location = "register.php" } setTimeout("register()", 5000) //--> </script>'; } ?> please note both are untested -
I use FileZilla;) but havn't used it much so i can't really say the pro's con's
-
try this code (in its own file) <?php phpinfo(); ?> if this fails please refer to the XAMP Manual
-
[SOLVED] Help adding font effects to a very small php bit
MadTechie replied to Padgoi's topic in PHP Coding Help
at a guess change $post = 'This post has been deleted by:'. $usr; to $post = '<font color="#FF0000"><strong>This post has been deleted by: $usr</strong></font>'; your need to test it in your IPB (also this should be in the third party section, as this is for IPB) -
your missing the code for the upload itself (in the code so far).. move this from the "code so far" to the sales.php <?php //define a maximum size for the uploaded images in Kb define ("MAX_SIZE","100"); //This function reads the extension of the file. //It is used to determine if the file is an image by checking the extension. function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } //This variable is used as a flag. //The value is initialized with 0 (meaning no error found) //and it will be changed to 1 if an error occures. //If the error occures the file will not be uploaded. $errors=0; //checks if the form has been submitted if(isset($_POST['Submit'])) { //reads the name of the file the user submitted for uploading $image=$_FILES['image']['name']; //if it is not empty if ($image) { //get the original name of the file from the clients machine $filename = stripslashes($_FILES['image']['name']); //get the extension of the file in a lower case format $extension = getExtension($filename); $extension = strtolower($extension); //if it is not a known extension, we will suppose it is an error and will not upload the file, //otherwise we will do more tests if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) { //print error message echo '<h1>Unknown extension!</h1>'; $errors=1; } else { //get the size of the image in bytes //$_FILES['image']['tmp_name'] is the temporary filename of the file //in which the uploaded file was stored on the server $size=filesize($_FILES['image']['tmp_name']); //compare the size with the maxim size we defined and print error if bigger if ($size > MAX_SIZE*1024) { echo '<h1>You have exceeded the size limit!</h1>'; $errors=1; } //we will give an unique name, for example the time in unix time format $regestration = REGNAME; $image_name=$regestration.'.'.$extension; //the new name will be containing the full path where will be stored (images folder) $newname="car_images/".$image_name; //we verify if the image has been uploaded, and print error instead $copied = copy($_FILES['image']['tmp_name'], $newname); if (!$copied) { echo '<h1>Copy unsuccessfull!</h1>'; $errors=1; } } } } //If no errors registred, print the success message if(isset($_POST['Submit']) && !$errors) { echo "<h1>File Uploaded Successfully! Try again!</h1>"; } ?>
-
can you please explain the logic behind the headers.. why would 1 go from 1 to 11 but header 2 only go from 12 to 16 ?
-
really!!, that weird i am viewing my script now!! lol, as for the question in hand, if you have write access to the scripts in question then you can if not then only if the data is processed to the page, if not then no, it would be security hell
-
use Relative Paths as for the Dirlist, try this // get the Absolute Path (see link above) $path = dirname(__FILE__)."/"; //goes up a folder to a folder called images $path .= "images/";
-
may help Dynamic Dropdown php/Ajax
-
I need a PHP based javascript compresser and protector
MadTechie replied to tibberous's topic in PHP Coding Help
protecting javascript is impossible as the client machine needs download the code to use it.. but using obfuscator makes it hard for the mortal humans to read.. -
Windows(system) Root = c:\ but if the webserver also used then when someone came to your site they could see all your files etc.. so the webserver asks where your webefile/site is stored (or it has a default), now that path is the web servers root.. so you on your computer see c:\ as the root but other people connecting throught your server see the webservers root.. so when it refers to root its infact refering to the webroot ("root of your web space").
-
[SOLVED] Invalid argument supplied for foreach()
MadTechie replied to bronzemonkey's topic in PHP Coding Help
welcome, if solved please click topic solved (bottom left) -
C:/WEB_SERVER/www/ is the windows path to the root of the site, thus if your script calls a file from the root (/) then it will look from their.. hope that makes sense! :-\
-
How is your login script working? MySQL, FlatFile etc ? probably the "simplest" way would be using the UsersID or Username (whatever is uniqe) then move the file to the "profile images" folder and rename it to that unique name/id .jpg
-
with that code you could just change echo "<a href=\"$file\">$file</a><br />"; to $filedisplay = preg_replace('/[a-z.]/si', '', $file); echo "<a href=\"$file\">$filedisplay</a><br />"; for the numbering.. as for the path ($path = "C:/WEB_SERVER/www/site/folder/" shouldn't that be $path = "site/folder/"; ?