Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-26-2013, 05:56 PM   PM User | #1
countrydj
Regular Coder

 
Join Date: Nov 2011
Location: Preston, UK
Posts: 130
Thanks: 36
Thanked 0 Times in 0 Posts
countrydj is an unknown quantity at this point
Cannot get data into database

I hope I have put this post in the right section.
I cannot get data into my database
This is the script that should update the database:
PHP Code:
$qry "UPDATE " $vars["fr table directory"] . " SET club_title='$club_title',club_name='$club_name',club_type='$club_type',club_address='$club_address',club_contact='$club_contact',club_details='$club_details',club_details2='$club_details2',club_dance_floor='$club_dance_floor',club_open='$club_open',club_admission='$club_admission',background_colour='$background_colour',background_image='$background_image',text_colour='$text_colour',header_colour='$header_colour' WHERE club_code='$club_code'";

    if(!(
$results mysqli_query($link$qry ))){
        
displayErrMsg(sprintf("Error in executing %s query"$qry));
        
displayErrMsg(sprintf("error:%d %s"mysqli_errno($link), mysqli_error($link)));
        exit();
    }
        
header ('Location:' .$input_page);
    } 
I have put a trap in the script:
PHP Code:
var_dump($_GET); exit; 
and this is the result:
Code:
array(15) { ["club_title"]=> string(38) "The Ranch House Country & Western club" ["club_name"]=> string(16) "The John Doe CWC" ["club_type"]=> string(24) "Country and Western Club" ["club_address"]=> string(0) "" ["club_details2"]=> string(0) "" ["club_dance_floor"]=> string(3) "yes" ["club_contact"]=> string(0) "" ["club_open"]=> string(0) "" ["club_admission"]=> string(0) "" ["club_details"]=> string(0) "" ["background_colour"]=> string(7) "#ffffff" ["background_image"]=> string(16) "multi_colour.jpg" ["text_colour"]=> string(7) "#990000" ["header_colour"]=> string(7) "#6633cc" ["action"]=> string(3) "add" }
Can anybody see the problem? I have been working on this practically all day.

Thanks,
__________________
The MAN, The MYTH, The LEGEND:
John C
________________________________
Support your local Country Music Club
countrydj is offline   Reply With Quote
Old 02-26-2013, 08:28 PM   PM User | #2
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,046
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
Let's just look at one part ...

club_title='$club_title'

How does $_GET['club_title'] become $club_title ?

Can you show us the entire script? Because we must not be seeing it all.
mlseim is offline   Reply With Quote
Users who have thanked mlseim for this post:
countrydj (02-27-2013)
Old 02-26-2013, 11:11 PM   PM User | #3
Arcticwarrio
Regular Coder

 
Arcticwarrio's Avatar
 
Join Date: May 2012
Location: UK
Posts: 597
Thanks: 15
Thanked 67 Times in 67 Posts
Arcticwarrio is on a distinguished road
in your output you have no club code so it doesn't know what to update
__________________
There are 10 types of people on CodingForums,
Those who understand Binary and those who dont.
Arcticwarrio is offline   Reply With Quote
Users who have thanked Arcticwarrio for this post:
countrydj (02-27-2013)
Old 02-27-2013, 12:31 AM   PM User | #4
countrydj
Regular Coder

 
Join Date: Nov 2011
Location: Preston, UK
Posts: 130
Thanks: 36
Thanked 0 Times in 0 Posts
countrydj is an unknown quantity at this point
Quote:
Originally Posted by Arcticwarrio View Post
in your output you have no club code so it doesn't know what to update
Hi Guys...
Thank you very much for being so helpful.

I can't believe that I've been such a 'dick head' !!!!
I couldn't see the wood for the trees.
I completely missed:
PHP Code:
WHERE club_code='$club_code'"; 
I have no excuse. I wish I had.

$club_code is defined at the top of the script: $club_code = "fr1195"; which is generated from: $club_code = "##[club_code]##";
from:
PHP Code:
    //ADD CLUB CODE TO NEW CLUB INPUT FILE
        
$file_contents file_get_contents($new_addclub);
        
$file_contents str_replace("##[new_addclub]##","$new_addclub",$file_contents);
        
