Jump to content

The Little Guy

Members
  • Posts

    6,675
  • Joined

  • Last visited

Everything posted by The Little Guy

  1. give each button a unique name then when it submits to the page check for which button was pressed. [CODE]<?php if($_POST['cancel']){     header("Location:page_cancel.php"); }elseif($_POST['save_exit']){     //update database code     header("Location:page_exit.php"); }elseif($_POST['save_continue']){     //update database code     header("Location:page_continue.php"); }else{     //this will display if something went wrong.     header("Location:default.php"); }[/CODE]
  2. http://us3.php.net/manual/en/security.database.sql-injection.php Never connect to the database as a superuser or as the database owner. Use always customized users with very limited privileges. Check if the given input has the expected data type. PHP has a wide range of input validating functions, from the simplest ones found in Variable Functions and in Character Type Functions (e.g. is_numeric(), ctype_digit() respectively) and onwards to the Perl compatible Regular Expressions support. If the application waits for numerical input, consider verifying data with is_numeric(), or silently change its type using settype(), or use its numeric representation by sprintf().
  3. [CODE]<?php $date = '2006-11-28 20:54:46'; list($year,$time) = explode(" ",$date); echo $year; ?>[/CODE]
  4. [code]<?php function get_id($url){ $end = $url; $begin = $_SERVER['SCRIPT_NAME']; $var1 = str_replace($begin,'',$end); $var2 = str_replace('?id=','',$var1); return $var2; } echo 'http://'.get_id($_SERVER['REQUEST_URI']); ?>[/code] http://tzfiles.com/phpcode/entities.php?id=d-top.org/display.php?artist=orgy
  5. I changed the ? in the url to three pipes (since that isn't common in a url), and changed & to thee ^^^ then I replace it with a question mark. Click Link: [url=http://tzfiles.com/phpcode/entities.php?id=http://d-top.org/display.php|||artist=orgy^^^title=candyass]http://tzfiles.com/phpcode/entities.php?id=http://d-top.org/display.php|||artist=orgy^^^title=candyass[/url] [code]<?php $page = $_GET['id']; $replace = array('|||', '^^^'); $value = array('?','&'); echo str_replace($replace,$value,$page); ?>[/code]
  6. I changed the ? in the url to three pipes (since that isn't common in a url), then I replace it with a question mark. Click Link: http://tzfiles.com/phpcode/entities.php?id=http://d-top.org/display.php|||artist=orgy <?php $page = $_GET['id']; $replace = array('|||', '||||'); $value = array('?','&'); echo str_replace($replace,$value,$page); ?>
  7. Here is what you need to do: convert all & to: %38 (after the [b]id=[/b]) convert all ? to: %63 (after the [b]id=[/b]) then you can send it to the address bar, then you can retrieve it and do what you want: [code]<?php $page = $_GET['id']; header("Location:".$page); ?>[/code]
  8. [quote author=Orio link=topic=116598.msg475205#msg475205 date=1164738930] @The Little Guy @taith But that's not what he/she was asking for... Orio. [/quote] Are you sure? It seems like it to me. This url doesn't "trip up", and it is displayed on the page. To me, he/she is asking if there is a way to get the whole URL, and that is what I posed does, and you can see from the link below: http://tzfiles.com/phpcode/echo_url.php?123123=2383&name=123?123
  9. You could get the value of 2 from the array, and save it in a new array, then order that new array as the order of the original arrays (if that makes any sense).
  10. Try this: [CODE]echo $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];[/CODE]
  11. you will need to make a row for every day for every player
  12. Im not sure, but I don't think that it is a temoprary directory, I think that it is just memory storage.  Any who... Here try this: [CODE] <?php if ($_FILES['file_name']['type'] != 'image/gif' || $_FILES['file_name']['type'] != 'image/jpg'){     echo'You can not upload that file type'; }else{     #upload file script... } ?>[/CODE]
  13. Here is how I usually do my login pages [code]<?php include"db.php";//include database $email = addslashes($_POST['user_email']);//set email/username var $pass = addslashes($_POST['user_password']);//set password var $sql = mysql_query("SELECT * FROM users WHERE email='$email' AND password='$pass'");//search database $row = mysql_fetch_array($sql);//return a row if(isset($_POST['submit']) && ($row)){//if post was set, and a row was returned set sessions session_start(); $_SESSION['email'] = $row['email']; $_SESSION['first'] = $row['first']; $_SESSION['last'] = $row['last']; $_SESSION['zip'] = $row['zip']; $_SESSION['city'] = $row['city']; $_SESSION['gender'] = $row['gender']; $_SESSION['DOB'] = $row['DOB']; $_SESSION['userid'] = $row['user_id']; $_SESSION['loggedin'] = 1; $date = date("m-d-Y"); mysql_query("UPDATE users SET last_login='$date' WHERE user_id='$_SESSION[userid]'")or die(mysql_error()); header("Location: user.php");//Redirect to users page }else{//else destroy any session made session_start(); $_SESSION = array(); if (isset($_COOKIE[session_name()])) {   setcookie(session_name(), '', time()-42000, '/'); } session_destroy(); header("Location: index.php");//redirect back to the login page } ?>[/code] for every page that is a "Logged in Users" page, you MUST have session_start() at the top otherwise it wont work as a users page.
  14. http://us3.php.net/getimagesize [quote=PHP.net]Returns an array with 4 elements. Index 0 contains the width of the image in pixels. Index 1 contains the height. Index 2 is a flag indicating the type of the image: 1 = GIF, 2 = JPG, 3 = PNG, 4 = SWF, 5 = PSD, 6 = BMP, 7 = TIFF(intel byte order), 8 = TIFF(motorola byte order), 9 = JPC, 10 = JP2, 11 = JPX, 12 = JB2, 13 = SWC, 14 = IFF, 15 = WBMP, 16 = XBM. These values correspond to the IMAGETYPE constants that were added in PHP 4.3.0. Index 3 is a text string with the correct height="yyy" width="xxx" string that can be used directly in an IMG tag.[/quote] Just compaire the numbers in your PHP code and if it isn't a match, don't allow upload.
  15. You would call the variable the same way you would if it were in the same file, when you include a file, it basically turns two page into one, and every time you add another file the one larger file and the next added file become one file, and this process continues until it gets to the very bottom of all the files.
  16. What do you think? This isn't really a critique on the site, but those would be nice... I am looking for what you think on the codes that I provide.  Each link has an interactive example, followed by the output, then the code used to make that example. Thinks I would like: - How is the coding for a specific link - What codes could I add - Layout - Any other suggestions Thanks http://tzfiles.com/phpcode
  17. echo            '<div>            <a href="course_details_index.php?       '.$Course_Id.'       &'.$Course_Begin_Time.'       &'.$Instructor_1.'">       <img src="media/course_pics/index.php?pic='.$Course_Pic .'" alt="Featured Course Image" border="none"       img style="position:absolute; height:300px; width:300px; TOP:0px; LEFT:0px;">[/url]       </div>'; ===================================================================== echo $_GET['pic'];
  18. Try this: [code]<?php $email1 = explode("\n",$_POST['emails']); foreach($email1 as $emailaddr){ $email = $emailaddr; $subject = "This Is Your Subject Line"; $headers  = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= "From: ".$_POST['name']." \r\n" . "X-Mailer: PHP/" . phpversion(); $message = '<p>This is your message it can have HTML in it</p> <p><a href="'.$_SERVER['HTTP_REFERER'].'">This Site</a></p>'; $mail = mail($email, $subject, $message, $headers); }[/code]
  19. Try this: [code]<?php $email1 = explode("\n",$_POST['emails']); foreach($email1 as $emailaddr){ $email = $emailaddr; $subject = "This Is Your Subject Line"; $headers  = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= "From: ".$_POST['name']." \r\n" . "X-Mailer: PHP/" . phpversion(); $message = '<p>This is your message it can have HTML in it</p> <p><a href="http://sitename.com'.$_SERVER['REQUEST_URI'].'">This Site</a></p>'; $mail = mail($email, $subject, $message, $headers); }[/code] ?>
  20. I haven't tested this yet, so I don't know if you'll get any errors or not. This is the HTML: [code]<form action="somepage.php" method="post"> One Email per line<br> <textarea name="emails"></textarea><br> <input type="submit" name="submit" value="Send"> </form>[/code] And here would be the PHP: [code]<?php $email1 = explode("\n",$_POST['emails']); foreach($email1 as $emailaddr){ $email = $emailaddr; $subject = "This Is Your Subject Line"; $headers  = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= "From: ".$_POST['name']." \r\n" . "X-Mailer: PHP/" . phpversion(); $message = '<p>This is your message it can have HTML in it</p>'; $mail = mail($email, $subject, $message, $headers); } ?>[/code]
  21. there are a couple ways of doing, but one main deal would be this question... do you want to send to only one person, or multiple people? Anther question is... Do you have support for the mail() function?
  22. It is mainly for when using a database to protect from SQL injection.  So the user would do an addslashes() function, and wen reading from the database he would use stripslashes.  Here is an example This is in the database: How\'s the weather? and when stripslashes is used around that, It will display on the page like this: How's the weather?
×
×
  • 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.