Jump to content

$_GET and $_POST


Dusaro

Recommended Posts

Well, i have got this code:

 

<?php
header("Cache-Control: no-store, no-cache, must-revalidate"); 
header("Cache-Control: post-check=0, pre-check=0", false); 
header("Pragma: no-cache"); 
?>
<form action="signature.php?user=" .$user. "&img=". $img" method="post">
<input name="user" type="text" />
<select name="img">
<option value="blue">Blue</option>
<option value="red">Red</option>
<option value="purple">Purple</option>
<option value="pink">Pink</option>
</select>

<?php
$user = $_POST['user'];
$img = $_POST['img'];
?>
<input type="submit" value="Submit" />

<?php
//Skill Grabs
$order = array("Overall", 
                        "Attack", 
                        "Defence", 
                        "Strength", 
                        "Hitpoints", 
                        "Ranged", 
                        "Prayer", 
                        "Magic", 
                        "Cooking", 
                        "Woodcutting", 
                        "Fletching", 
                        "Fishing", 
                        "Firemaking", 
                        "Crafting", 
                        "Smithing", 
                        "Mining", 
                        "Herblore", 
                        "Agility", 
                        "Thieving", 
                        "Slayer", 
                        "Farming", 
                        "Runecraft", 
                        "Hunter", 
                        "Construction", 
                        "Summoning",
                        "Dungeoneering"); 

$user = $_GET['user']; //Change this to the variable (Or a string literal) that contains the username
$get = file_get_contents("http://hiscore.runescape.com/index_lite.ws?player=$user");
$get = explode("\n", $get);
$i = 0;

foreach ($order as $key => $value)
{
        $value = strtolower($value);
        $temp = explode(",", $get[$i]);
        $temp = array("rank" => $temp[0], "level" => $temp[1], "exp" => $temp[2]);
        $stats[$value] = $temp;
        $eval = "\$$value = array(\$temp[\"rank\"], \$temp[\"level\"], \$temp[\"exp\"]);";
        eval($eval);
        $i++;
}

//End Skill Grabs


// specify the file name - you can use a full path, or "../../" type stuff here
// if the image is not in the same directory as this code file
$image = imagecreatefrompng("http://slay2day.x10.mx/highscores/signatures/".$_GET['img'].".png");

// specify the font size


// in this case, the color is white, but you can replace the numbers with the RGB values
// of any color you want
$color = imagecolorallocate($image, 255,255,255);


// and now we do the overlay - the layers of text start top to bottom, so
// the drop shadow comes first

// $image - the base image file we specified above
// $font_size - Well duh. Its the size of the font
// 0 - the angle of the text - we don't want an angle, so we leave it at 0
// 55 - pixels to the right from the leftmost part of the image
// 35 - pixels down from the top of the image
// $black - the color we defined above
// "../fonts/ARIALBD.TTF" - the location on the server that the font can be found
// "Test Text" - the text we're overlaying - you can also use a variable here

ImageTTFText ($image, "7", 0, 280, 10, $color, "arial.ttf","Slay2day");

ImageTTFText ($image, "12", 0, 240, 55, $color, "biblio.ttf",$user);

if($overall[0]==-1){ImageTTFText($image, "11", 0, 230, 105, $color, "biblio.ttf","NOT RANKED");}else{ImageTTFText($image, "11", 0, 240, 105, $color, "biblio.ttf",$overall[0]);}

ImageTTFText ($image, "10", 0, 27, 20, $color, "arial.ttf",$attack[1]);
ImageTTFText ($image, "10", 0, 27, 42, $color, "arial.ttf",$strength[1]);
ImageTTFText ($image, "10", 0, 27, 64, $color, "arial.ttf",$defence[1]);
ImageTTFText ($image, "10", 0, 27, 88, $color, "arial.ttf",$hitpoints[1]);
ImageTTFText ($image, "10", 0, 27, 114, $color, "arial.ttf",$ranged[1]);

ImageTTFText ($image, "10", 0, 70, 20, $color, "arial.ttf",$prayer[1]);
ImageTTFText ($image, "10", 0, 70, 42, $color, "arial.ttf",$magic[1]);
ImageTTFText ($image, "10", 0, 70, 64, $color, "arial.ttf",$cooking[1]);
ImageTTFText ($image, "10", 0, 70, 88, $color, "arial.ttf",$woodcutting[1]);
ImageTTFText ($image, "10", 0, 70, 114, $color, "arial.ttf",$fletching[1]);

