PHP Code Pop-up...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • LANTEK
    New Member
    • Sep 2006
    • 7

    PHP Code Pop-up...

    I am currently working on a form that would have multiple fields plus an upload file spot. I cannot add the code for the upload file. Also, after clicking submit the form should send an email to the specified email address and currently those emails are not being recieved. All that happens is the php code box ocomes up and lets the user know that the form has been submitted and doesn't re-direct to the thank you page..Please help

    Here is my php formmail code...

    <?
    ///////////////////////////////////////////////////////////////////
    // PERFECT //
    ///////////////////////////////////////////////////////////////////

    // Configuration Settings
    $SendFrom = "sales@lantekon line.com";
    $SendTo = "ayob@lantekonl ine.com";
    $SubjectLine = "Feedback Submission";
    $ThanksURL = "http://www.lantekonlin e.com/html/asset_thankyou. htm"; //confirmation page
    $Divider = "~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~";

    // Build Message Body from Web Form Input
    $MsgBody = @gethostbyaddr( $_SERVER["REMOTE_ADD R"]) . "\n$Divider \n";
    foreach ($_POST as $Field=>$Value)
    $MsgBody .= "$Field: $Value\n";
    $MsgBody .= "$Divider\n " . $_SERVER["HTTP_USER_AGEN T"] . "\n";
    $MsgBody = htmlspecialchar s($MsgBody); //make content safe

    // Send E-Mail and Direct Browser to Confirmation Page
    mail($SendTo, $SubjectLine, $MsgBody, "From: $SendFrom");
    header("Locatio n: $ThanksURL");
    ?>
  • Motoma
    Recognized Expert Specialist
    • Jan 2007
    • 3236

    #2
    Originally posted by LANTEK
    I am currently working on a form that would have multiple fields plus an upload file spot. I cannot add the code for the upload file. Also, after clicking submit the form should send an email to the specified email address and currently those emails are not being recieved. All that happens is the php code box ocomes up and lets the user know that the form has been submitted and doesn't re-direct to the thank you page..Please help

    Here is my php formmail code...

    <?
    ///////////////////////////////////////////////////////////////////
    // PERFECT //
    ///////////////////////////////////////////////////////////////////

    // Configuration Settings
    $SendFrom = "sales@lantekon line.com";
    $SendTo = "ayob@lantekonl ine.com";
    $SubjectLine = "Feedback Submission";
    $ThanksURL = "http://www.lantekonlin e.com/html/asset_thankyou. htm"; //confirmation page
    $Divider = "~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~";

    // Build Message Body from Web Form Input
    $MsgBody = @gethostbyaddr( $_SERVER["REMOTE_ADD R"]) . "\n$Divider \n";
    foreach ($_POST as $Field=>$Value)
    $MsgBody .= "$Field: $Value\n";
    $MsgBody .= "$Divider\n " . $_SERVER["HTTP_USER_AGEN T"] . "\n";
    $MsgBody = htmlspecialchar s($MsgBody); //make content safe

    // Send E-Mail and Direct Browser to Confirmation Page
    mail($SendTo, $SubjectLine, $MsgBody, "From: $SendFrom");
    header("Locatio n: $ThanksURL");
    ?>
    Files are accessed via the $_FILES variable (much like $_POST and $_GET).
    In order to send mail, you will need to have your server configured to do so.
    A header("Locatio n:") call will not work if anything gets printed or echoed to the web-browser.

    Comment

    • LANTEK
      New Member
      • Sep 2006
      • 7

      #3
      Originally posted by Motoma
      Files are accessed via the $_FILES variable (much like $_POST and $_GET).
      In order to send mail, you will need to have your server configured to do so.
      A header("Locatio n:") call will not work if anything gets printed or echoed to the web-browser.


      How can I do that? Here is the form I am trying to work with, if it helps
      [HTML]<form action="formmai l.php" method="POST">
      <input type="hidden" name="recipient " value="ayob@lan tekonline.com">
      <input type="hidden" name="subject" value="Asset Investment Form">
      <input type="hidden" name="thanks" value="http://www.lantekonlin e.com/html/asset_thankyou. htm" />
      <input type="hidden" name="required" value="email,re alname">
      <input type="hidden" name="alias" value="email=E-mail Address,realnam e=Name">
      <input type="hidden" name="alias_met hod" value="email">
      <input type="hidden" name="mail_newl ine" value="2">
      <input type="hidden" name="env_repor t" value="REMOTE_H OST,REMOTE_ADDR ">
      <input type="hidden" name="print_bla nk_fields" value="true">
      <input type="hidden" name="gmt_offse t" value="-5">

      <table align="center" width="535" cellspacing="2" cellpadding="5" border="1" height="254">
      <tr>
      <td width="133" height="2" align="right">< font color="6e2f32" face="Alps">Nam e:</font></td>
      <td width="370" height="2" align="left"><i nput type="Text" name="realname" align="LEFT" size="35" maxlength="100" >
      </td>
      </tr>
      <tr>
      <td align="right">< font color="6e2f32" face="Alps">Ema il: </font></td>
      <td align="left"><i nput type="Text" name="email" align="RIGHT" size="35" maxlength="100" >
      </td>
      </tr>
      <tr>
      <td align="right">< font color="6e2f32" face="Alps">Tit le: </font></td>
      <td align="left"><i nput type="Text" name="title" align="RIGHT" size="35" maxlength="100" >
      </td>
      </tr>
      <tr>
      <td align="right" height="4"><fon t color="6e2f32" face="Alps">Com pany:</font></td>
      <td align="left" height="4"><inp ut type="Text" name="company" size="35" maxlength="100" >
      </td>
      </tr>
      <tr>
      <td align="right" height="4"><fon t color="6e2f32" face="Alps">Add ress:</font></td>
      <td align="left" height="4"><inp ut type="Text" name="Address" align="LEFT" size="35" maxlength="100" >
      </td>
      </tr>
      <tr>
      <td align="right" height="4">&nbs p;</td>
      <td align="left" height="4"><inp ut type="Text" name="Address2" align="LEFT" size="35" maxlength="100" >
      </td>
      </tr>
      <tr>
      <td align="right">< font color="6e2f32" face="Alps">Cit y, State Zip: </font></td>
      <td align="left"><i nput type="Text" name="city" align="LEFT" size="25" maxlength="75">
      &nbsp;&nbsp;&nb sp;
      <input type="Text" name="State" align="LEFT" size="2" maxlength="2">
      &nbsp;&nbsp;&nb sp;
      <input type="Text" name="Zip" align="LEFT" size="5" maxlength="10">
      </td>
      </tr>
      <tr>
      <td align="right">< font color="6e2f32" face="Alps">Pho ne: </font></td>
      <td align="left"><i nput type="Text" name="phone" align="LEFT" size="15" maxlength="15">
      &nbsp;&nbsp;&nb sp; </td>
      </tr>
      <tr>
      <td align="right">< font color="6e2f32" face="Alps">Fax : </font></td>
      <td align="left"><i nput type="Text" name="fax" align="LEFT" size="15" maxlength="15">
      &nbsp;&nbsp;&nb sp; </td>
      </tr>
      </table>
      <table width="535" border="1" align="center" cellpadding="5" cellspacing="2" >
      <tr>
      <td colspan="2"><fo nt color="6e2f32" face="Alps">Ple ase provide an approximate asset inventory: </font></td>
      </tr>
      <tr>
      <td width="287" height="202"><p ><font color="6e2f32" face="Alps"><br >
      Manufacturer(s) , Model(s), Quantity, Specifications( If possible): <br>
      </font></p>
      <p><font color="6e2f32" face="Alps">Do you currently have a PC Refresh Plan?(If yes, how many years?)<br>
      <br>
      If you have a pre-existing file containing this information, please upload it here</font></p></td>
      <td width="242"><p>
      <textarea name="manufactu rer_model_Quant ity_spec"></textarea>
      </p>
      <p> <font color="6e2f32" face="Alps">
      <input name="yes_no" type="Text" size="4" maxlength="4">
      <input name="Years" type="Text" id="Years" size="10" maxlength="10">
      </font><br>

      <br>
      </p>
      <p> <input type="file" name="upload">
      </p></td>
      </tr>
      </table>
      <font color="#0000A0" ><BR>
      </font>
      <DIV align="center">
      <INPUT name="submit" type="submit" value="Submit">
      </DIV>
      </form>[/HTML]

      Comment

      • Motoma
        Recognized Expert Specialist
        • Jan 2007
        • 3236

        #4
        This link explains file uploads in PHP.

        Comment

        • LANTEK
          New Member
          • Sep 2006
          • 7

          #5
          So if i understand that correctly, i need to use 2 form tags for this script?

          Comment

          • Motoma
            Recognized Expert Specialist
            • Jan 2007
            • 3236

            #6
            Originally posted by LANTEK
            So if i understand that correctly, i need to use 2 form tags for this script?
            No, you will need to set your form's ENCTYPE properly, and access your file through the $_FILES variable.

            Comment

            Working...