Jump to content

Multi-page form problem(s)


Shockstomp

Recommended Posts

Hello everyone,

First and foremost I am a novice with php.

I understand it and everything, but I have made a mess of this script. I was wondering if I should just start from scratch on the php end.

GOAL- I am trying to make a multi-page form that emails the results to me when it's finished. I also plan on making this an openly available template for anyone who needs it. (mail() is not yet complete)
(
SCRIPT- 3 pages, first page: Enter Contact info, second page: enter equipment details, final page: text box for additional requirements.

This is what i have thus far, I actually include it into another page. (you WILL find it strikingly similar to the "cheese" script :P, i am still working on writing scripts from scratch).


Once again, I warn you of the mess below.(if this is too much i can just link the file, let me know mods, tks)
*********************************************************************************

/*<style type="text/css">
<!--
.style2 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;

}
.style3 {font-size: 10px}
.style7 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
font-variant: small-caps;
}
.style8 {
font-size: 12px;
font-weight: bold;
}
-->
</style>

<?php */?>  <div align="right"><span class="style2">
    <span class="style3">
    <?php
    function display_contact() {
    global $PHP_SELF;

    ?>
    </span></span></div>
    <FORM METHOD=GET TARGET="<?php echo $PHP_SELF; ?>" class="style7">
     
      <div align="right"><span class="style8">Step 1 - Contact Information        </span>
      </div>
      <p align="right">Contact Name
        <INPUT TYPE=TEXT NAME="name">
      </p>
      <p align="right">Company
        <INPUT TYPE=TEXT NAME="comp">
      </p>
      <p align="right">Address
        <INPUT TYPE=TEXT NAME="addr">
      </p>
      <p align="right">City
        <INPUT TYPE=TEXT NAME="city">
      </p>
      <p align="right">State/Province
        <INPUT TYPE=TEXT NAME="st-pr">
      </p>
      <p align="right">Country
        <INPUT TYPE=TEXT NAME="country">
      </p>
      <p align="right">Zip/Postal Code
        <INPUT NAME="zip-pc" TYPE=TEXT size="15">
      </p>
      <p align="right">Telephone
        <INPUT TYPE=TEXT NAME="tel">
      </p>
      <p align="right">Fax
        <INPUT NAME="fax" TYPE=TEXT size="20">
      </p>
      <p align="right">Email
        <INPUT TYPE=TEXT NAME="from">
      </p>
      <p align="right"><BR>
        <INPUT TYPE=HIDDEN NAME="stage" VALUE="contact">
        <INPUT TYPE=SUBMIT VALUE="Next">
                          </p>
    </FORM>
      <div align="right"><span class="style7">
        <?php
    }
    ?>
       
        <?php
function display_equip() {
  global $PHP_SELF;
  global $contact;
?>
        </span>
      </div>
    <FORM METHOD=GET TARGET="<?php echo $PHP_SELF; ?>" class="style7">
 
    <div align="right"><span class="style8">Step 2 - Tool Specifications</span>
    </div>
    <p align="right">Hole Opener Type:
      <input type=TEXT name="hotype" />
    </p>
    <p align="right">      Hole Diameter / OD:
      <INPUT NAME="od" TYPE=TEXT size="8">
    </p>
    <p align="right">Pilot Bit OD:
      <INPUT NAME="pbod" TYPE=TEXT size="8">
    </p>
    <p align="right">Number of Cutters:
      <INPUT NAME="ncw" TYPE=TEXT size="8">
    </p>
    <p align="right">Cutter Type:
      <INPUT TYPE=RADIO NAME="cuttertype" VALUE="tci">
  TCI / Button / Insert
          <INPUT TYPE=RADIO NAME="cuttertype" VALUE="tooth">
          Steel Tooth / Mill Tooth    </p>
    <p align="right">IADC Code / Formation Type / Hardness Information: 

      <INPUT TYPE=TEXT NAME="iadc-formation">
      <br />
      <a href="http://www.bitbrokers.com/iadc.php" target="_blank">NEED HELP? CLICK HERE</a></p>
    <p align="right">Top Connection:
      <INPUT NAME="tc" TYPE=TEXT size="8">
    </p>
    <p align="right">      Bottom Connection:
      <INPUT NAME="bc" TYPE=TEXT size="8">
    </p>
    <p align="right">Circulation Type:
      <INPUT TYPE=RADIO NAME="circ" VALUE="air">
      Air
      <INPUT TYPE=RADIO NAME="circ" VALUE="fluid">
    Fluid</p>
    <p align="right">      Circulation Pump Type:
      <INPUT NAME="cpt" TYPE=TEXT size="15">
      <br />

      <INPUT TYPE=HIDDEN NAME="contact" VALUE="<?php echo htmlspecialchars($contact); ?>">
      <INPUT TYPE=HIDDEN NAME="stage" VALUE="equip">
      <INPUT TYPE=SUBMIT VALUE="Next">
    </p>
    </div>
</FORM>
      <div align="right"><span class="style7">
        <?php
}
?>
       
        <?php
function display_notes() {
  global $PHP_SELF;
  global $contact;
  global $equip;

?>
        </span>
      </div>
    <FORM METHOD=GET TARGET="<?php echo $PHP_SELF; ?>" class="style7">

        <div align="right"><span class="style8">Step 3: Additional Notes / Special Requirements</span><br />
         
          <textarea name="req" cols="35" rows="10"></textarea>
          <br />
          <INPUT TYPE=HIDDEN NAME="contact" VALUE="<?php echo htmlspecialchars($contact); ?>">
          <INPUT TYPE=HIDDEN NAME="equip" VALUE="<?php echo htmlspecialchars($equip); ?>">
          <INPUT TYPE=HIDDEN NAME="stage" VALUE="notes">
          <INPUT TYPE=SUBMIT VALUE="Submit">
        </div>
    </FORM>
      <div align="right"><span class="style7">
        <?php
}
?>

        <?php
if (empty($stage)) { display_contact(); }
elseif ($stage == 'equip') { display_equip(); }
elseif ($stage == 'notes') { display_notes(); }
else { mail(); }
?>
        </span>
       
      </div>
    </div>*/


Thanks for any help!

Also, to show that I am not COMPLETELY dense to programming here is a link to another form I installed/modified.
http://www.bitbrokers.com/contact.php

The problem form will be at: http://www.bitbrokers.com/custom_built_hole_openers.php
Link to comment
Share on other sites

I need to know about the following:

-If global $PHP_SELF and <INPUT TYPE=HIDDEN NAME="contact" VALUE="<?php echo htmlspecialchars($contact); ?>">
can carry ALL variables from the first page , or if I must do this with all of the inputs

-Does the mail() function allow for a message with dynamic content? ie. A table in the email with values inserted accordingly


Like I said, I am no guru by any means.

Thanks
Link to comment
Share on other sites



This is the line I use when I just wanna dump ALL my form values to the next page.

[code]
foreach($_REQUEST as $var=> $val){echo "<INPUT TYPE='hidden' VALUE='$val' NAME='$var' >";}
[/code]

These will only xfer to the next page if contained within a form that is submitted to the next page, and only if you dont have any single quotes in your data.

And yes, you can put HTML characters into an email, but if viewed from a email program that isnt HTML-capable it will just dump all the tags along with the content into the body of the email.
Link to comment
Share on other sites

this is something similar i think, and i wasn't sure what to do with it.

/*<?php

/* ---------------------
    Declare Variable(s)
  --------------------- */

$name; // Represents the name of the elements in $HTTP_POST_VARS
$value; // Represents the value of the elements in $HTTP_POST_VARS


// ---------------------

// Do while there is an element in $HTTP_POST_VARS...

while (list($name, $value) = each($HTTP_POST_VARS))

  /* ...get the name and value of the element and use it to construct a hidden input field. 
      Then go back to the beginning of the loop and do the same thing with the next element. */

  {
  echo "<input type=\"hidden\" value=\"$value\" name=\"$name\">\n";
  }

?>*/



Also, this is the mail function that i am going to manipulate.

/*
<?php
  $to = $_REQUEST['to'] ;
  $confirmationSubject='Bitbrokers.com Hole Opener Inquiry Confirmation';
  $confirmationBody="Your hole opener inquiry has been received, thank you.

If your inquiry is urgent please call (618)435-5811 or fax (618)435-2388.

Your inquiry is shown below.
**********************************************************************************

";
  $from = $_REQUEST['from'] ;
  $message= $_REQUEST['message'] ; <<<<< My email template will be defined here.
  $displayForm=true;
  if ($_POST){
    $from=stripslashes($_POST['from']);
    $message=stripslashes($_POST['message']);
    // validate e-mail address
    $valid=eregi('^([0-9a-z]+[-._+&])*[0-9a-z]+@([-0-9a-z]+[.])+[a-z]{2,6}$',$from);
    $crack=eregi("(\r|\n)(to:|from:|cc:|bcc:)",$message);
    if ($from && $message && $valid && !$crack){
      if (mail('bitsales@bitbrokers.com',"BBI Hole Opener Web Inquiry",$message,'From: '.$from."\r\n")
          && mail($from,$confirmationSubject,$confirmationBody.$message,'From: '.$to."\r\n")){
        $displayForm=false;
?>
*/

I will have error messages for incomplete or invalid fields also.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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