$file_contents str_replace("##[club_code]##","$club_code",$file_contents);
        
file_put_contents($new_addclub,$file_contents); 
Thank you for again for being so helpful. You prompted me towards the right direction.
__________________
The MAN, The MYTH, The LEGEND:
John C
________________________________
Support your local Country Music Club
countrydj is offline   Reply With Quote
Old 02-27-2013, 12:41 AM   PM User | #5
countrydj
Regular Coder

 
Join Date: Nov 2011
Location: Preston, UK
Posts: 130
Thanks: 36
Thanked 0 Times in 0 Posts
countrydj is an unknown quantity at this point
Quote:
Originally Posted by mlseim View Post
Let's just look at one part ...

club_title='$club_title'

How does $_GET['club_title'] become $club_title ?

Can you show us the entire script? Because we must not be seeing it all.
I have a very simple form, which is a double opt-in system for verification, for the user to fill in. When the user clicks on the verification link in their email, they are presented with a Verification Success page which includes a link to their individual input form. This is the basis for creating the first entry in the database.
After the first entry, the user can UPDATE their database entry with their details
This is pulled from the database, along with all the other variables:
$club_title = $_GET['club_title'];

Thank you once again for coming to my rescue.
__________________
The MAN, The MYTH, The LEGEND:
John C
________________________________
Support your local Country Music Club
countrydj is offline   Reply With Quote
Old 02-27-2013, 03:11 AM   PM User | #6
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,046
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
Why are you using $_GET? Can't you use $_POST?
mlseim is offline   Reply With Quote
Old 02-27-2013, 07:32 AM   PM User | #7
Arcticwarrio
Regular Coder

 
Arcticwarrio's Avatar
 
Join Date: May 2012
Location: UK
Posts: 597
Thanks: 15
Thanked 67 Times in 67 Posts
Arcticwarrio is on a distinguished road
its from an email link
__________________
There are 10 types of people on CodingForums,
Those who understand Binary and those who dont.
Arcticwarrio is offline   Reply With Quote
Old 02-27-2013, 10:07 AM   PM User | #8
countrydj
Regular Coder

 
Join Date: Nov 2011
Location: Preston, UK
Posts: 130
Thanks: 36
Thanked 0 Times in 0 Posts
countrydj is an unknown quantity at this point
Quote:
Originally Posted by mlseim View Post
Why are you using $_GET? Can't you use $_POST?
Hi mlseim...

I don't know is the simple answer.
The truth is that I don't know when to use POST or GET.

I would appreciate you advising me.

Thank you,
__________________
The MAN, The MYTH, The LEGEND:
John C
________________________________
Support your local Country Music Club
countrydj is offline   Reply With Quote
Old 02-27-2013, 10:11 AM   PM User | #9
Arcticwarrio
Regular Coder

 
Arcticwarrio's Avatar
 
Join Date: May 2012
Location: UK
Posts: 597
Thanks: 15
Thanked 67 Times in 67 Posts
Arcticwarrio is on a distinguished road
POST hides all the data sent between pages where GET shows it in the address bar
__________________
There are 10 types of people on CodingForums,
Those who understand Binary and those who dont.
Arcticwarrio is offline   Reply With Quote
Old 02-27-2013, 10:17 AM   PM User | #10
countrydj
Regular Coder

 
Join Date: Nov 2011
Location: Preston, UK
Posts: 130
Thanks: 36
Thanked 0 Times in 0 Posts
countrydj is an unknown quantity at this point
Quote:
Originally Posted by Arcticwarrio View Post
POST hides all the data sent between pages where GET shows it in the address bar
Thanks for your very quick reply.
1. Is this the only advantage ???
2. Does it matter ???

Regards,
__________________
The MAN, The MYTH, The LEGEND:
John C
________________________________
Support your local Country Music Club
countrydj is offline   Reply With Quote
Old 02-27-2013, 10:29 AM   PM User | #11
Arcticwarrio
Regular Coder

 
Arcticwarrio's Avatar
 
Join Date: May 2012
Location: UK
Posts: 597
Thanks: 15
Thanked 67 Times in 67 Posts
Arcticwarrio is on a distinguished road
POST is the preferred option,
however you cant use POST for links

