starting variable

C++, C#, Java, PHP, ect...
Post Reply
pretender5552
Posts: 127
Joined: Mon Jan 03, 2011 5:38 am

starting variable

Post by pretender5552 »

In my level up system I am trying to make it so that clicking on the button will add the stat but I am not sure how to do this do you just button the code in the link?
User avatar
PaxBritannia
Posts: 680
Joined: Sun Apr 18, 2010 1:54 pm

Re: starting variable

Post by PaxBritannia »

There are 2 main ways to do this:

1: use a get to pass a variable through a link

Code: Select all

<a href src="levelup.php">Level up!</a>
2: use a form submit button

For both, direct the user to a php page where the operations are processed. Then redirect them back to where you want.

Both ways will work, but make confirm that they are eligible to do the operation. That is, make sure they haven't just used the link several times to cheat.

pax.
pretender5552
Posts: 127
Joined: Mon Jan 03, 2011 5:38 am

Re: starting variable

Post by pretender5552 »

Isn't there a way to do it without sending them to another page?
User avatar
PaxBritannia
Posts: 680
Joined: Sun Apr 18, 2010 1:54 pm

Re: starting variable

Post by PaxBritannia »

Once that page is loaded, there is no other way using only php.

From then on, you must use javascript or another client side script to call another php page.

I found this tutorial extremely helpful when I needed to call another script:
http://net.tutsplus.com/tutorials/javas ... ng-jquery/

Although what you want to do is a little different, you can just ignore some parts of the tutorial and focus on when they call the php script.

Hope it works out!

pax.
Post Reply

Return to “Coding”