473,388 Members | 1,327 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Multi entry form not passing info to mysql database

I am trying create a form for my club which takes info from a database to enable a sub selection of trainees from the database. Then additionally select a from a list of events and INSERT both back into a database. It writes to the database OK and loops through the correct number of times but doesnt pass $trainee value to the database
What is failing is the passing of the info from
print ' <input type="hidden" name="Trainee" value= ' . $trainee . ' />
to the $query in the if(isset($_POST['formSubmit'])) loop.

Anyone tell me where I am going wrong
Attached Files
File Type: txt test_multi_select_form.txt (2.3 KB, 287 views)
Jan 29 '12 #1
3 1618
dlite922
1,584 Expert 1GB
you're using an @ sign in front of your mysql_query() function. You may have a bad query.

do a die(var_dump($query)); before you run the query and manually run that query yourself in the DB to see if there's a problem with it if the issue is not obvious.

Also SANITIZE your variables. Look into a little thing called SQL Injection. If this site is internet facing, I could totally sabotage your inputs by putting in malicious values. Start with mysql_real_escape_string() function. See the manual.


Dan
Jan 30 '12 #2
Thanks for the response. Your comments noted about security, I stripped all extra code for fault finding, but will investigate your suggestions. FYI, the form is accessed by a restricted encrypted login to the website.
Removed the @ didnt make any difference. The query does work and posts all the info except the $trainee value which currently appears as / in the database field, which I believe to be the closing / of the /> in the <input type "hidden" name="Trainee" value= ' . $trainee . ' /> line.
Any other thoughts or observations
Jan 30 '12 #3
dlite922
1,584 Expert 1GB
You just need to trace your code. Put in die(var_dump($variable_name_you_want)) at every step and you can see where it's failing or where there should be data in the variable but isn't.

Do this for $_POST variable, $aTrainee, and $query. You don't have an else in the if(mysql_query()) so you wouldn't know if the query failed at all and why. add an else and mysql_error().

Dan
Jan 31 '12 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Mark | last post by:
I have found many examples of how to access an HTML text field from PHP, but cannot find the reverse - how to load an HTML form from a MySQL database. Specifically, I have an HTML form which...
3
by: sammmista | last post by:
hello experts, Plz dont treat this as another newbie query , i did my homework but still getting nowhere :( :( :( Trying to learn PHP on Fedora core 1 (PHP 4.3,MySQL,HTTPD).Unable to post data...
1
by: skeeterbug | last post by:
hi all, i'm new to using php, adodb and pgsql. i have a need to enter data into a database. however, i can't find a web example or tutorial that explains the nuts and bolts of how this is...
2
by: aseaman | last post by:
I am a big novice with MySQL and PHP. I need a script that enters information from a html form into a MySQL database. Can anyone tell me where I can find one that I can just replace the table and...
4
by: Mmm_moo_cows | last post by:
Hi, I'm new to the world of mysql and i'm having alot of trouble with it. All i want to do is create a page with a response form, e.g. name etc and some radio buttons (part of a uni project,...
2
by: Rajesh | last post by:
dear all, as of now, am working on a simple access database with a normal data entry form Can I design a form in HTML for data entry, and the same be linked to an access database where the...
4
by: Ewok | last post by:
let me just say. it's not by choice but im dealing with a .net web app (top down approach with VB and a MySQL database) sigh..... Anyhow, I've just about got all the kinks worked out but I am...
3
by: intl04 | last post by:
Is it possible to create a Word form as the data entry form for an Access database? I didn't see any reference to this possibility in my Access books, so I'm sorry if this is a question that is...
3
by: kd8con | last post by:
Ok, I am writing an application in which - a user enters data into a field, then when leaving this field and going to the next field, I need to do a search on the access database for that data and...
8
by: nick02895 | last post by:
I am not a programmer, just putting bits and pieces I've found on the net. I am missing something here, can you help? The "publishcityonline" checkbox is not sending the required 0 or 1 to mysql...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.