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

  • SEARCH
  • Home
  • 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 8506671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:39:14+00:00 2026-06-11T02:39:14+00:00

So I made a registration form such that the user must select one of

  • 0

So I made a registration form such that the user must select one of the three radio options before continuing. However if the user didn’t choose an option and clicked submit I want to display at least a message that says “please choose an option” or something. Here is my code so far:

<?php
$reg_type = "";
function setclick()
{
    if(isset($_POST["Submit"]))
        $clicked=1;
    else 
        $clicked=0;
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    if (empty($_POST["Reg_type"])) {
        $clicked=1;
        header('Location: Registration_1.php');
    }
    else {
        $reg_type = $_POST["Reg_type"];
        header('Location: Registration_2.php');
    }
}
echo $clicked;
?>

<form name="frmtype" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="POST" >
<input type="radio" name="Reg_type" value="1"/> Registering myself with credit card or bank account <br/>
<input type="radio" name="Reg_type" value="2"/> Registering multiple people using credit card or bank account <br/>
<input type="radio" name="Reg_type" value="3"/> Registering multiple people using a purchase order <br/>
<input type="submit" name="Submit" value="Submit" />
<?php 
setclick();
if($clicked)
    echo "Please select an option";
?>

I’m having a real hard time getting the logic down to display the error message if they didn’t choose an option and clicked submit.

  • 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-06-11T02:39:16+00:00Added an answer on June 11, 2026 at 2:39 am

    Your setclick() function will always set $clicked to true if the form has been posted. Since you then call setclick() after your main php block, it will be true whether or not the rest of the logic has changed it. Try this:

     if(isset($_POST['Reg_type']) && $_POST['Reg_type'] != ''){ 
        $reg_type = $_POST['Reg_type'];
        header('Location: Registration_2.php');
     } else $clicked = true;
    

    and then down the bottom of the page under the form:

     if($clicked) echo "Please select an option";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have made customized user registration page. and i have made that on theme
I just made the registration form for my website, however I have zero knowledge
I have a registration form on my layout grid, made out of a stackPanel.
I made an extension for IE9 that adds a toolbar button. The registration looks
I have several text fields which compromise a registration form . When the user
I have made a form for client registration, and I can't make this postvalidators
I have made a user registration where I have salted the user password and
i have made user-register.tpl.php file. And i have set many text field in that.
I have simple registration form. Once all information entered, user click submit button and
I have made user registration which includes (name, password, email, phone no) and now

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.