Jump to content

davidannis

Members
  • Posts

    627
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by davidannis

  1. try if (trim($row['has_email'])!='') to see if it is blank instead of just if ($row['has_email'])
  2. You should be getting the name from a form with an input field. You can default the value to Quest <form method="POST" action="myscript.php"> <input name="fname" type="text" value="Quest"> <input type="submit> </form> If you don't want the user to be able to change the value easily use type="hidden" instead of text. If you don't want the user to control the value then don't put it in the $_POST array.
  3. I generally like to have a few common files sets globals, opens db connections, etc header footer functions that are used by multiple programs then I have separate files and include the common ones.
  4. You should be able to use http://pear.php.net/package/Mail_Queue/
  5. I think I recognize the problem. Looks to me like you are using Tectite's formmail but are many versions back. As an alternative to fixing it yourself, you could upgrade to a newer version at http://www.tectite.com They've added some new features.
  6. I believe that if you mix mysql access methods in the same script your programs won't work so choose PDO, mysql, or mysqli now and stick with it.
  7. OK, something like this: if (isset($_POST['add_friend'])) { // don't bother checking for a duplicate unless $_POST['add_friend'] is set //meaning put code in here //The next line sanitizes the email. If you don't do this and I put "david@david.com ; TRUNCATE competition" in the form e-mail field then I just erased your table. YOu need to sanitize every piece of data you run through mysql. $email=mysql_real_escape_string($_POST['email']); $sql="SELECT email FROM competition WHERE email='$email'"; $result=mysql_query($sql,$connection); if (mysql_num_rows($result)>0){ die ('oops, that e-mail is in our database already'); }else{ $sql="INSERT INTO competition (title, name, surname, phone, email) VALUES('$_POST[title]','$_POST[name]','$_POST[surname]','$_POST[phone]','$_POST[email]')"; } if (!mysql_query($sql,$connection)); { die('Your details have been added to the system' . mysql_error()); } mysql_close($connection); } ?> I took a quick stab at illustrating what i meant. I did not change your code
  8. You have the idea right. You can put the code to check for an existing e-mail inside if (isset($_POST['add_friend'])) { as cyberroot said use one method to access the database, don't mix and match like you did in your example.
  9. mysqli can be used almost exactly like mysql in terms of coding with only a few minor changes. If you are coding from scratch you may as well use it.
  10. Before you do the insert do a SELECT email FROM competition where email='$_POST' and if the number of rows returned is >0 then die ('e-mail address already in database'); // or whatever custom message you want You also need to sanitize your data before using it in SQL. See http://php.net/manual/en/function.mysql-real-escape-string.php for more detail. If you don't you'll be hacked with an SQL injection attack.
  11. DavidAM is right and don't forget session_start(); if you are using sessions.
  12. <?php include '/pathtoheader/header.tpl';?> Your page content here <?php include '/pathtofooter/footer.tpl';?>
  13. If you are just storing a large blob of text use the text or blob type. http://dev.mysql.com/doc/refman/5.0/en/blob.html
  14. What is the field length/type of the field you are storing it in? Is it the data at the end that you are losing? My guess is it is being truncated because you have a lot of characters and a field that won't hold them all.
  15. vinny42, Hex values are base 16, OP wants to use base 62.
  16. Looks to me like you set the value of $con only when the form is submitted with a button that has the name edit but use it when the form is submitted with the name edit_multi.
  17. I find it difficult to believe that it makes sense to have the overhead of converting to base 62 numbers just to shorten he ID. A 10 character number gives you a 10 billion possible records, a 13 character number give you 10 trillion. However, if you need to do it, the way to do it is documented here. A mysql bigint (unsigned) column would allow you 18,446,744,073,709,551,615 records. That's 18 quintillion if I remember number names that big correctly.
  18. oops, sleep deprived and working fast $c='php -f file'.$x.'.php'; $process = new BackgroundProcess('sleep 5'); should be: $c='php -f file'.$x.'.php'; $process = new BackgroundProcess($c);
  19. To modify the code that I pointed to to execute 100 files per your original post try something like namespace Bc\BackgroundProcess; class BackgroundProcess { private $command; private $pid; public function __construct($command) { $this->command = $command; } public function run($outputFile = '/dev/null') { $this->pid = shell_exec(sprintf( '%s > %s 2>&1 & echo $!', $this->command, $outputFile )); } public function isRunning() { try { $result = shell_exec(sprintf('ps %d', $this->pid)); if(count(preg_split("/\n/", $result)) > 2) { return true; } } catch(Exception $e) {} return false; } public function getPid() { return $this->pid; } } //It’s now relatively easy to execute a command in a background process: use Bc\BackgroundProcess\BackgroundProcess; for ($x=1 ; $x<101 ; $x++){ $c='php -f file'.$x.'.php'; $process = new BackgroundProcess('sleep 5'); $process->run(); } of course, this example does nothing with the output from those 100 php files.
  20. Your site may have been hacked and the page index.php is being used to deliver malware. Check your site carefully.
  21. The solution: <img src="run-in-background.php" border="0" alt="" width="1" height="1" /> will run your one script in the background. To run 100 scripts, you'd need 100 images. You also would leave yourself open to running a server out of resources running 100 scripts on each page load with no check to see if the user already set off 100 previously and is reloading the page. I would recommend following the link I provided in post #2 and using php to kick off background processes after making sure a user doesn't already have 100 processes running.
  22. If you look at the logs are the requests coming from a reasonably small group of IP addresses. You may be better off blocking by IP address. Looks like you have a denial of service attack, which can be difficult to defend against. For more information on DoS attacks see https://www.us-cert.gov/ncas/tips/ST04-015
  23. I think that perhaps the line include_once("./koneksi.php"); opens the database connection or tires to. You need to make sure that the database is up and running, know the user and password, and then look at or post the code in that file.
  24. I think that mac_gyver has found the problem. You are using the wrong variable in: $numrows = mysql_num_rows($query); it should read $numrows = mysql_num_rows($result);
  25. While I understand the intent of the limitations on the freelance postings I think that perhaps they should be relaxed. I posted a thread offering free programming for non-profits and it has worked out well for me. However, after a couple months I would love to be able to go in and edit it to change the title to something more relevant to the content of the post and to remove a reference to future availability that is now in the past. In a few more months, I'd bet searchers will begin not to look at freelance posts that old, and in a year I may have skills that I don't have now that I'd like to offer. Could the restriction be relaxed to allow a user to update their post quarterly?
×
×
  • 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.