POST is more secure, you wouldn't send a password as GET,
also any hidden form fields will be shown in GET too.

GET can be altered by the user too
__________________
There are 10 types of people on CodingForums,
Those who understand Binary and those who dont.
Arcticwarrio is offline   Reply With Quote
Old 02-27-2013, 11:32 AM   PM User | #12
countrydj
Regular Coder

 
Join Date: Nov 2011
Location: Preston, UK
Posts: 130
Thanks: 36
Thanked 0 Times in 0 Posts
countrydj is an unknown quantity at this point
Quote:
Originally Posted by Arcticwarrio View Post
POST is the preferred option,
however you cant use POST for links

POST is more secure, you wouldn't send a password as GET,
also any hidden form fields will be shown in GET too.

GET can be altered by the user too
Thank you Arcticwarrio..
This explains it better for me.

One last point: can you give me an example of what you mean "you cant use POST for links".

I really do wish I understood things better.

Thanks,
__________________
The MAN, The MYTH, The LEGEND:
John C
________________________________
Support your local Country Music Club
countrydj is offline   Reply With Quote
Old 02-27-2013, 12:52 PM   PM User | #13
Arcticwarrio
Regular Coder

 
Arcticwarrio's Avatar
 
Join Date: May 2012
Location: UK
Posts: 597
Thanks: 15
Thanked 67 Times in 67 Posts
Arcticwarrio is on a distinguished road
like the address for this thread

http://www.codingforums.com/showthread.php?t=288340

the php for querying the database would be

PHP Code:
SELECT FROM posts WHERE thread $_GET['t'
?t=288340 where t is the variable and 288340 is the value

when posting a form the variables are all hidden therefor cant be in the address bar

Code:
http://www.codingforums.com/showthread.php?t=288340
__________________
There are 10 types of people on CodingForums,
Those who understand Binary and those who dont.
Arcticwarrio is offline   Reply With Quote
Old 02-27-2013, 07:29 PM   PM User | #14
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,046
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
Can you show us an example of what one of the links looks like when a person gets an email?

Maybe that will shed some light on this.

I missed the part about a confirmation link from an email. But I want to see what that confirmation link looks like.
mlseim is offline   Reply With Quote
Old 02-27-2013, 10:03 PM   PM User | #15
countrydj
Regular Coder

 
Join Date: Nov 2011
Location: Preston, UK
Posts: 130
Thanks: 36
Thanked 0 Times in 0 Posts
countrydj is an unknown quantity at this point
Hi Guys...
Thank you very much for helping me.
In order to let you know what is happening, here is a link to the index page:

http://www.countrymusic.org.uk/clubs...dmin/index.php

Here is the resulting email:
Code:
Please DO NOT reply to this email. It is an unattended mailbox.

To validate your email address, please click the following link:

http://countrymusic.org.uk/clubs/fr_clubs/fr_admin/register-exec.php?your_phone=07989115251&your_email=j@in-uk.co.uk&status=1&club_name=Ranch_House&action=add&your_name=John_Doe&passwd=asda1234&m=3c4d583d63292f70aba39f853fa7a9e8
This link then returns a page with a link to open an input page for the user, and also creates the first entry into the database, using 'club_code' as the reference for all other updates.

This is the page that the above link created:

http://www.countrymusic.org.uk/clubs...add_fr1208.php

If you do take a look at this, you will see that there is very little information.
The user can then fill in the boxes and update the database.
After updating the database, the form is returned with all the information filled in that is contained in the database.
I did it this way because I don't have to create a special update form.

This is as far as I have got.
The Review Web Page and Add Dates buttons don't work properly because I haven't managed to get round to coding them to automatically be created with the correct information to display the web page properly.

If you want to test it for yourselves, please go ahead. It is still in production so you can't do any harm.
Also, this type of project is a first for me, so any advise will be welcome.

BTW, I am doing this out of interest, and because I enjoy getting absolutely frustrated doing it. Although I hope the script will be used, I won't receive any reward at all for doing it. Most of the things on my web site are FREE.

Thanks.
__________________
The MAN, The MYTH, The LEGEND:
John C
________________________________
Support your local Country Music Club
countrydj is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:10 PM.


Advertisement
Log in to turn off these ads.