Jump to content

jvalarta

Members
  • Posts

    42
  • Joined

  • Last visited

    Never

Everything posted by jvalarta

  1. How about something like: if ($HTTP_REFERER == 'paypal.com/address') {     //update db } I suppose if the referrer address is from paypal, but not always an exact string, you could use strpos() to determine if "paypal.com" is at least in the referring address.
  2. That's a long wish list for not knowing PHP. I would suggest trying to find something off the shelf that you can tweak, maybe from hotscripts.com. I don't think you're going to get anyone here to give you chucks of pre-written code, tailor made to your request. Sorry.
  3. You have to have an if/else statement so that it chooses one of the options as the SELECTED choice. You have a multi-select form field...do you need the query to build based on more than one choice? If so, you're going to need more logic when you build the query string itself.
  4. You do need to tell PHP which variables are to be stored in the session, two ways to do this: session_register('var'); or $_SESSION['var'] (I believe session_register is the old method in which to do this)
  5. Yes, using sessions is a good way to do this. The biggest error made here is not to declare the session. you should have this at the top of every page you wish to use session variables within: session_start();
  6. Use an Array to build your HTML SELECT menu...something like this should do it: [code] <SELECT NAME="PullDownID"> <OPTION VALUE="">Choose... <? $PullDownArray = array ( "1" => "One", "2" => "Two", "3" => "Three") while (list($key, $var) = each($PullDownArray)) { if ($PullDownID == $key) { echo "<OPTION VALUE=\"$key\" SELECTED>$var\n"; } else { echo "<OPTION VALUE=\"$key\">$var\n"; } } ?> </SELECT> [/code]
  7. Yes, use the mktime function to turn the dates into unix timestamps...do the math (subtract one from the other) then use date() and mktime() to format the time difference however you need. http://php.net/mktime http://php.net/date [code] $MyDate = '2006-08-01 10:30:45'; $diff = time() - mktime(substr($MyDate,11,2),substr($MyDate,14,2),substr($MyDate,17,2),substr($MyDate,5,2), substr($MyDate,8,2), substr($MyDate,0,4)); $DaysGoneBy = ($diff/86400); [/code]
  8. Im not sure this is a PHP question -- sounds more like a javascript question...ONCLICK, blah blah blah.
  9. You have to make the page "sticky", meaning, the page has to know what the last query was...by way of remembering the variables. You could do this by simply appending the variables in a GET string to each link (how I often do it) or use hidden HTML fields within a form to store the query variables (then you need a big of javascript for onclicks to execute the form action). Bottom line, you have to rebuild the query in in it's entirety each time the user clicks.
  10. Well, a couple of thoughts: - You are not required to specific MYSQL_ASSOC in the mysql_fetch_array function. If you take it out, you will be able to call variables both ways, i.e. $var and $row[1] - I use the extract function (http://www.php.net/extract) and it works great. Here's a very basic example example: [code] $sql = "SELECT * FROM table"; $result = mysql_query($sql); while ($row = mysql_fetch_array($result)) { extract($row); } [/code]
  11. Add this to the top of your script: [code] <? if(!isset($_SERVER['HTTP_USER_AGENT'])){   exit; } if(!$_SERVER['REQUEST_METHOD'] == "POST"){   exit;    } ?> [/code]
  12. INSERT INTO users (username,password,name,email) VALUES ('$username', '$password','$name','$email')
  13. Adding this to your httpd.conf will prevent files with these extensions from being loaded directly: <Files ~ ".pdf$">   Order allow,deny   Deny from all   Satisfy All </Files> '...drkstr' is also correct, that's a good way to go also.
  14. If you are going to create a number that needs to last for 24 hours for any user who visits, you need to store that number somehwere -- a flat file or a database. You can't use a session, or cookie, as that's a per user variable. The example I gave you would pick a number and store it in a flatfile...then you can very easily just read into a web page. And as for the cron, if you want to automate this, you really need to use a cron to have it kick off whatever process you end up choosing to create the number. I don't know of any other method that you could automate something like this. i suppose to could create a quasi-daemon in PHP by creating a loop and using sleep()...but this is hooky at best. Good luck.
  15. If you are concerned that people could just path to the file, i.e. domain.com/path/to/your/files/file.blah ... then you could just config apache to not allow this (dont allow files with certain extensions to be loaded. Then, you are secure, just use PHP to start the download -- and then you can auth the user to ensure they are legit to be downloading that file.
  16. Well, you could do something like this: 1) Create a cron to run every 24 hours to call a file that does this: 2) $RandomNumber = rand(1,100); //PICK A NUMBER BETWEEN 1-100 $NumberFile = fopen("numberfile.txt", "w+"); //CREATE A FLATFILE TO STORE THE RANDOM NUMBER fwrite($NumberFile, "$RandomNumber"); //WRITE THE NUMBER TO THE FILE fclose($NumberFile); //CLOSE THE FILE 3) Have your script read the flat file "numberfile.txt"
  17. PHP's mail() function relies on sendmail, which may not be working correctly on the host's server. You could email them about this and might get their help, or, you could use an SMTP class, such as PHPMAILER (which Ive used and it's easy and great) to route messages to an SMTP mail server, instead of using sendmail, which in my experience, can be unreliable.
  18. see this post, I think it contains everything you need: [url=http://www.phpfreaks.com/forums/index.php/topic,105395.0.html]http://www.phpfreaks.com/forums/index.php/topic,105395.0.html[/url]
  19. Well, the .htaccess security is a great way to go. If this is a pain, you could build a login/password system with php and to authenticate, you could use a session, and to ensure it's security, use $_SESSION['var'] vs $_POST or $_GET which could be easily fooled. Im no expert, but in my experience, securing a directory with apache (via .htaccess) is a pretty safe way to go.
  20. I built something about a couple years ago that did this exact thing. here's a some bits and pieces. If you need more, let me know. [code]// GET IMAGE ATTRIBUTES list($ImportWidth,$ImportHeight,$ImageMimeType) = getimagesize($import); // CHECK IMAGE MIME TYPE TO ENSURE IT'S A JPEG if ($ImageMimeType != 2) { echo "<FONT FACE=\"verdana,arial\" SIZE=\"1\"><B>Upload Error:</B> This image does not appear to be JPG format."; if ($ImageMimeType == 1) {$WrongType = 'GIF';} if ($ImageMimeType == 3) {$WrongType = 'PNG';} if ($ImageMimeType == 4) {$WrongType = 'SWF';} if ($ImageMimeType == 5) {$WrongType = 'PSD';} if ($ImageMimeType == 6) {$WrongType = 'BMP';} if ($ImageMimeType == 7 || $ImageMimeType == 8) {$WrongType = 'TIFF';} if ($ImageMimeType > 8) {$WrongType = 'UNKNOWN FORMAT';} echo "<P>It appears to be a $WrongType. Please upload JPG format only."; echo "<BR><BR><BR><BR><CENTER><INPUT TYPE=\"button\" VALUE=\"Close\" ONCLICK=\"window.close()\"></CENTER>"; unlink($import); exit; } // CHECK FILE WIDTH and HEIGHT FOR ACCURACY if ($ImportWidth > $ImportHeight) { if ($ImportWidth != 1125 && $ImportHeight != 675) { echo "<FONT FACE=\"verdana,arial\" SIZE=\"1\"><B>Upload Error:</B> The image you are uploading is not the proper size."; echo "<P>It appears to be $ImportWidth x $ImportHeight."; echo "<P>It should be 1125 x 675 for a horizontal card at 300dpi. <P>Please correct and re-upload.</FONT>"; echo "<BR><BR><BR><BR><CENTER><INPUT TYPE=\"button\" VALUE=\"Close\" ONCLICK=\"window.close()\"></CENTER>"; unlink($import); exit; } } else { if ($ImportWidth != 675 && $ImportHeight != 1125) { echo "<FONT FACE=\"verdana,arial\" SIZE=\"1\"><B>Upload Error:</B> The image you are uploading is not the proper size."; echo "<P>It appears to be $ImportWidth x $ImportHeight."; echo "<P>It should be 1125 x 675 for a vertical card at 300dpi.<P>Please correct and re-upload.</FONT>"; echo "<BR><BR><BR><BR><CENTER><INPUT TYPE=\"button\" VALUE=\"Close\" ONCLICK=\"window.close()\"></CENTER>"; unlink($import); exit; } }[/code] You will need GD installed, of course. As for renaming the upload file, here you go: [code] //copy the file to permanent location copy($import, "path/to/images/$VarName.jpg"); [/code]
  21. How about a cron on ANOTHER server, and execute via a full URL?
  22. Ok, I see. I could use exec() but I don't quite understand the syntax. I went to php.net/exec but that's no clearer. Can you explain how I say foo=bar&etc=blah using exec?
  23. When starting a PHP script (myscript.php) from command line, it gives me the PID, great.  So my challenge is to build another PHP script (checker.php) that a cron fires off every so often to check to make sure the main PHP script (myscript.php) is still running, and if not, kick it off again. Any ideas? I'm stumped and have googled the heck out of this with no luck.
  24. QUESTION 1: Q-- Is it possible to append GET variables to a PHP string via command line? I can not get this to work: > myscript.php?f00=1&bar=2&etc=blah QUESTION 2: When I start a PHP script via command line, it runs fine, until I close the terminal window (then it dies). If I do this, it returns a prompt, but still dies if I close the terminal window: > myscript.php & Q-- How can I start a PHP script to run and then be able to close the terminal window and have it continue to execute?
  25. Yes, I meant to comment on this. I tried the exec method -- I kept recieving "unable to fork" PHP error and all references I found to this error were Windows related, and I'm on a LAMP box. Any suggestions? I do think this just might be the solution!
×
×
  • 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.