Jump to content

billckr

Members
  • Posts

    14
  • Joined

  • Last visited

    Never

Everything posted by billckr

  1. You use the same method as before; <select name="payment"> <option value="<?php echo $_POST['payment'];?>" selected><?php echo $_POST['payment'];?></option> Change _POST to _GET if using URL and Not a form. The above keeps the value from the post data and makes it the selected option so it shows just like it did on the prior form. Not 100% thats what your asking but if so, there you go. Bill.
  2. Give us the context of what you are trying to do and I think we can give you better help unless taquitosensei's answer is what you needed.
  3. You don't want to be doing this with PHP. This is a good for Apache or mod_rewrite or what ever web-server software you are using. You could use something like; RewriteEngine On RewriteCond %{SERVER_PORT} !443$ RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R,L] if you really want to use php perhaps something like; if($_SERVER['SERVER_PORT'] != '443') { //Force SSL upon this page header("Location: https://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']); } However, neither of these solutions will ensure that any item on the page it called via SSL. The only way to ensure that is to include it via SSL in the code and using SSL via the web browser. Any item like an image called from say; <img src="http://mydomain.com/images/myimage.jpg" /> Will be insecure because it wasn't called via https, but http, and the users browser will allow access to the page but give them a choice to not load that image. hope this helps. Perhaps others have better solutions.. Bill.
  4. OK, I'm still not sure what I'm doing wrong here. I've tried every way I could think of. I really appreciate everyone's patience. Would someone be so kind as to "using the example below" show me how to pass the connection info from my config.php into the function below so I can use to select data from a database. config.php <?php $DBHost="localhost"; //* Database Hostname $DBName="dbname"; //* Database Name $DBUser="dbuser"; //* Database Username $DBPass="dbpass"; //* Database Password $db = mysql_connect($DBHost, $DBUser, $DBPass); mysql_select_db($DBName); ?> Fuction: <?php /* Select Clients from DB */ function client_select() { $result = mysql_query("SELECT FirstName FROM some table"); while ($row = mysql_fetch_array($result)) { echo $row['FirstName']; echo "<br />"; } mysql_close($con); } ?> So, the question is: How can I modify the function above or otherwise get the connection information from the config to it so I can place this fucntion in any place or any page that has my config.php included? Thank you for the assistance.
  5. Ok, now that I know how to ask the question, I can find the answer. I think I need to be doing something like this. http://kimbriggs.com/computers/computer-software/php-mysql-connection-function.file
  6. I don't think I switched what I was talking about. If I was misleading I apologize. Ok I think that is what I'm asking. How do I do this?
  7. PFMaBiSmAd, Thanks for the reply. I'm glad to know that's how it's supposed to work but currently it's not 'could be my fault'. Using the config above if I have a funtion that like the below I get an mysql connection error that apache@localhost cannot connect meaning that it's not picking up my connection info for the config.php even if the function is written inside the actual config.php itself. <?php /* Select Clients from DB */ function client_select() { $con = mysql_connect("$BDhost", "$DBUser", "$DBPass"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db($DBName, $con); $result = mysql_query("SELECT * FROM some table"); while ($row = mysql_fetch_array($result)) { echo $row['FirstName'] . " " . $row['LastName']; echo "<br />"; } mysql_close($con); } ?> Any thoughts?
  8. Greetings all, I like to make a config.php file and place it outside my document root for security. I do this all the time. Then just inlcude the config in any file that I need information for. include('../includes/config.php'); This works most of the time for any DB connection information a piece of code might need. However, sometimes I like to place all my functions in a file called functions.php to keep them separate and have a single place to work with them. I have not done any coding in about two years and just started back and for the life of me I can't get any connection attempt inside any of my functions to use the DB connection info from the config.php even if I include the file right inside the functions.php at the top. Even when I put all my functions inside the config file itself they still have no access to the connection vars. I remember that I used to be able to use a global so some type to do this. The important part is getting DB connection access to any functions that I write. Here is an example of a plain config that I might start with; //* Database connection information.. *// $DBHost="localhost"; //* Database Hostname $DBName="some_db"; //* Database Name $DBUser="some_user"; //* Database Username $DBPass="some_pass"; //* Database Password $db = mysql_connect($DBHost, $DBUser, $DBPass); mysql_select_db($DBName); Can someone show me where I'm going wrong and the modern excepted method of doing this? I would greatly appreciated it!! Thank you.
  9. I tried what I thought was this exact thing several times. Clearly I had something out of place. Thanks BillBob!
  10. Both of these work out of the box but I'm having a devil of a time getting the results into the drop down menu. It's because they are in an array I guess. Might I ask for a small example that I could work with? Thank you very much.
  11. Thank you both. Sorry for the delay in replying i've been on Plane all day and just landed. I'll try these out this evening and report back the results.
  12. HI, I am trying to use scandir and place the results of the array in a drop down. Firstly I would like to exclude anything but directories if possible. There will be several .php and .html files in the directory that I would like to leave out of the results as well as the "." and "..". Maybe scandir is not the best options with these requirements? The code below prints out the results using echo or print just find, but it's the whole array and not just the names of the folders. Array ( [0] => . [1] => .. [2] => 2006-12 2006-12 is the name of one of the folders I want. How can I get the results of ; $dir = '/some/dir'; $files1 = scandir($dir); into a drop down with just the folder names? Thank you for your help.
  13. Thank you very much for both answers. While neither one would work 100% for me, I used to 2 examples and this is what is working for me now. // force to download a file $file = pathto/content/$download/$thefile"; header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/force-download"); header( "Content-Disposition: attachment; filename=".basename($file)); header( "Content-Description: File Transfer"); @readfile($file); Thank you again!
  14. Hi all, I've created a document system that allows our company to upload files and create documents for internal use. I've completed the system except for the download system. When a user uploads a physical file say a .xls it's uploads outside of the home dir so it's not accessible via the web to anyone. I'm trying to figure out the standard method for creating a download link for such a file. what it's the most common method for this? How can I cause the header or browser to call and then dowload the said file? Thanks for any help.
×
×
  • 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.