Jump to content

POST with image not working


djexploit
 Share

Recommended Posts

Hey there,

 

I'm trying to make a simple point adding system and it works so far, but it works with a submit button and not an image. So if i click the button it will add 20 'points' to the database i provided but this does not seem to work with an image. Can someone help me with this, i'm kinda new to php.

 

Code:

 

<?php

 

//defining username and amount of points to give + the current points

 

$username = 'djexploit';

$seepoints = mysql_query("SELECT points FROM members WHERE username='$username'") or die(mysql_error());

$fetchresults = mysql_fetch_row($seepoints);

$currentpoints = $fetchresults['0'];

 

echo "Current points are: $currentpoints points.";

 

$points = $currentpoints + 20 ;

 

 

if(isset($_POST['submit']))

 

{

 

$newpoints = $points;

//the updating of the points field

mysql_query("UPDATE `members` SET `points` = '$points' WHERE `username`= '$username'") or die(mysql_error());

 

echo "The amount of points has been updated. You now have $newpoints";

 

} else {

 

echo '<br>click the image to add 20 points';

 

}

 

 

?>

 

<html>

<body>

<form id="form" action="give.php" method="post">

<a href="http://www.google.com"><input type="image" src="http://hamovhotov.com/advertisement/wp-content/uploads/2007/03/468x60ad.gif" name="submit" value="submit"></a>

</form>

</body>

</html>

Link to comment
Share on other sites

Ah I see..

I thought that if ($_POST['submit]) meant if it was clicked. I don't know much about javascript although I did hear about OnClick() function. Could that be it? And if so how do i make it so that it posts to php so i can put it in an if statement?

Link to comment
Share on other sites

I agree with previous commenters that it would help to know what your link does when you click on it. PLEASE don't use JavaScript. That is a hack.

 

Try putting the type="submit" attribute on the input. The name attribute gives the element a name, and the value is the actual data you are passing. You should consider reading the API. MDN is better than w3schools.com. They're notoriously wrong.

Here ya go: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input

If this works, please don't forget to mark my answer as the solution. (please)

Edited by nodirtyrockstar
Link to comment
Share on other sites

This thread is more than a year old.

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.

 Share

×
×
  • 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.