Jump to content

jazzman1

Staff Alumni
  • Posts

    2,713
  • Joined

  • Last visited

  • Days Won

    12

Everything posted by jazzman1

  1. Does your provider provide you a smtp relay hosting? What's the name of your hosting provider?
  2. Use swiftMailer. This line of code is correct: ->setFrom(array($post->email => $post->name)) // From:
  3. You don't have to pay extra money to approach that. I would recommend you using mysqldump via ssh tunnel to encrypt the dump data and a cron job to run the dump file on a schedule. Take a look at this my simple script written in BASH: #!/bin/bash DBHOST="dbAddress" DBUSER="dbUser" DBPASS="dbPass" DBNAME="dbName" NOW=`/bin/date +%Y%m%d` DIR=$(dirname $0) if [ ! -d $DIR/$NOW ];then mkdir -p $DIR/$NOW;fi ssh userName@domainName -p 22 mysqldump --host=$DBHOST --user=$DBUSER --password=$DBPASS --protocol=TCP \ --port=3306 --single-transaction ${DBNAME} > ${DIR}/${NOW}/$NOW.sql tar zcf ${DIR}/db-$NOW.tgz ${DIR}/${NOW}/$NOW.sql rm -rf ${DIR}/${NOW} If you have more then one database hosted on the same DB sever you could use a --all-databases flag. You need to set up a trusted ssh connection between the client and server to allow logging into a host(server) without needing a password.
  4. No, it's just fine
  5. In fact, I've tested the script before to post it. What debugging steps have you taken so far? Did you get some error messages?
  6. Use character setting instead a set names sql command: $dbh = new PDO("mysql:host=$dbhost;dbname=$dbname;charset=utf8", $dbuser, $dbpass); Why do you want to store html markup inside DB and latter on you want to avoid of dispalying them?
  7. Ah....you're storing the results in the text file. I was thinking that you are trying to save a data inside a session array
  8. Why do you want to use a session if you're planning to use the same user account from different machines or browsers? The session's life is expired (delete) when you close a browser window and the current unclosed session data will be overriden if someone try to start a different session with the same account. You need to use cookies with expired time to do that and then that the same cookie data is going to be sent to the same user with different machines (browsers). You have to show us your own script as well.
  9. This is a brief sample from me how to make multiple inserting values in the database. insert.php <?php $filename = "posts.txt"; $fd = fopen($filename,"r"); $contents = fread ($fd,filesize ($filename)); fclose($fd); function explode_assoc($glue1, $glue2, $array) { $array2=explode($glue2, $array); foreach($array2 as $val) { $pos=strpos($val,$glue1); $key=substr($val,0,$pos); $array3[$key] =substr($val,$pos+1,strlen($val)); } return $array3; } //usage: $inventoryarray=explode_assoc(" ","\n",$contents); ?> <table border="0" cellpadding="2"> <thead> <th align="left">PartNumber</th> <th align="left">PartDescription</th> <th align="left">CurrentInventory</th> <th align="left">OrderQuality</th> </thead> <form method="post" action="post_data.php"> <?php foreach ($inventoryarray as $key => $value): ?> <tr> <td><input type="text" style="border: none;" name="partNum[]" value="<?php echo $key; ?>" /></td> <td><input type="text" style="border: none;" name="PartDesc[]" value="BAR BUS" /></td> <td><input type="text" name="currentInv[]" style="border: none;" value="<?php echo $value; ?>"</td> <td><input type="text" name="someName[]" value="0" /></td> </tr> <?php endforeach; ?> <tr><td><input type="submit" value="Go!" /></td></tr> </form> </table> posts.txt 12006GD16P 37 13406BP16H 217 13406BP16P 197 13406BP16T 516 13406BP16W 75 13406BP16Y 0 13406BP17D 171 13406BP17H 33 13406BP17N 191 13406BP17P 0 13406BP17T 43 4176B76H01 30 4176B76H06 100 4176B76H07 550 4180B53H02 200 4180B53H03 446 4180B53H06 75 4180B53H07 200 6563C02H01 350 6563C02H02 165 6563C04H01 170 6563C04H02 75 posts_data.php <?php //print_r($_POST); exit; // build query... $sql = "INSERT INTO `tbl_name`"; // implode keys of $array... $sql .= " (`" . implode("`, `", array_keys($_POST)) . "`) VALUES"; // count an array keys $count = count($_POST['partNum']); // loops values of // multiple dimensional array; $i=0; while ($i < $count): $sql .="("; foreach ($_POST as $col) { $sql .= "'" . $col[$i] . "',"; } // trim the commas between sections $sql = rtrim($sql, ','); $i++; $sql .= "),"; endwhile; // trim the last comma from the string $sql = rtrim($sql, ','); //execute the query to db //mysql_query($sql, $conn); echo $sql; RESULTS: Create your database table with auto_increment id field and try to insert the data. Note; There's a lot more you should be doing (sanitize data, etc....), but I've not the time to get into all of it right now.
  10. The easiest way is to join these two tables and to use IN sql operator: SELECT `t1`.`desc` FROM table1 t1 INNER JOIN table2 t2 ON (t1.pid = t2.pid) WHERE t2.cat IN (101,102) Desc is a reserved word in mysql! You should avoid using reserved words as names of table columns.
  11. In addition what mac and Barand said when you are using a sha256 algorithm you should also know of what length field you'll need to store this hashing string in the database.
  12. Change, isset($_POST['submit'])) to isset($_POST['submitButton']) // add an exit command to terminate the script // when the page has been redirected // redirect to confirmation header('Location: http://www.bonnersmu...ank-you.html'); exit; You should also spend time to learn more about debugging process!
  13. You're doing it wrong man! Are you sure that the script with a basic file reach this include function? Can you show us both files, please?
  14. You are just a web developer. The traffic to db could come from many different points of the server. Don't worry to much about that This is a DBA's or sysadmin's job. About the indexes, we cannot help you again unless you want to show us database schemas and provide us some details about applications.
  15. The path to the index is correct - $data['category'][0].
  16. Make some effort man. @Ch0cu3r did the hard part of the code for you, all you need to do is to define username, surname,name and mails variables like user_id and to redirect the page.
  17. @Nightasy, read this article.
  18. Example, please
  19. You've gotta be kidding
  20. 1. Use some php mail library to do this, as @fastsol said phpmailer is just fine or personally, I prefer swiftMailer. 2. You should buy a unique IP address for our shared hosting (GoDaddy provides that). That means, nobody with any other accounts on the same server could use this IP even you're sharing the same DNS and DNS records are being propagated somehow on the web.
  21. I think here you should have to return $row['user_id'] from your database table instead just true; function logged_in(){ GLOBAL $dbc; return(isset($_SESSION['user_id'])) ? true : false; }
  22. Yep, I mean to run nmap from your local PC! Server 2 should be reachable by port 389, but not sure if this port is not filtered. PS: Are you using windows for home PC? Try to run ldap but be careful about php syntax: <?php echo 'start'; $host = 'server 2 ip address'; $port = 389; $ds = ldap_connect($host, $port); echo 'success!'; Go to the php.net website and take a look at examples how to check if the connection of ldap is success or fail. Never use php to do this before.
  23. So, run nmap from your local server terminal and give me the output of: nmap -Pn -p 339 ip_address_of_server2
  24. Yes, agreed! I just wanted to say him that the warnings coming from this database library don't stop the script from the flow of execution without die() or some other exit methods.
  25. You're wide open to SQL injection attacks. Every decent PHP tutorial on the web which shows how to deal with databases should start with this. Your script doesn't have error checking logic in it. Check on the web, how to php_error_reporting and mysql_error use. Read the big warning message about php mysql library! About the question how to display the output of the variable, try to echo it using a proper syntax as well. <p align="left">"<?php echo $_POST['tchr_id']; ?>"</p> -- here I want to display the ID since it can't be updated. PS: If you want to update some existing records in a table, you should call SQL UPDATE statement not SELECT!
×
×
  • 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.