Jump to content

$POST in HTML form


Go to solution Solved by haku,

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/261064-post-in-html-form/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.

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