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 4547688
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T16:07:33+00:00 2026-05-21T16:07:33+00:00

GOAL : Trying to make sure none of the fields are left blank including

  • 0

GOAL: Trying to make sure none of the fields are left blank including the radio button set and the dropdown. Anyone?

HTML

<form action="add_p_c.php" method="post"> 
    Professor<input type="radio" name="addType" />&nbsp;&nbsp;Course<input type="radio" name="addType" /> 
    <br><br>Name: <input type="text" name="name" /><br> 
    Department: <select name="deptName"><option>Department 1</option> <option>Department 2</option></select>
    Email: <input type="text" name="email" /><br>
    <input type="submit" name="submit" /> 
</form> 

**PHP (add_p_c.php) **

 <?php
if (isset($_POST['submit'])) {
if (empty($selected_radio)){ echo "You need to select a prof or course";} else(return;)
    $selected_radio = $_POST['addType'];
if (empty($course_prof_name)){ echo "You need to enter a name";} else(return;)
    $course_prof_name = $_POST['name'];
if (empty($select_dep)){ echo "You select a dept";} else(return;)
    $select_dep = $_POST['deptName'];
$email = $_POST['email'] = "myemail@email.com"; 
if(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) { 
  return; 
} 
else { 
  echo "<span color='red;'>Invalid email address.</span>"; 
} 
}
?>
  • 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-21T16:07:34+00:00Added an answer on May 21, 2026 at 4:07 pm

    For the sake of safety, you should add in certain things to improve security, because if you do any queries to a DB, you could get an SQL injection. Try this:

    <?php
    if(isset($_POST['submit']){
    
        $_POST['name']= trim(strip_tags(addslashes($string)));
        $_POST['deptName']= trim(strip_tags(addslashes($string)));
        $_POST['email']= trim(strip_tags(addslashes($string)));
    
                /* I can't remember if it should be '' or NULL, but some simple testing will let you know which it is*/
        if($_POST['addType'] != ''){
             if($_POST['name'] != ''){
                if($_POST['deptName'] != ''){
                    if($_POST['email']) != ''){
                        $selected_radio = $_POST['addType'];
                        $course_prof_name = $_POST['name'];
                        $select_dep = $_POST['deptName'];
                        $email = $_POST['email'] = "myemail@email.com"; 
                        if(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) { 
                            return; 
                        } 
                        else { 
                            echo "<span color='red;'>Invalid email address.</span>"; 
                        } 
                    }
                    else{
                        // email wasn't set
                    }
                }
                else{
                    //deptName wasn't set
                }
            }
            else{
                //name wasn't set
            }
        }
        else{
            // add type wasn't set
        }
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to set up integration tests using the AbstractTransactionalJUnit4SpringContextTests base class. My goal
I am trying to make a simple search where my goal is to avoid
First let me explain my goal. I am trying to make an Animation that
Goal: I am trying to create a UI with 2 checkboxes per line, each
Goal: I'm trying to refresh content inside a div so that if the user
The overall goal I'm trying to accomplish is to implement a customizable avatar system
I'm trying to run exec-maven-plugin 's exec:java goal on a simple two-module project where
I am trying to achieve a very simple goal, however it does not seem
Im trying to create a moving back ground. My goal is to have a
I'm trying to use custom meta boxes in wordpress. My goal at the moment

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.