-
Posts
1,025 -
Joined
-
Last visited
Never
Posts posted by Caesar
-
-
If you want to use those variables in a function in 'main.php', you have to make them available to the function by...
<?php include'foo.php'; function cancer() { global $foo_1; //Now we can use this variable in the cancer() function in 'main.php' $message = "Hello $foo_1"; return $message; } ?>
-
I agree...
A simple timestamp will do.
<?php function check_session($current) { session_start(); $sess_limit = 1200; $sess_start = $_SESSION['sess_start']; $session_time = ($current - $sess_start); if($session_time > $sess_limit) { session_destroy(); header("location: index.php?action=logout"); exit; } else { //Update the your session...or whatever. } } ?>
-
Use MYSQL. Create a sessions table and update it every time the page is viewed.
-
Using your existing code....
<?php $sql = "SELECT * FROM siteusers"; $query = @mysql_query($sql,$connection) or die(mysql_error()); while ($row = mysql_fetch_array($query)) { $emails[] = $row['email']; print $row['email'].'; '; } ?>
This will create an $emails array that will store all the emails in that loop. If you want to store it in one long string instead of using an array...
<?php $sql = "SELECT * FROM siteusers"; $query = @mysql_query($sql,$connection) or die(mysql_error()); while ($row = mysql_fetch_array($query)) { $emails .= $row['email'].' '; print $row['email'].'; '; } ?>
-
That one is written in PHP so I can also edit and customize :-) If you plan on learning PHP, it's a good solution.
Good luck!
-
If you've already got the product to sell, and you're not a programmer, I suggest using an existing solution.
Reasons why...
1. They continuously update their software.
2. They troubleshoot the code.
3. Support for integrated payment processors..
And on and on...etc.
The solution I use for my clients is:
http://www.turnkeywebtools.com/sunshop/
Edit: Online Demo -> http://demos.turnkeywebtools.com/ss4/
-
I only want to redirect if the URL is www.mydomain.com with no PID. So would the first code be sufficient?
Yes, it will.
Slight modification....
<?php if((!isset($_GET['pid'])) || ($_GET['pid'] == '') || (!is_numeric($_GET['pid']))) { header("location: index.php?pid=0"); exit; } ?>
-
You can also use a switch, if you want to redirect only for specific instances.
-
<?php if(!isset($_GET['pid'])) { header("location: index.php?pid=0"); exit; } ?>
-
thanks
also what do you use to un md5 it?
Technically, it isn't reversible. So to check the db for authentication, you need to see if the password they entered, equals the hash stored in the database.
-
<?php $password = md5($_POST['password']); ?>
-
Tested mine as well..though change to this to include the 'http'
<?php $string = 'xxxyyyvvvhttp://www.website.com/bbbb/id=1234zzzaaa'; preg_match('/[aA-zZ0-9]+(http\:\/\/[aA-zZ.0-9\/\=]+id=1234)/i',$string,$url); print_r($url); ?>
-
<?php $string = 'xxxyyyvvvhttp://www.website.com/bbbb/id=1234zzzaaa'; preg_match('/[aA-zZ0-9]+http\:\/\/([aA-zZ.0-9\/\=]+id=1234)/i',$string,$url); echo $url[1]; //This is the url you want ?>
-
Your question isn't very specific.
If you plan on developing a site for games...I suggest starting with some PHP tutorials and actually putting aside some time to learning it...instead of looking for code to work with. Otherwise, you'll annoy half the world by troubleshooting every problem that comes up because you never took the time to learn the basics.
Good luck.
-
Missing a closing bracket. The whole thing supposed to be in the while loop? Or did you forget to close that first one?
-
Please post some code so we can help troubleshoot. Thanks.
-
Use regex, my friend. And then loop through your files and delete the ones that match the regular expression.
-
Basically...it's telling you you cant connect to the database.
-
Ah Salis beat me to it. But yeah...using headers. Though if Salis has done this...I would try his example. :-)
-
I do something similar to this with other file types but I don't think I've tried it with images....possibly something like...
<?php fopen('temp/'.$filename,"w"); fclose($filehandle); header("Content-type: force-download"); header("Content-type: jpeg"); header("Content-transfer-encoding: binary\n"); header("Content-disposition: attachment; filename=\"$filename\""); unlink('temp/'.$filename); ?>
You'll have to fill in the blanks and edit it....but maybe something like that can be done using images as well. I don't see why not. (Note: Again, have only tried this with documents and other file types)
-
Yes. You can loop through all the posted data (Except the submit button etc...) and clean it, and check it.
-
Hopefully, you're not sending messages to some terrorist organization...
What is the default character encoding on the server? And I could be wrong but, I believe that the character encoding on the receiving end also plays a part on whether it will be displayed properly.
-
Might seem like a strange question but...why take such an approach to including a file to your script? Even if the function you're including is dependent on the value you're trying to pass to it here...there are easier and less problematic approaches.
-
.htaccess, if you're on an Apache server. But if these are files your other pages/scripts use...they will be prompted for the login from there. (If I remember correctly)
Help with php code
in PHP Coding Help
Posted
Are you getting errors? Is the code not working? Please be specific...and please remember to use the code tags next time.