ImageTTFText ($image, "10", 0, 117, 20, $color, "arial.ttf",$fishing[1]);
ImageTTFText ($image, "10", 0, 117, 42, $color, "arial.ttf",$firemaking[1]);
ImageTTFText ($image, "10", 0, 117, 64, $color, "arial.ttf",$crafting[1]);
ImageTTFText ($image, "10", 0, 117, 88, $color, "arial.ttf",$smithing[1]);
ImageTTFText ($image, "10", 0, 117, 114, $color, "arial.ttf",$mining[1]);

ImageTTFText ($image, "10", 0, 162, 20, $color, "arial.ttf",$herblore[1]);
ImageTTFText ($image, "10", 0, 162, 42, $color, "arial.ttf",$agility[1]);
ImageTTFText ($image, "10", 0, 162, 64, $color, "arial.ttf",$thieving[1]);
ImageTTFText ($image, "10", 0, 162, 88, $color, "arial.ttf",$slayer[1]);
ImageTTFText ($image, "10", 0, 162, 114, $color, "arial.ttf",$farming[1]);

ImageTTFText ($image, "10", 0, 212, 20, $color, "arial.ttf",$runecraft[1]);
ImageTTFText ($image, "10", 0, 212, 42, $color, "arial.ttf",$construction[1]);
ImageTTFText ($image, "10", 0, 212, 64, $color, "arial.ttf",$hunter[1]);
ImageTTFText ($image, "10", 0, 212, 88, $color, "arial.ttf",$summoning[1]);
ImageTTFText ($image, "10", 0, 212, 114, $color, "arial.ttf",$dungeoneering[1]);

// Now add the actual white text "on top"

header("Content-type: image/png");
imagepng($image);
imagedestroy($image);
?>

 

It generates a image and gets data from the name thats in the url. I am wanting to make a form where they fill out their name and what color they use.

 

What is wrong?

Link to comment
https://forums.phpfreaks.com/topic/248377-_get-and-_post/
Share on other sites

my probably guess is that you didnt close the <form> tag

i didnt tested the code but probably this could be the answer.

<?php
header("Cache-Control: no-store, no-cache, must-revalidate"); 
header("Cache-Control: post-check=0, pre-check=0", false); 
header("Pragma: no-cache"); 
?>
<form action="img.php?user=" .$user. "&img=". $img" method="post">
<input name="user" type="text" />
<select name="img">
<option value="blue">Blue</option>
<option value="red">Red</option>
<option value="purple">Purple</option>
<option value="pink">Pink</option>
</select>
<input type="submit" value="Submit" />
</form>


<?php
if(isset($_POST['submit']))
$user = $_POST['user'];
$img = $_POST['img'];


//Skill Grabs
$order = array("Overall", 
                        "Attack", 
                        "Defence", 
                        "Strength", 
                        "Hitpoints", 
                        "Ranged", 
                        "Prayer", 
                        "Magic", 
                        "Cooking", 
                        "Woodcutting", 
                        "Fletching", 
                        "Fishing", 
                        "Firemaking", 
                        "Crafting", 
                        "Smithing", 
                        "Mining", 
                        "Herblore", 
                        "Agility", 
                        "Thieving", 
                        "Slayer", 
                        "Farming", 
                        "Runecraft", 
                        "Hunter", 
                        "Construction", 
                        "Summoning",
                        "Dungeoneering"); 


$user = $_GET['user']; //Change this to the variable (Or a string literal) that contains the username
$get = file_get_contents("http://hiscore.runescape.com/index_lite.ws?player=$user");
$get = explode("\n", $get);
$i = 0;


foreach ($order as $key => $value)
{
        $value = strtolower($value);
        $temp = explode(",", $get[$i]);
        $temp = array("rank" => $temp[0], "level" => $temp[1], "exp" => $temp[2]);
        $stats[$value] = $temp;
        $eval = "\$$value = array(\$temp[\"rank\"], \$temp[\"level\"], \$temp[\"exp\"]);";
        eval($eval);
        $i++;
}


//End Skill Grabs




