Jump to content

fema3

New Members
  • Posts

    6
  • Joined

  • Last visited

Everything posted by fema3

  1. Thanks for the replies, I'm not new at coding per se, as I said, I have wrote apps in both C and C++. Mostly very basic, simple task things, mostly procedural. I'm absolutely new at programming in PHP and html. In fact one of the reasons I am trying to learn PHP is that I created a small c program on an arduino, and at some point I want to be able to put that on the web, and use php to access it and analyze or view the data. The analogy of a taking a carb apart probably isn't a good analogy for me, as I did that when I was hs to my small dirtbike that I rode around. Necessity is the mother of all invention I suppose. It never dawned on me that I shouldn't do it for fear of breaking it. I have a book I am trying to follow (PHP and MYSQL by Ullman) and another one by Murach. They take you through very specific examples, I suppose my first thought was why can't I just write some of these myself. A lot of things were similar, but I was stumped as to why it was not doing anything I intended it to do, even though all my code appeared correct (to me anyway). You and mac_gyver are correct that I think what I am missing is that php isn't saving my variables. In trying to do things incrementally. It never dawned on me that the program not only begins, but also ends when the user hits the submit button. I looked at another submit as a continuation of the previous. I had read about "hidden form field" data, but I only glanced at it, it didn't seem like something that was necessary at the time. At least now, I can at least make a few educated guesses as to what's going on. Neither of the books I have really address this, though they all use the hidden fields. Looks like I have more searching and reading to do.
  2. OK. I thought it wouldn't matter where or how the data came from. Initially, I built my form by a function, but I've been trying to remove anything that might causing the problem. Until, I was left with this simple script, and I still don't really understand. I've always done programming in C++, so there is a lot of stuff I really don't understand about php, it seems really confusing to me. So really, what I was thinking, was to take in the heights and weights, as the submit button was pressed. Storing those into arrays, then I could later write some code further down the page that would show what the height or weight of a particular user was (say print out the data in the array at index[y]). But so far, just trying to understand how to put data from forms into an array has been pretty challenging.
  3. ginerjm, thanks for responding. I know that the code isn't checking for validation, nor is it looking for things like safety, xss attacks etc. Right now, I'm working on understanding on how to work with arrays and general basics in php/html. <?php /** * This is the file, untitled.php **/ echo ' </form> <form method="post" action="untitled.php"> <p></p> <label for="height">height:</label> <input type="text" name="height[]" id="height" required="required"> <p></p> <label for="weight">weight:</label> <input type="text" name="weight[]" id="weight" required="required"> <p></p><input type="submit" value="Submit!"> </form> '; // check to see what was sent in post print_r($_POST, true); echo '<br>'; // height and weight sent, now put the height and weight each into an array $h = $_POST['height']; $w = $_POST['weight']; // check the values in each array h and w print_r($h); echo '<br>'; print_r($w); // store h and w into an array of arrays, maybe they will increment this way $hw = array('height' => $h, 'weight' => $w ); // check to see what is in hw print_r($hw); ?> So trying to put the data from the arrays into another array still doesn't do what I want it to do. It is all in the same file, so I could make sure that the data wasn't being sent from one file to another and out of the variable scope. I suppose, what I am fundamentally trying and failing at understanding is how to take the form data and put it (correctly) into an arrray. * edit -added clarity When I wanted to add the values into an array, I don't know why when I hit submit again, it doesn't add those values to the arrays, instead, it simply adds the value to the index = 0 position. I've been rereading my book on php, but it doesn't say much on taking data from a form to an array. Thanks again,
  4. I think ginerjm has solved my problem.. </form> <form method="post" action="check.php"> <label for="height">*Height:</label> <input type="text" name="height[]" id="height" required="required"> <label for="weight">*Weight:</label> <input type="text" name="weight[]" id="weight" required="required"> <input type="submit" value="Submit!"> </form> When I dump the data via print_r($_POST,true); I get both values out of the variable, But yes, I think this is probably exactly the problem. So should I send the variables to the original page, via some hidden type? How can I create and keep the array?
  5. This is one of those things that only you can trouble shoot since there aren't any detailed logs provided. A logfile should have more detail as to why it is being rejected. Some service providers have you log in through their console. This is logging in through ssh, but you still need to setup ssh to log directly into the system. It sounds like you are loggin into their system and using some kind of passwordless login. If that is true, you still need to set up ssh to actually login to the server. Barring that, Host key verification means exactly that. Check that: on your server: 1-Your public key is in the authorized_keys file on your server, (~/.ssh/authorized_keys) ( you should have ssh-copy-id to the server or the server host should have given you a public and private key initially if that's how they roll) 2- the authroized keys file is in the correct format. (look at the keys, each on a newline) 3- your authorized keys file has the correct permissions 0600 on your local box: 4- check that your private key and .ssh folder have the correct permissions 5- check that there are no conflicts in known_hosts ( you would probably see this error though) 6- use the i switch ( ssh -p 2233 -i ~your-private-key -f...) When you start talking about /var/www/.ssh, that's crazy. You login to whatever account you have on the server with ssh. It should be the account you log into, I use root, you might use whatever account that has sudo access, or just a local one with no special access. Look into your /home directory for a list of users if you aren't sure. Your not logging in to apache, and there is no way that apache should be logging in remotely. You are merely creating a tunnel. There is no way that your ssh folder or keys should be owned or readable by www-data. I'd delete that crap out of there asap. Being that they tried to help you get going, I'm going to say that it is likely they don't disallow ssh logins. It sounds to me like you either need to set it up, or you need to use the i switch to make sure you are using your correct key, or you need to check the permissions on your private key. Re-reading.. your 3rd statement, it appears that you need to ssh into your box in the same method as you do your SQLylog. They might not allow key based ssh. if that is the case, you might want to use a password file, or however you log in normally through your SQLylog. There are a lot of if's here, sorry.
  6. Hey guys and gals, I'm new at coding, and I'm having some difficulty figuring out what might be the problem. In words, I'm taking a few text boxes from a html form (such as the user enters a couple of numbers) and put that directly into an array in php. Essentially it is this: <input type="text" name="height[]" id="height[]" required="required"> <input type="text" name="weight[]" id="weight[]" required="required"> a submit button takes the data via post to the calculate.php. There we have $height = $_POST['height']; $weight = $_POST['weight']; print_r($height); So what is going on is that when the user submits , say 55 in the height and 25 in the weight. It as expected gets loaded into the $height and $weight arrays. But when I try to add a new height and weight to the array via a new submit, say 22 and 95, the old values get replaced by the new ones, instead of adding to the $height and $weight array. So it always looks like array[0] => 55 array[0] => 22 What I want it to do is to increment, array[0] => 55, array[1] => 22 ... I check the data coming from POST, it seems to be a string, is it because the array should be numeric and the data coming into the array are strings? My thoughts are that the data from post are being put into a variable, but I just don't think this is right. 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.