Jump to content

FORM not processing correctly...


StroiX

Recommended Posts

 

I used to have a separate FORM (step1.php) that asked for "Personal Information" and "Work Information" on a separate .html page which processed "step2.php", however now I have combined these two steps in "combined.php".

 

I am having 2 issues that I am not sure how to tackle and would be gratefull for your help.

 

1) When "combined.php" is ran, it gives the following error:

Notice: Undefined index: group1 in /Web Directory/ur/combined.php on line 26

 

2) The "Other Information" is always visible now, and I would like it to only show after a choice is made from "Personal Information" or "Work Information", of course it wouldn't matter since this is the information that would show regardless, I just don't want it to show at the time the selection is made.

 

I have played around with a few things, but I don't think I am doing it correctly, and would really appreciate if someone could provide a working example, but your advice is very much needed as well!  =)

 

combined.php:


<html>
<head>

<title>Untitled Document</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="step2.php">
  <p>
    <input type="radio" name="group1" value="personal">
    Personal Information
    <br>
  <input type="radio" name="group1" value="work" checked>
  Work Information</p>
  <p>
    <label>
    <input type="submit" name="submit" id="submit" value="continue..." />
    </label>
    <br>
    </p>
</form>

<?php

$group1 = $_POST['group1'];

if ($group1 == "personal"){

print<<<HERE

   <form id="form1" name="form1" method="post" action="process.php">
     <p><strong>Personal Information</strong></p>
     <p>Full Name: 
       <label>
   
       <input type="text" name="name" id="name" />
       </label>
     </p>
     <p>Cell Phone: 
       <label>
       <input type="text" name="cellphone" id="cellphone" />
       </label>
     </p>
  
HERE;

} else if ($group1 == "work") {

print<<<HERE

   <form id="form1" name="form1" method="post" action="process.php">
     <p><strong> Work Information</strong></p>
     <p>Company Name: 
       <label>
       <input type="text" name="company" id="company" />
       </label>
     </p>
   
     <p>Work Phone: 
       <label>
   
       <input type="text" name="workphone" id="workphone" />
       </label>
     </p>

HERE;
}

?>

  <hr />
  <p><strong>Other Information</strong></p>
  <p>Your message:</p>
  <p>
    <label>

    <textarea name="message" id="message" cols="45" rows="5"></textarea>
    </label>
  </p>
  <p> </p>
  <p>
    <label>
    <input type="submit" name="submit" id="submit" value="Submit" />
    </label>

  </p>
</form>
</body>
</html>

 

Thank you for your help with this.

 

Link to comment
https://forums.phpfreaks.com/topic/100178-form-not-processing-correctly/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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