View Full Version : [HELP]RuneScape Signature PHP Script.
ballin
June 17th, 2010, 20:10
Okay, so i have this signature script and everything is working and all, but I need help to make it so the color picker actually works. Like the dropdown on the page actually makes it so when you pick the color, the bg will change to an image i specify.
Link: Only the registered members can see the link.
Anyone know how I can make it work?
Friss
June 17th, 2010, 20:22
Just use another simple GET method to see which background the user wants and have the script use that background image.
ballin
June 17th, 2010, 20:26
So, to load my current image i have this method:
$image = ('img/blackgd.png');
And if i want to use the GET function using the dropdown, would i use it like this?
<select name="sigtype" size="1">
<optgroup label="Gradient">
<option value="Black" name="image" action="/img/blackgd.png">Black</option>
<option value="Blue" name="image" action="/img/bluegd.png">Blue</option>
<option value="Green" name="image" action="/img/greengd.png">Green</option>
<option value="Red" name="image" action="/img/redgd.png" method="get">Red</option>
</optgroup>
<optgroup label="Scenes">
<option value="varrock" name="image" action="#">Varrock</option>
</optgroup>
</select>
Can you further explain to me please?
jamie
June 17th, 2010, 20:40
Wow nice attempt but i would suggest asking Friss or Faab. They are good devolpments ppl
Friss
June 17th, 2010, 21:02
For your image selector use this
$color = $_GET['sigtype'];
$image = ('img/" . $color . "gd.png');
Not sure this will work as I can't remember how to put a variable and a string into another variable.
And for the rest do
<select name="sigtype" size="1">
<optgroup label="Gradient">
<option value="black" name="image" action="/img/blackgd.png">Black</option>
<option value="blue" name="image">Blue</option>
<option value="green" name="image">Green</option>
<option value="red" name="image" >Red</option>
</optgroup>
<optgroup label="Scenes">
<option value="varrock" name="image" action="#">Varrock</option>
</optgroup>
</select>
ballin
June 17th, 2010, 21:09
I got all this...
Only the registered members can see the link.
Friss
June 17th, 2010, 21:14
hmm
You could do a switch statement
Only the registered members can see the link.
ballin
June 17th, 2010, 21:23
Wouldn't it be more complicated to do it with a switch statement though?...
dahunta97
June 18th, 2010, 15:22
I'd help but I can't for most part -- and Friss, you can input a String and a variable into a variable, just concatenate the string/variable with the "." dot operator.
<?php
$text = "text.";
$var1 = "String of " . $text;
?>
Aaron
June 18th, 2010, 15:24
Ask Faab, Former Top Poster, I'm 99% he can do this.
Faab234
June 18th, 2010, 15:46
With this script you can choose your image, so a bit converting.
File that shows the image:
<?php
$color = $_POST["select"];
header("Content-type: image/png");
$im = imagecreatefrompng("$color" . ".png");
imagepng($im);
?>
Form:
<form method="post" action="RSStats.php">
<select name="select">
<option value="Black">Black</option>
<option value="White">White</option>
<option value="Blue">Blue</option></select>
<input type="submit" value="submit" name="submit">
</form>
Errors? Reply.
ballin
June 18th, 2010, 16:00
Well, it doesn't seem to be drawing the background correctly...
Faab234
June 18th, 2010, 16:04
Well, it doesn't seem to be drawing the background correctly...
Printscreen Please.
ballin
June 18th, 2010, 16:04
Ok, so it draws the image correctly now, but there is a problem, it's not printing out the stats since you made the dropdown into a separate form. Is there a way so I can make the submit button submit both the name in the textbox and color chosen?
EDIT: Here's how my page looks like:
Only the registered members can see the link.
It has 2 separate forms; one for the username and now, on for the color that you made.
Friss
June 18th, 2010, 16:15
you can just combine it in 1 form just put in one forum and change post to get in Faab's codes.
Justin H
June 18th, 2010, 16:17
This may be a more messy way of doing it, but I didn't really feel the need to make it all perfect. :p
<?php
$background_color = $_GET['Gradient'];
if($background_color=="Black") { $image = ('img/blackgd.png'); } elseif ($background_color=="Blue") { $image = ('img/bluegd.png'); } elseif($background_color=="Green") { $image = ('img/greengd.png'); }
else { $image = ('img/redgd.png); }
?>
<select name="sigtype" size="1">
<optgroup label="Gradient">
<option value="Black" name="image" action="/img/blackgd.png">Black</option>
<option value="Blue" name="image" action="/img/bluegd.png">Blue</option>
<option value="Green" name="image" action="/img/greengd.png">Green</option>
<option value="Red" name="image" action="/img/redgd.png" method="get">Red</option>
</optgroup>
<optgroup label="Scenes">
<option value="varrock" name="image" action="#">Varrock</option>
</optgroup>
</select>
@ Current Topic - Sorry didn't see it. But why not do what Friss said? You could just put the form on the same page, and check and see if the form has values. *(I changed it to post)* Example:
<?php
$background_color = $_POST['Gradient'];
$username = $_POST['username'];
if(!$username) {
echo '<form action="sigs.php" method="POST">
<select name="sigtype" size="1">
<optgroup label="Gradient">
<option value="Black" name="image" action="/img/blackgd.png">Black</option>
<option value="Blue" name="image" action="/img/bluegd.png">Blue</option>
<option value="Green" name="image" action="/img/greengd.png">Green</option>
<option value="Red" name="image" action="/img/redgd.png" method="get">Red</option>
</optgroup>
<optgroup label="Scenes">
<option value="varrock" name="image" action="#">Varrock</option>
</optgroup>
</select>
</form>'; } else {
//any other PHP code you have goes here
if($background_color=="Black") { $image = ('img/blackgd.png'); } elseif ($background_color=="Blue") { $image = ('img/bluegd.png'); } elseif($background_color=="Green") { $image = ('img/greengd.png'); }
else { $image = ('img/redgd.png); }
} ?>
Faab234
June 18th, 2010, 16:27
Ok, so it draws the image correctly now, but there is a problem, it's not printing out the stats since you made the dropdown into a separate form. Is there a way so I can make the submit button submit both the name in the textbox and color chosen?
EDIT: Here's how my page looks like:
Only the registered members can see the link.
It has 2 separate forms; one for the username and now, on for the color that you made.
Read the post of friss.
Friss
June 18th, 2010, 16:30
Read the post of friss.
It has to places that you would have to submit but you can only submit one at a time?
So he would have to combine the forms to have it all at one time?
Justin H
June 18th, 2010, 16:35
I gave him an to put the form on the same page, but I just need his other form too. And I noticed that also. I when to go click submit, but I noticed their were two separate forms. I needs to be one form, on the same page as the actual PHP.
ballin
June 18th, 2010, 16:47
Here's my form page:
<html>
<head>
<title>RuneScape Stat Signatures</title>
</head>
<form name="input" action="sigs.php" method="get">
RuneScape Username:
<p><input type="text" name="user" />
<input type="submit" value="Submit" /></p>
</form>
<br>Signature Type(Not Yet Working):<br />
<form method="post" action="sigs.php">
<select name="select">
<option value="black">black</option>
<option value="White">white</option>
<option value="blue">blue</option></select>
<input type="submit" value="Submit">
</form>
</html>
Justin H
June 18th, 2010, 17:04
Try this
<?php
$background_color = $_POST['sigtype'];
$username = $_POST['user'];
$scene = $_POST['scenes'];
if(!$username) {
echo '<form action="sigs.php" method="POST">
RuneScape Username:
<p><input type="text" name="user" />
<input type="submit" value="Submit" /></p>
<br/><br/>
<select name="sigtype" size="1">
<optgroup label="Gradient">
<option value="Black" name="image">Black</option>
<option value="Blue" name="image">Blue</option>
<option value="Green" name="image">Green</option>
<option value="Red" name="image">Red</option>
</optgroup>
</select>
<br/><br/>
<optgroup label="Scenes">
<option value="varrock" name="image" action="#">Varrock</option>
</optgroup>
</select>
</form>'; } else {
if($background_color=="Black") { $image = ('img/blackgd.png'); } elseif ($background_color=="Blue") { $image = ('img/bluegd.png'); } elseif($background_color=="Green") { $image = ('img/greengd.png'); } else { $image = ('img/redgd.png); }
//any other php code goes here
//any other PHP code you have goes here
//any other PHP code you have goes here
//any other PHP code you have goes here
//any other PHP code you have goes here
} ?>
ballin
June 18th, 2010, 17:08
W00T, it worked! Thanks everyone!
Powered by vBulletin® Version 4.1.9 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.