I have a script for my web form which logs the data to DB and also emails me the data once submitted. When I fill out the form and hit send, the script logs the data to DB and sends me an email but the email is completely empty. I have fetched the array of the form elements and double checked my script but I am missing something for sure.Does anyone have any ideas?
Table 1 is below. I also have another table where value is 2. I am using the same script for both forms on the same page. I am receiving the email with subject only. No contents…
How about changing the structure variable name $table to $content both in table building and within $body (NOT IF CONDITIONS) and for a test just return $body.
My DB tables are named “contact_requests” and “bayi_basvurusu” I used “one” and “two” in my form structure as hidden input names to differentiate the forms from each other and used them to send the incoming entries from the form to the correct MYSQL tables. I am no expert at this thing maybe there was a better way to do it (there probably is )I will make the changes right now and let you know how it goes. Btw, I appreciate the help.
I made all the changes but I am not sure if I broke something as I have received the following error:
Error: Invalid Data given.You have an error in your SQL syntax; check
the manual that corresponds to your MySQL server version for the right
syntax to use near ‘WHERE id=3’ at line 1
With the previous script everything works fine but only it doesn’t send the data.
I am little lost at the moment. Can you take a look at the code below. I have tried to incorporate what you have said but I guess I did not structure the the first part as you instructed.
My DB table names are “contact_requests” and “bayi_basvuru”
Ok I did. So I have only used the second portion of your code starting with " function send_mail($table,$id){ " and also wrapped the id in single quotes like this : $sql=“SELECT * FROM $table WHERE id=‘$id’”;
Ok solved. Actually I have realized another issue where I defined the global email, there was an underscore missing.
It seems to be working fine now. Many many thanks…Aha. The first form is working perfectly fine but when I submit the second form it says “Invalid data given” ???
Hard to say. Just go through some trouble shooting to pin down the issue. Double check DB fields for that second table and POST names in processing are as sent by the form. Double check that you are getting results inserted to DB and insert_id() is present.
Funny thing is I haven’t changed a single thing on the script other than what you have recommended. It was submitting the form before and now it doesn’t, all fields and ids match also.
Anyhow, I will keep diggin’ post the answer once I find out the issue here… Thanks…
Well what part is not working? You do understand that the code I posted in post# 11 was just a loose example explaining to define the real DB table names based off of your hidden input, not literal code to use. In any case you were already defining $table as the DB table name.
Looks like in the function we have different database table names or IF condition value check. Compare to what it is supposed to be and correct.
bayi_basvuru
bayi_basvurusu
Note that I got the name bayi_basvurusu from post# 5 that you made.
Fantastic news for me and kudos to you, it is working now I had completely overlooked those two letters at the end. It is all fixed up now. Thanks a lot.