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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:01:54+00:00 2026-05-23T10:01:54+00:00

Ok I am trying to get this form to where if someone skip something

  • 0

Ok I am trying to get this form to where if someone skip something on the form it will come up and tell them. I am a newbie and I am not understanding on how to get that error to come up if someone dont enter the information. This is what I have

  <?php
 function showForm($strMessage){
echo "<h1>".$strMessage."</h1>";
echo " <p>Note: fields marked with '*' are required</p>\n";
echo "<form action=\"".$_SERVER['PHP_SELF']."\" method=\"post\">\n";
echo "<table width=\"45%\" class=\"formtable\" cellpadding=\"3\" cellspacing=\"0\">\n";
echo "  <tr>\n";
echo "      <td><span id=\"rfvname\">* Name:</span></td>\n";
echo "      <td><input type=\"text\" name=\"name\"   value=\"".$_POST['name']."\"  /></td>\n";
echo "  </tr>\n";
echo "    <tr>\n";
echo "      <td><span id=\"rfvemail\">* E-mail:</span></td>\n";
echo "      <td><input type=\"text\" name=\"email\" value=\"".$_POST['emial']."\" /></td>\n";
echo "  </tr>\n";
echo "      <tr>\n";
echo "      <td><span id=\"rfvusername\">* Username:</span></td>\n";
echo "      <td><input type=\"text\" name=\"username\" value=\"".$_POST['username']."\" /></td>\n";
echo "  </tr>\n";
echo "  <tr>\n";
echo "        <td><span id=\"rfvpword\">* Password:</span></td>\n";
echo "        <td><input type=\"password\" name=\"pword\" value=\"".$_POST['pword']."\" /><br /><span style=\"font-size:9px;\"><em>(at least 4 chars) </em></span></td>\n";
echo "  </tr>\n";
echo "    <tr>\n";
echo "      <td><span id=\"rfvpword\">* Re-enter Password:</span></td>\n";
echo "      <td><input type=\"text\" name=\"repword\" value=\"".$_POST['repword']."\" /></td>\n";
echo "  </tr>\n";
echo "  <tr>\n";
echo "         <td>&nbsp;</td>\n";
echo "         <td><input type=\"submit\" value=\"Submit\" class=\"btnSubmit\" id=\"btnSubmit\" name=\"submit\" /></td>\n";
echo "  </tr>\n";
echo "</table>\n";
echo "</form>\n";
 }
 ?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1  /DTD/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 <head>
 <title>Contact Form</title>
  <style type="text/css">
   body{
        background-color:#FFBD40;
        color:#000000;
        font-size:100%;
        font-family:Georgia,Verdana,"Times New Roman",sans-serif;
     }


    #container{
        background:#FFF573;
        width:800px;
        margin:auto;
        padding:5px 10px 5px 10px;
        border:6px double #000000;
      }
       </style>
  </head>
  <body>
  <div id="container">
   <?php
   if (isset($_POST['submit'])){
  if (trim($_POST['name'])==""){
    $strMessage="Please enter your name!";
    showForm($strMessage);
   }
   elseif (strlen(trim($_POST['pword']))<=3){
    $strMessage="Your password must be at least 4 characters long!";
    showForm($strMessage);
  }
    else{
     $strMessage="Thank you, your information has been submitted. Below is the information you sent:";
     $strMessageBody.="Name: ".trim(stripslashes($_POST['name']))."<br />";
     $strMessageBody.="E-mail: ".trim(stripslashes($_POST['email']))."<br />";
     $strMessageBody.="UserName: ".trim(stripslashes($_POST['username']))."<br />";
     $strMessageBody.="Password: ".trim(stripslashes($_POST['pword']))."<br />";
     $strMessageBody.="Re-enter Password: ".trim(stripslashes($_POST['repword']))."<br />";
    echo "<h1>".$strMessage."</h1>";
    echo $strMessageBody;
}
   }
 else{
$strMessage= "Please fill out the form below to send your information:";
showForm($strMessage);
}
   ?>php
    $$errors = array();
    if (isset($_REQUEST["seen_already"])){
    validate_data();
    if(count($errors) ! = 0){
    display_errors();
    display_welcome();
    } else {
    display_welsome();
    }
    function validate_data()
    {
    global $errors;
    if($_REQUEST["Name"]==""){
    $errors[] = "<FONT COLOR='RED'>Please enter your first name</FONT>";
    }
    if($_REQUEST["E-mail"]==""){
    $error[] = "<FONT COLOR='RED'>Please enter your E-Mail>/FONT>";
    }
    if($_REQUEST["UserName"]==""){
            $errors[] = "<FONT COLOR='RED'>Please enter your Username</FONT>";
    }
    if($_REQUEST["Password"]==""){
            $errors[] = "<FONT COLOR='RED'>Please enter your Password</FONT>";
    }
    if($_REQUEST["RE-enter Password"]==""){
            $errors[] = "<FONT COLOR='RED'>Please  re-enter your Password</FONT>";
    }
   }
   function display_errors()
   {
      global $errors;

      foreach($errors as $err){
        echo $err, "<BR>";
        }
      }
      function process_data()


 </div>
  </body>
  </html>

Well the echo’s and the ” and \ is how I have to set this all up. So it is suppose to look like that. And all i am asking is if someone can help me understand how to do the error code. Not to do it for me but help me understand it. Is the code i already started on will it work or am I doing it all messed up. And thank to whoever is voting me down.I am just asking a simple question.

  • 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-23T10:01:54+00:00Added an answer on May 23, 2026 at 10:01 am

    Your problem is this:

     $_REQUEST["RE-enter Password"]
    

    You used the textual label for the form fields. But your actual input field is called:

     $_REQUEST["repword"]
    

    Likewise for all the other fields. The $_REQUEST array holds the keys according to the name= attributes in the HTML form.


    Something else: You can also simplify the form output. Instead of the many echos you should use a heredoc string to avoid the many " dquotes and \ backslash escapes:

    echo <<<HTML
     <h1>$strMessage</h1>
     <p>Note: fields marked with '*' are required</p>
     <form action="$_SERVER[PHP_SELF]" method="post">
     <table ...
          <td><span id="rfvname">* Name:</span></td>
         <td><input type="text" name="name"   value="$_POST[name]"></td>
     ...
    HTML; 
    

    Also add $_POST = array_map("htmlentities", $_POST); before that (for simplicity/security).

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

Sidebar

Related Questions

I am trying to rewrite an url with GET-data from a form. This works
Im trying to get this working but for some reason it's just not right.
I'm trying to get this simple PowerShell script working, but I think something is
Trying to get this example working from http://www.munna.shatkotha.com/blog/post/2008/10/26/Light-box-effect-with-WPF.aspx However, I can't seem to get
Trying to get this to work, with no luck: [DataMember] public Type ParameterType {
Been trying to get this up and running for a while now. Basically i
I'm trying to get this sample for AJAX to WCF working, with the following
I'm trying to get this piece of code working a little better. I suspect
I've been trying to get this code to work for hours! All I need
I'm trying to get this sitemap clas s working. It appears to use LINQ,

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.