rocky48 Posted April 16, 2012 Share Posted April 16, 2012 Firstly I was not sure whether to put this in HTML or PHP forum! I have some code that I wish to input into the PHP script, using $POST. Here is the HTML code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html lang="en"> <head> <title><!-- Insert your title here --></title> </head> <body> <form action="testcolor.php" method="post"> <input type="checkbox" name="textcolor" value="255215000" /> Gold<br /><br /> <input type="submit" value="Submit"/> </form> </body> </html> As you can see the name of the variable is 'textcolor' and its value is '255215000' The PHP code takes this number and using SUBSTR extracts each group of three characters. The purpose of this is to split the string up into 3 variables r, g, b, to input this as a colour in fpdf. Here is the PHP code: <?php echo $POST[textcolor]; $color = $POST[textcolor]; $r = substr($color,0,3); $g = substr($color,3,3); $b = substr($color,6,3); echo $r; echo $g; echo $b; ?> I put the echo in to see if it would output the input from the HTML script, but I just get a blank screen. I know that the SUBSTR part works as I have substituted the intended string and got the $r, $g, $b values output. There is obviously something wrong with the $POST command, but I can not see where I am going wrong> Can anyone help? Quote Link to comment Share on other sites More sharing options...
rocky48 Posted April 16, 2012 Author Share Posted April 16, 2012 I have just found by using >> print_r($_POST); I can see what is in the array. It prints 255215000, so why does $color not pick up this number and use it to extract the characters?? Quote Link to comment Share on other sites More sharing options...
Solution haku Posted April 17, 2012 Solution Share Posted April 17, 2012 $POST[textcolor]; $_POST[textcolor]; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.