| Home | Register | FAQ | Members List | Search | Today's Posts | Mark Forums Read |
|
|
#1 (permalink) |
|
Senior Member
Join Date: Jan 2006
Posts: 146
|
query results in mail function
so i have made a shopping cart and everything works except for the confirmation mail. i already searched the forum and found one similar problem, but that solution doesn't work with me...strangely enough. all i want is to loop results from a uery so the customer gets a confirmation mail with all the items they ordered. when i get the mail, i get all the other info , but not the item name, title or quantity. is it because i misplaced my query or something ? code: PHP Code:
thanx in advance! |
|
|
|
|
|
#2 (permalink) |
|
Registered Abuser
Join Date: Jun 2006
Location: Manchester, England.
Posts: 174
|
What is the problem, i.e. where does the code go wrong? What do the logs say? Is it the mail function that's failing? Have you checked the values of the variables that you pass to the mail function? Also, on a different note, passing user supplied values straight into sql queries is an extremely bad idea because it opens your system up to sql injection attacks. Clean the POST values before setting the variables. |
|
|
|
#3 (permalink) | |
|
Senior Member
Join Date: Jan 2006
Posts: 146
|
Quote:
well, i got the problem half solved. i get one result now. it was the first loop for the $query5 which was the problem...still working on it. yes the mail function works. this is actually the last step in a checkout process. i have checked the input already in a previous step. this is just a matter of passing variables. |
|
|
|
|
#4 (permalink) |
|
Registered Abuser
Join Date: Jun 2006
Location: Manchester, England.
Posts: 174
|
Note that I'm not a php guru. Saying that, after a quick look, I'd say that it's because you're looping through result5 in the email message to output the list of items, but you're not updating name, title or quantity in the loop, which means they'll always be the last value that they were set to. Also, the loop won't loop because you've not reset the row pointer. I'd set a string listing the details of the products when you actually select the orders from the products DB (br_products presumably) then output that string in the email message. |
|
|
|
#5 (permalink) |
|
Senior Member
Join Date: Jan 2006
Posts: 146
|
thanx for your reply, but i got it working 100% now. i removed the first loop. that caused it to override the variables. and i adapted my query so i get all the items, not just one.. so this is my working code. PHP Code:
|
|
|
|
#6 (permalink) |
|
Registered Abuser
Join Date: Jun 2006
Location: Manchester, England.
Posts: 174
|
Cool. Now escape the submitted form data to prevent sql injection. http://us2.php.net/manual/en/functio...ape-string.php |
|
![]() |