Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6567545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:21:00+00:00 2026-05-25T14:21:00+00:00

I recently just started playing around in PHP and got myself a small project/homework.

  • 0

I recently just started playing around in PHP and got myself a small project/homework.
The idea is very simple – by getting a number by user input, draw a circle.

I got the circle working with imagearc, everything scales beautiful by the number the user type in.
However, there seems to be a color problem. On my main page, I created four radio buttons with 4 different colors. The radio button choose what color the circle has.
I can’t get it work though. The circle is not displaying anymore, even though I checked everything. Here’s the code I try to use:

<form method="post" action="circle.php">
<input type="radio" name="color" value="blue" class="color">Blue<br />
<input type="radio" name="color" value="red" class="color">Red<br />
<input type="radio" name="color" value="green" class="color">Green<br />
<input type="radio" name="color" value="yellow" class="color">Yellow<br />
<input type="submit" value="Send" name="submit" />
</form>

That’s from index.php, here’s what I try to do

$color = $_POST['color'];

if ($color == 'red') {
    $superColor = $red;
    }

// make some color
$white  = imagecolorallocate($img, 255, 255, 255);
$red    = imagecolorallocate($img, 255, 0, 0);

// draw the circle
imagearc($img, ($height + 10) / 2, ($width + 10) / 2, $circumference, $circumference, 0, 360, $superColor);

I’m still new, and still learning, so I guess there’s an easier and prettier way of doing it. This is just my try. What am I doing wrong here?

Thanks in advance

EDIT: Thanks for the quick answers! I have tried what you guys (or girls) told me to do, change from ID to name and put the == ‘red’ in quotes – it doesn’t work though.
I think it has something to do with my if statement. Shouldn’t it be possible to give the information stored in $red to $superColor by doing a simple $superColor = $red?
If not, what should I do instead? Nothing shows up in my imagearc, if I change $superColor to $red, it shows up a nice, red circle.

An echo test shows that $_POST[‘color’]; works just fine

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T14:21:01+00:00Added an answer on May 25, 2026 at 2:21 pm

    You index $_POST with names, not ids. Change your input definitions to name=”color”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am just getting started with Silverlight and have recently added a Silverlight project
I've recently started playing around with ASP.NET and I was just about to connect
I have recently started playing around with iOS development and have got most of
I've recently started playing with CouchDB and just into some small issues. I am
I've just recently started learning/using Ruby at work. I've got a super-simple test script
I've recently started playing around with the ASP.NET MVC NerdDinner sample, and as part
I've recently been learning python and I just started playing with networking using python's
I recently started playing with C#, but I am finding it very frustrating. It
I don't know much about this, just having recently started with JavaScript, so simple
I have just started playing around with using Dojo in Zend Framework and things

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.