The Little Guy
Members-
Posts
6,675 -
Joined
-
Last visited
Everything posted by The Little Guy
-
HTML forms. different buttons, different actions
The Little Guy replied to boo_lolly's topic in PHP Coding Help
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] -
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().
-
[CODE]<?php $date = '2006-11-28 20:54:46'; list($year,$time) = explode(" ",$date); echo $year; ?>[/CODE]
-
Retrieve a whole URL via GET (or is there a better way?)
The Little Guy replied to closet geek's topic in PHP Coding Help
Your Welcome! It took time but we got it! -
Retrieve a whole URL via GET (or is there a better way?)
The Little Guy replied to closet geek's topic in PHP Coding Help
[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 -
Retrieve a whole URL via GET (or is there a better way?)
The Little Guy replied to closet geek's topic in PHP Coding Help
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] -
Retrieve a whole URL via GET (or is there a better way?)
The Little Guy replied to closet geek's topic in PHP Coding Help
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); ?> -
Retrieve a whole URL via GET (or is there a better way?)
The Little Guy replied to closet geek's topic in PHP Coding Help
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] -
Retrieve a whole URL via GET (or is there a better way?)
The Little Guy replied to closet geek's topic in PHP Coding Help
[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 -
Id say yeah.
-
sorting multiple arrays by the same key
The Little Guy replied to jdubwelch's topic in PHP Coding Help
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). -
Retrieve a whole URL via GET (or is there a better way?)
The Little Guy replied to closet geek's topic in PHP Coding Help
Try this: [CODE]echo $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];[/CODE] -
you will need to make a row for every day for every player
-
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]
-
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.
-
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.
-
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.
-
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
-
How do I retrieve variables passed thru the URL?
The Little Guy replied to ridiculous's topic in PHP Coding Help
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']; -
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]
-
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] ?>
-
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]
-
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?
-
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?
-
Nevermind... I got it.