// specify the file name - you can use a full path, or "../../" type stuff here
// if the image is not in the same directory as this code file
$image = imagecreatefrompng("http://slay2day.x10.mx/highscores/signatures/".$_GET['img'].".png");


// specify the font size




// in this case, the color is white, but you can replace the numbers with the RGB values
// of any color you want
$color = imagecolorallocate($image, 255,255,255);




// and now we do the overlay - the layers of text start top to bottom, so
// the drop shadow comes first


// $image - the base image file we specified above
// $font_size - Well duh. Its the size of the font
// 0 - the angle of the text - we don't want an angle, so we leave it at 0
// 55 - pixels to the right from the leftmost part of the image
// 35 - pixels down from the top of the image
// $black - the color we defined above
// "../fonts/ARIALBD.TTF" - the location on the server that the font can be found
// "Test Text" - the text we're overlaying - you can also use a variable here


ImageTTFText ($image, "7", 0, 280, 10, $color, "arial.ttf","Slay2day");


ImageTTFText ($image, "12", 0, 240, 55, $color, "biblio.ttf",$user);


if($overall[0]==-1){ImageTTFText($image, "11", 0, 230, 105, $color, "biblio.ttf","NOT RANKED");}else{ImageTTFText($image, "11", 0, 240, 105, $color, "biblio.ttf",$overall[0]);}


ImageTTFText ($image, "10", 0, 27, 20, $color, "arial.ttf",$attack[1]);
ImageTTFText ($image, "10", 0, 27, 42, $color, "arial.ttf",$strength[1]);
ImageTTFText ($image, "10", 0, 27, 64, $color, "arial.ttf",$defence[1]);
ImageTTFText ($image, "10", 0, 27, 88, $color, "arial.ttf",$hitpoints[1]);
ImageTTFText ($image, "10", 0, 27, 114, $color, "arial.ttf",$ranged[1]);


ImageTTFText ($image, "10", 0, 70, 20, $color, "arial.ttf",$prayer[1]);
ImageTTFText ($image, "10", 0, 70, 42, $color, "arial.ttf",$magic[1]);
ImageTTFText ($image, "10", 0, 70, 64, $color, "arial.ttf",$cooking[1]);
ImageTTFText ($image, "10", 0, 70, 88, $color, "arial.ttf",$woodcutting[1]);
ImageTTFText ($image, "10", 0, 70, 114, $color, "arial.ttf",$fletching[1]);


ImageTTFText ($image, "10", 0, 117, 20, $color, "arial.ttf",$fishing[1]);
ImageTTFText ($image, "10", 0, 117, 42, $color, "arial.ttf",$firemaking[1]);
ImageTTFText ($image, "10", 0, 117, 64, $color, "arial.ttf",$crafting[1]);
ImageTTFText ($image, "10", 0, 117, 88, $color, "arial.ttf",$smithing[1]);
ImageTTFText ($image, "10", 0, 117, 114, $color, "arial.ttf",$mining[1]);


ImageTTFText ($image, "10", 0, 162, 20, $color, "arial.ttf",$herblore[1]);
ImageTTFText ($image, "10", 0, 162, 42, $color, "arial.ttf",$agility[1]);
ImageTTFText ($image, "10", 0, 162, 64, $color, "arial.ttf",$thieving[1]);
ImageTTFText ($image, "10", 0, 162, 88, $color, "arial.ttf",$slayer[1]);
ImageTTFText ($image, "10", 0, 162, 114, $color, "arial.ttf",$farming[1]);


ImageTTFText ($image, "10", 0, 212, 20, $color, "arial.ttf",$runecraft[1]);
ImageTTFText ($image, "10", 0, 212, 42, $color, "arial.ttf",$construction[1]);
ImageTTFText ($image, "10", 0, 212, 64, $color, "arial.ttf",$hunter[1]);
ImageTTFText ($image, "10", 0, 212, 88, $color, "arial.ttf",$summoning[1]);
ImageTTFText ($image, "10", 0, 212, 114, $color, "arial.ttf",$dungeoneering[1]);


// Now add the actual white text "on top"


header("Content-type: image/png");
imagepng($image);
imagedestroy($image);
}
?>

Link to comment
https://forums.phpfreaks.com/topic/248377-_get-and-_post/#findComment-1275487
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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