Jump to content

Simple questing I think, how to post a form value through a link?


Recommended Posts

Quick and simple, I have this form;

 

      print "Player ID to Attack<br>";

      print "<form action='newatk.php' method='post'>";

      print "<input type='text' name='playerID' size='20'><br>";

      print "<P><input type='submit' name='submit2' value='Attack'></form>";

 

When they put in a value into the 3rd row - it sends it to a php file called newatk.php where I have it call " name='playerID' " which = player 2. Also the player you will fight.

 

Playerone (which would be you), is selected from the session cookie to define the id and that I can handle easily. This code works and all very good, the only problem I have is when I attempt to put in inside a link (under this snippet of code)

 

    $playerID=$_POST['playerID'];

 

    $playerone="SELECT * from km_users where playername='$player'";

    $playerone2=mysql_query($playerone) or die("Blah");

    $playerone3=mysql_fetch_array($playerone2);

 

    $playertwo="SELECT * from km_users where ID='$playerID'";

    $playertwo2=mysql_query($playertwo) or die("Blah");

    $playertwo3=mysql_fetch_array($playertwo2);

    $time=date("M d H:i:s");

 

Alright, what I'm attempting to do is set it up to have an attack linkinstead of a form submit button..

 

(basically think of it as a message link on a forum where you want to message them)

 

..on the user's profile so when clicked it would take their ID and your ID and would go to "newatk.php" and activate the fight/math to determine what happens (which that is all fine) like it does in the form.

 

http://ext.flitched.com/ I honestly don't know how well to explain it without taking too much time of your time reading this, if you go to that site and login with guest - guest, you can easily see how it works and in the "top players" on the left side navigation...look for the link called "hit" and look at where the link is supposed to go. I  have it set to:

 

      "<a href=newatk.php?name=4>$dead</a>"

 

And I know it is supposed to have a $_GET command right there right? I did a lot of tutorials but just can't seem to pinpoint how to set it up. I'm not asking to get spoonfed :) - just a nudge where I can learn how to do it!

 

I'l gladly show any more code that is needed, but I believe that I posted enough to pinpoint it especially after you visit the site, there is like 5 things on there lol..easy to find.

 

Thanks for your time! (If you have a good tutorial for this stuff I'd love to read up, I saw one similar to this earlier on the forum but I just really couldn't find my problem)

set your link like this:

 

<a href="battle.php?playerid=$id" />players id</a>

 

then use GET

 

$playerid = (int)$_GET['playerid'];

 

it will the the number or id after the playerid bit,

 

just make sure $id is changed to how you call the id.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.