Quantcast
Viewing latest article 6
Browse Latest Browse All 16

post form values to a phpgd script without refreshing the pa

I am NOT good with server-side technologies (have a hard time wrapping my mind around them at points). I am pretty decent with PHP. I have a form that offers color options (now in drop-down format, but in future will be an image click). There are multiple choices in the form, for instance you can choose a frame …

via PHP Website Development » Search Results » ajax:

post form values to a phpgd script without refreshing the pa

I am NOT good with server-side technologies (have a hard time wrapping my mind around them at points). I am pretty decent with PHP.
I have a form that offers color options (now in drop-down format, but in future will be an image click). There are multiple choices in the form, for instance you can choose a frame color in one select menu, then choose a top color in another select menu in this illustration. Depending on which page you are on, there can be up to 12 of these choices, all named a,b,c,d…through l.
I have an image that is being created by phpgd library. Here is the current setup for the php gd:
$a = $_POST[‘a’];//1
$b = $_POST[‘b’];//2
$c = $_POST[‘c’];//3
$d = $_POST[‘d’];//4
$e = $_POST[‘e’];//5
$f = $_POST[‘f’];//6
$g = $_POST[‘g’];//7
$h = $_POST[‘h’];//8
$i = $_POST[‘i’];//9
$j = $_POST[‘j’];//10
$k = $_POST[‘k’];//1
$l = $_POST[‘l’];//12

$default = imagecreatefrompng(‘../configurator-testing/11ta-503/default.png’);
$defaulta = imagecreatefrompng(‘../configurator-testing/11ta-503/black_a.png’);
$defaultb = imagecreatefrompng(‘../configurator-testing/11ta-503/black_b.png’);

header(‘Content-Type: image/png’);

$x = imagesx($default);
$y = imagesy($default);

imagecopy($default, $defaulta,0, 0, 0, 0, $x, $y);
imagecopy($default, $defaultb, 0, 0, 0, 0, $x, $y);

imagepng($default);

imagedestroy($default);
imagedestroy($defaulta);
imagedestroy($defaultb);Right now, it only posts a “default” image, which has a black frame, black top. What I want it to do is take the form input, and without refreshing the page or using a submit button, use the submitted values to change what image is created. File names are formatted according to the submitted value (ex. submitted black will correlate to files black_a.php and black_b.php, etc). Here is the form I am testing with:
Image may be NSFW.
Clik here to view.

Notice that it is pulling my image (phpgd) file in the first line above the form, so I want the choices to be processed through my phpgd script, and throw out the new color choices in the image above the form.
I can figure out how to get it to process in the phpgd script, no problem. I am having problems with the posting with no refresh and without a button part. Anyone know some jquery/ajax and willing to help? I’ve been trying to put something together off of tutorials on the web, i’m having an awful time.
I had found some simple functions to model after, and here is what I came up with, but I can’t figure out how best to implement, and so far my efforts have not turned out:
function postImg(layer1, layer2)

$.ajax(
url: “config-gd.php”,
data:
id: layer1,
rate: layer2
,
type: “POST”,
success: function()
alert(‘Done!’);

});

}
………………………………….

If I am right you want an image created by php to load on an event without page reload. I think it is simple.
==================edited part code is replaced==================================
Okay I see you need to send form data to php, it is trivial with Ajax, it’s also easy to create the image too however what seems difficult for me is how to turn the raw data sent by php to a real image using js.
So I don’t include the ajax here, however you can still sent the form data dynamically, without reload of course and get the desired image, using the src attribute of the image, check this code, maybe it can be of some help if customized to your needs.
image.php
if($_GET[‘color’]==’red’)
$red=223; $green=32; $blue=3;
else
$red=0; $green=0; $blue=0;

$im = @imagecreate(110, 20)
or die(“Cannot Initialize new GD image stream”);
$background_color = imagecolorallocate($im, $red, $green, $blue);
$text_color = imagecolorallocate($im, 233, 233, 231);
imagestring($im, 11, 5, 5, $_GET[‘txt’], $text_color);
imagepng($im);
imagedestroy($im);
?>index.htm




Write something here and I will get it back as an image created by php.




Image may be NSFW.
Clik here to view.


For more info: post form values to a phpgd script without refreshing the pa

PHP Website Development » Search Results » ajax

post form values to a phpgd script without refreshing the pa

L'articolo post form values to a phpgd script without refreshing the pa sembra essere il primo su AutoHotKey.


Viewing latest article 6
Browse Latest Browse All 16

Trending Articles