-
Posts
6,906 -
Joined
-
Last visited
-
Days Won
99
Everything posted by ginerjm
-
For those of us who can't recognize these outside products it would be nice if posters declared such things.
-
Your call to the mail() function needs 4 things: a to address a subject string a message body string a headers string The to address s/b something like: $to = "you@domain.com"; The subject $subj = "My email subject"; The message body: $body = "This is my message\nHere is the second line of it\nhere is the 3rd."; The headers: $headers = 'From: me@mymail.com' . "\r\n" . 'Reply-To: me@mymail.com' . "\r\n" . 'Bcc: someone@theirdomain.com'; The call is then: mail($to, $subj, $body, $headers); Pretty simple.
-
Of course it is. Write a query to select the specific RECORD that you are curious about and then retrieve the result (a row) and examine the column in that retrieved row. Do a little research in the php manual on how to use PDO as your db interface. (Or mysqlI, if PDO is n/a.). You'll need to setup a db connection, write a query, run the query and then fetch the result. (Be sure to write your script so that you do checks on each of those ops to ensure that they succeed before blindly moving to the next stage.) All good things to learn as you (apparently) begin your programmer training.
-
You are definitely not reading the manual's examples for how to do this. You execute your query twice - did you know that? Also - try turning on php error checking to see what errors may be troubling you. See my signature.
-
You still need to sanitize your input values before putting them in a non-prepared query.
- 13 replies
-
- php
- mysql database update
-
(and 1 more)
Tagged with:
-
The code as you posted it doesn't work. Typing the name of the array as a one word sentence doesn't do anything. To post it in the forum with no explanation is just plain improper since it is meaningless. Ok - so you have to input element sets using arrays to collect their values. What happens when the user enters an id in one element but enters no value for it? Then he enters another id and its matching value? Your array will be off by one place since the un-entered value element will not arrive at the server so your two arrays will be out of sync. Of course I'm sure that you are validating all of your input, arent' you? And as I said before and Mac_gyver as added to, you aren't running any queries in this code that you have showed us. Perhaps you want to share the rest of your code with us as I also said before?
- 13 replies
-
- php
- mysql database update
-
(and 1 more)
Tagged with:
-
OK - please explain the first two lines to me: $arrayIDs; //array containing database table IDs $arrayVALUES; // array containing update data What do you think those lines are doing for you? They do nothing for me! Now this line: $combine = array_combine($arrayIDs, $arrayVALUES); The same issue that I mentioned earlier here. How do you know that the items in each array are EXACTLY corresponding? If you can truly ensure that they do match then you can stick with your original approach, but if not this new approach isn't any better. To finish with your code, this is your query. Where do you execute it and how do you know what the results are: foreach($combine as $key => $value)){ $element = "UPDATE TableToUpdate SET newUpdateData = '$value' WHERE ID = '$key'"; Your loop builds a query using the items in the array. But you never run the query. At least not in this code snippet. Care to share?
- 13 replies
-
- php
- mysql database update
-
(and 1 more)
Tagged with:
-
You didn't REALLY use the above code? It couldn't do what you want. Also - problem with your approach is you have to be absolutely sure that the two arrays are in sync and that item x in one array does in fact correspond to item x in the other array. A better approach might be to use an associative array such as $items[$id] = $value; Now you can simply code foreach($items as $k=>$v) { // do your code to use $k as the id and $v as the value for each pair }
- 13 replies
-
- php
- mysql database update
-
(and 1 more)
Tagged with:
-
This might be more appropriate on a different forum that serves those who need to hire help. PhpFreaks does in fact have one of those.
-
While Barand did trash my example, I structured it for the OP's apparently limited understanding. A firs-time solution that hopefully he would learn many things from and then learn how to properly structure a db.
-
New to php, can't get a form to email data?
ginerjm replied to ChrisCCPHP's topic in PHP Coding Help
That is the idea, yes. BUT - you need to validate all of the POST fields to be sure that they are valid answers and that they are not filled with malicious data. Consequently, they will probably not be $_POST values afterwards, but local vars that you have created as part of your checking process. The mantra of all programmers is "never trust user input". That means you have to check if the answer is what you expect. If a field asks for a Yes or No answer, you have to check and make sure that it is Yes or No. Same with a phone number - check that it is numeric and has the right number of digits. Do some reading on validation and filtering of data input. Check the manual for "types of filters". -
You said something about "static". I assume that you are saying the questions will be static, ie, the same all the time. Setup two tables for this questionnaire alone. Have each question in a column in table 1. Name them as Question1,Question2, Question3... In your second table define the columns as Answer1, Answer2..... and then build your questionnaire form using the cols from table 1. When the user posts the form back you would collect the answers, validate them and ensure that you have answers and then store the results into each column in table2. If you are using checkboxes set the values of them to Yes and No in the html and then simply store the values into the table. Hopefully I understood your question.
-
New to php, can't get a form to email data?
ginerjm replied to ChrisCCPHP's topic in PHP Coding Help
He's saying that all those data fields you put in your mail call are incorrect. All that data should be part of your "message" not added in to the function call(which won't work as you are doing it). I don't know what you mean by "a way to return the additional parameters". -
hth!
-
The use of the .. is completely wrong. Just look at the path in the error message that you get - doesn't it look wrong to you? Secondly - are you sure that there is a file named "membersite_config.php" in the folder: "/home/ebspma/public_html/include"?
-
You use the multicell function for just this purpose! Of course you have to save the current y position and do a sety to get back to the "top" line again after each one. PS - your output might end up more readable if you didn't center all the columns. Especially text ones.
-
In the error message does the path noted as the place where the doc is NOT found (and filename too!) agree with your own manual (ie, visual) inspection of your server's file system?
-
Hmmm, I copied your files and uploaded them to my server. They worked just fine when I filled in all the fields. When I didn't though the message came out with a bit of garbage at the start of it. That anchor tag I suspect. So I removed it. What is the purpose of the anchors in front of your messages, or don't you know? PS - It is recommended to use the appropriate array to search for your inputs. Since you know it is coming from $_POST, why do you look in $_REQUEST?
-
Way too much code to look at. Are you using the MultiCell function?
-
I couldn't agree with mac_gyver more. He said it in a way better tone than I would have projected. Ian(?) - you are prolific in your posts but as said already you don't seem to be learning anything. Why is that? Are you familiar with the PHP manual at least? Or perhaps some other books/manual/references that you are using to build your knowledge and skillset? If not - you apparently need to do so. The "dive right in" approach is not working for you.
-
You open the file. Then you start a foreach loop but in each iteration you close the file. I'm surprised you have more than one entry in the file. And you obviously are getting errors. Turn on php error checking to see.
-
You could simulate this 'conversation' by sending your beginning screen with a couple of buttons on it that will send the user's input back to the script. When the script is called it checks which button was clicked and decides what to do for you based upon that. Once your work is done your script can then send a new screen back to the client and await the next response. (I keep forgetting about the command-line PHP. Probably because I have never used it.)
-
Um..... You must be new at this PHP stuff. PHP runs on the server and doesn't have a "user interface". Consequently you cannot pause a script and await a keypress of any other user input. What you want is probably some kind of JS code that does what you want, but in that case it would be not so much of a "pause" but rather an "event handler" that gets triggered by a 'keypress' or 'onclick' event.
-
Parse error: syntax error, unexpected 'exit' (T_EXIT)
ginerjm replied to chiranjiv's topic in PHP Coding Help
Actually the braces are not required for this usage of the if statement. As I said in a different forum, try adding the parens to the exit call.