Author |
Topic |
|
Webbo
Average Member
United Kingdom
982 Posts |
Posted - 06 August 2014 : 17:41:38
|
I'm trying to add some form data into a MySql database and failing miserably partially due to long work hours, tiredness and little spare time to spend on it
Basically I have a form page where info can be submitted. It then goes to a confirmation page which opens in the users browser displaying the info that has been submitted. (this bit works fine) It is this info from the confirmation page that I need to be added to the database
Below is a copy of the confirmation page:
Could someone please advise how I can send the form data into a table in the database
The table is called: postcodes The columns in the table are named: fishery, street_address, town_city, county, postcode
Many thanks in anticipation |
|
Carefree
Advanced Member
Philippines
4207 Posts |
Posted - 06 August 2014 : 20:28:19
|
This is basically all you need. Change the bit in red to match your database connectivity string.
|
Edited by - Carefree on 06 August 2014 20:29:28 |
|
|
Webbo
Average Member
United Kingdom
982 Posts |
Posted - 07 August 2014 : 16:55:51
|
Hi Carefree, can you just check my code below as when I add my connection string I get an error 500 message:
|
|
|
Carefree
Advanced Member
Philippines
4207 Posts |
Posted - 07 August 2014 : 20:06:17
|
Well, the obvious problem is that you don't specify "user". You don't use "UID" as the variable. Beyond that, though, your "option=3" limits what you can do while connected to a MySQL database. Also, there's no data checking for the content of the form fields. Try this:
|
Edited by - Carefree on 08 August 2014 07:17:20 |
|
|
Webbo
Average Member
United Kingdom
982 Posts |
Posted - 08 August 2014 : 02:20:25
|
Nope, still giving a http500 error
I've check the database details and they're all correct |
|
|
Carefree
Advanced Member
Philippines
4207 Posts |
Posted - 08 August 2014 : 07:46:30
|
I tested this and it works fine. Just change the connection string. I called it "address.asp" (look at the action line in the form). I also corrected two errors in the above, so it may work for you without using this one.
|
Edited by - Carefree on 08 August 2014 07:49:06 |
|
|
Webbo
Average Member
United Kingdom
982 Posts |
Posted - 08 August 2014 : 12:31:38
|
The version above (the last one) works fine Carefree using the MySql connection string - many thanks
I've just got to add a check to ensure that the fishery does not already exist in the database which would require two checks: fishery name and postcode as some fisheries do have the same names, Also, a password protection to stop others from using it peferably with a session cookie so that the password is not required every time the page is viewed
If you get the time to do the above it would be muchly appreciated |
Edited by - Webbo on 08 August 2014 12:40:18 |
|
|
Carefree
Advanced Member
Philippines
4207 Posts |
Posted - 08 August 2014 : 18:25:59
|
This is untested. Don't forget to change your connection string.
|
Edited by - Carefree on 08 August 2014 18:30:11 |
|
|
Webbo
Average Member
United Kingdom
982 Posts |
Posted - 10 August 2014 : 15:50:22
|
Hi Carefree, the above accepts any username and password combination and takes the user to the form. However the form does not send the information to the database regardless if the user and pass values are correct or not
If you would like I can email you a link to the page and a user and password, let me know. |
Edited by - Webbo on 10 August 2014 15:50:58 |
|
|
Carefree
Advanced Member
Philippines
4207 Posts |
Posted - 10 August 2014 : 20:23:33
|
I just discovered that myself and rewrote the whole thing. Make sure you change the connection string (in red). This uses sha256 for encryption of the password. I just appropriated the include file from Snitz.
|
Edited by - Carefree on 11 August 2014 18:46:31 |
|
|
Webbo
Average Member
United Kingdom
982 Posts |
Posted - 11 August 2014 : 16:21:41
|
This one doesn't accept the user name or password, displaying the message: No record found. Go back to try again
In the database I have a table named: users and columns in the table: User_ID , User_name , User_pass |
|
|
Carefree
Advanced Member
Philippines
4207 Posts |
Posted - 11 August 2014 : 18:01:41
|
It works here, does exactly what you asked, cookies and all. Was your password encrypted with sha256? That's what I wrote it to check. If the password is plain text or uses some other form of encryption, line 18 (below) will have to be changed accordingly.
For sha256 (currently used):
strPass = sha256(Request.Form("Pass"))
For plain text passwords:
strPass = Request.Form("Pass")
Any other encryption should follow the sha256 scheme, but you'll have to provide your own "include" file and function to call it. |
Edited by - Carefree on 11 August 2014 18:03:40 |
|
|
Webbo
Average Member
United Kingdom
982 Posts |
Posted - 11 August 2014 : 21:30:51
|
^^ That was it Carefree, I changed line 18 and it works fine
Many thanks |
|
|
Carefree
Advanced Member
Philippines
4207 Posts |
Posted - 11 August 2014 : 23:56:00
|
You're welcome. |
|
|
|
Topic |
|
|
|