Reply to topic  [ 8 posts ] 
PHP POSTing 
Author Message
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 7:35 pm
Posts: 6580
Location: Getting there
Reply with quote
I've given myself a PHP exercise to create a website based on Facemash (if anyone has seen The Social Network) you will know what it looks like).

I've got 2 submit buttons (one for each side) and I want to post which button was pressed into the next page so it can process the info and update the Mysql db I've attached it to.

I know how to update the db and all that stuff I just can't work out how to post the info.

All I need to post is two numbers. First is the winner, second is the loser. The winner is the db number of the person whose button was pressed. I have these stored in variables but not sure how to put them into the post info.

Any help is much appreciated.

TVM!

_________________
Oliver Foggin - iPhone Dev

JJW009 wrote:
The count will go up until they stop counting. That's the way counting works.


Doodle Sub!
Game Of Life

Image Image


Sat Feb 19, 2011 4:48 pm
Profile WWW
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 7:35 pm
Posts: 6580
Location: Getting there
Reply with quote
OK, done it!

<input type='hidden' name='winner' value='" . $winner . "' />

_________________
Oliver Foggin - iPhone Dev

JJW009 wrote:
The count will go up until they stop counting. That's the way counting works.


Doodle Sub!
Game Of Life

Image Image


Sat Feb 19, 2011 5:09 pm
Profile WWW
Spends far too much time on here
User avatar

Joined: Thu Apr 23, 2009 11:36 pm
Posts: 3527
Location: Portsmouth
Reply with quote
That's not the way that I would do it. In fact, from the fact that you are using a variable named $variable I'm guessing this is a two part form, so there is a page in the middle to determine which was the winner???

To me it would seem much more straight forward to use isset() to see which button was pressed??

That way there would be no need for a hidden field or a third page???

_________________
Image


Sat Feb 19, 2011 8:26 pm
Profile
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 7:35 pm
Posts: 6580
Location: Getting there
Reply with quote
Nick wrote:
That's not the way that I would do it. In fact, from the fact that you are using a variable named $variable I'm guessing this is a two part form, so there is a page in the middle to determine which was the winner???

To me it would seem much more straight forward to use isset() to see which button was pressed??

That way there would be no need for a hidden field or a third page???

Well there is actually only one page.

I haven't ever used javascript before (or PHP or mysql for that matter) so I wanted to try keep the learning down to a sensible level.

To begin with the PHP goes and gets two random records from the DB. Then the display is built from these two records and put in to forms and setting up the values for the posting of the forms.

I also used a table for a slight bit of layout stuff which I know is a big NO but I couldn't get it to work the way I wanted.

When you click the button it links back to the same page which then (if it has POST values) then updates the DB with the new scores and displays 2 new random pictures to choose from.

The site is http://oliverfoggin.dyndns.org/teaparty if you want to take a looky?

_________________
Oliver Foggin - iPhone Dev

JJW009 wrote:
The count will go up until they stop counting. That's the way counting works.


Doodle Sub!
Game Of Life

Image Image


Sun Feb 20, 2011 4:35 pm
Profile WWW
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 7:35 pm
Posts: 6580
Location: Getting there
Reply with quote
Oh and BTW there are only 5 entries in the DB so you might get quite a few repeating pages.

_________________
Oliver Foggin - iPhone Dev

JJW009 wrote:
The count will go up until they stop counting. That's the way counting works.


Doodle Sub!
Game Of Life

Image Image


Sun Feb 20, 2011 4:45 pm
Profile WWW
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 7:35 pm
Posts: 6580
Location: Getting there
Reply with quote
You won't get onto it now.

My fricking internet keeps going down and so I've moved the router to the test socket as the final part of testing for Virgin Media.

Which means I'm now on wifi and I don't have a wifi card for my linux PC.

_________________
Oliver Foggin - iPhone Dev

JJW009 wrote:
The count will go up until they stop counting. That's the way counting works.


Doodle Sub!
Game Of Life

Image Image


Sun Feb 20, 2011 5:34 pm
Profile WWW
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 7:35 pm
Posts: 6580
Location: Getting there
Reply with quote
OK, it's back online now.

Moved everything over to MAMP following advice from the OS Forum.

Took me about 20 mins to download, install, transfer the site and set my IP of my MBP to the right one.

_________________
Oliver Foggin - iPhone Dev

JJW009 wrote:
The count will go up until they stop counting. That's the way counting works.


Doodle Sub!
Game Of Life

Image Image


Sun Feb 20, 2011 8:51 pm
Profile WWW
Spends far too much time on here
User avatar

Joined: Thu Apr 23, 2009 11:36 pm
Posts: 3527
Location: Portsmouth
Reply with quote
Ah okay, I see what you mean now.

Just ignore me :lol: !

_________________
Image


Mon Feb 21, 2011 12:52 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 8 posts ] 

Who is online

Users browsing this forum: No registered users and 10 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software.