#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    32
    Rep Power
    1

    Duplicate Submissions on PHP forms


    Hi All,

    First off I love this site and all of the Good Karma the skilled posters provide as it greatly helps guide a novice like me in the right direction. You all rule!!

    I have a form on a HTML page that processes through a PHP form on a server (with Godaddy) and the actual script is :

    PHP Code:
    <?php     
    $request_method 
    $_SERVER["REQUEST_METHOD"];
    if(
    $request_method == "GET"){       
    $query_vars $_GET;     
    } elseif (
    $request_method == "POST"){       
    $query_vars $_POST;    
    }     
    reset($query_vars);     
    $t date("U");      

    $file $_SERVER['DOCUMENT_ROOT'] . "/../data/gdform_" $t;     
    $fp fopen($file,"w");  

    $FTGName =  $_REQUEST['Name'] ; 
    $FTGPhone_AM =  $_REQUEST['Phone_AM'] ; 
    $FTGPhone_PM $_REQUEST['Phone_PM'] ; 
    $FTGEmail_Address $_REQUEST['Email_Address']; 
    $FTGStreet_Address $_REQUEST['Street_Address'] ; 
    $FTGCity $_REQUEST['City'] ; 
    $FTGZip_Code $_REQUEST['Zip_Code'] ; 
    $FTGNumber_Windows =  $_REQUEST['Number_Windows'] ; 
    $FTGComments =  $_REQUEST['Comments'] ;   

    if (
    $_POST ['Name'] == "" or 
    $_POST ['Phone_AM'] == "" or 
    $_POST ['Phone_PM'] == "" or 
    $_POST ['Email_Address'] == "" 

    header("Location: http://www.mydomainname.com/error.html"); exit; 
    }       

    include_once 
    $_SERVER['DOCUMENT_ROOT'] . '/securimage/securimage.php';     
    $securimage = new Securimage();     
    if (
    $securimage->check($_POST['captcha_code']) == false) {     
    header("Location: http://www.mydomainname.com/error.html");     
    exit; }      

    while (list (
    $key$val) = each ($query_vars)) {      
    fputs($fp,"<GDFORM_VARIABLE NAME=$key START>\n");      
    fputs($fp,"$val\n");      
    fputs($fp,"<GDFORM_VARIABLE NAME=$key END>\n");      
    if (
    $key == "redirect") { $landing_page $val;}     
    }  

    $emailTo 'MFW <info@mydomainname.com>';  

    $emailSubject 'Request from MFW Web Site';  

    $emailBody "Name : $FTGName\n"  
    "Phone AM : $FTGPhone_AM\n"  
    "Phone PM : $FTGPhone_PM\n"  
    "Email Address : $FTGEmail_Address\n"  
    "Street Address : $FTGStreet_Address\n"  
    "City : $FTGCity\n"   
    "Zip Code : $FTGZip_Code\n"  
    "Number of Windows : $FTGNumber_Windows\n"  
    "Comments : $FTGComments\n"  
    "";     

    $emailFrom "$FTGEmail_Address";    

    $emailHeader "From: $emailFrom\n"   
    "MIME-Version: 1.0\n"   
    "Content-type: text/plain; charset=\"ISO-8859-1\"\n"   
    "Content-transfer-encoding: 8bit\n";    

    mail($emailTo$emailSubject$emailBody$emailHeader); 

    fclose($fp);     
    if (
    $landing_page != ""){     
    header("Location: http://".$_SERVER["HTTP_HOST"]."/$landing_page");     
    } else {     
    header("Location: http://".$_SERVER["HTTP_HOST"]."/");     
    }  
    ?>
    The issue is I get duplicate submissions on the code I added to the Godaddy PHP form ( gdform.php ) and of course their IT is pretty bad to say it nicely. I understand that the email is already being pulled somehow and in the Godaddy server somewhere so how would I tweak the code above to submit and either not include the email I used above or bypass and omit the Godaddy server email that is stored?

    The Godaddy form also rearranges the fields and puts them in alphabetical order so their is no customization plus it even includes the CAPTCHA submission which is not needed for the email body area when received.

    I saw a gdform.cgi in the CGI folder and am not sure that is where I would need to tweak the server code if needed, but also pulled that code and it is:

    Code:
    #!/usr/bin/perl  
    sub parse_form_data 
    {     
    
    local (*FORM_DATA) = @_;     
    local  ( $request_method, $query_string, @key_value_pairs, $key_value, $key, $value);     
    $request_method = $ENV{'REQUEST_METHOD'};     
    if ($request_method eq "GET") {         
    $query_string = $ENV{'QUERY_STRING'};     
    } elsif ($request_method eq "POST") {         
    read (STDIN, $query_string, $ENV{'CONTENT_LENGTH'});
    };     
    
    @key_value_pairs = split(/&/, $query_string);     
    foreach $key_value (@key_value_pairs) {         
    ($key, $value) = split (/=/, $key_value);         
    if (defined($value)) {$value =~ tr/+/ /;             
    $value =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C", hex ($1))/eg;};         
    if (defined($FORM_DATA{$key})) {             
    $FORM_DATA{$key} = join (" ", $FORM_DATA{$key}, $value);         
    } else {             
    $FORM_DATA{$key} = $value;         
    }     
    } 
    }; # end of sub  
    
    &parse_form_data(*simple_form); 
    $t = time; 
    
    chdir ($ENV{'DOCUMENT_ROOT'}) ; chdir(".."); 
    open (OUTFILE, ">data/gdform_$t") or die ("Cannot open file"); 
    while (($key , $value) = each(%simple_form)) {    
    
    print OUTFILE "<GDFORM_VARIABLE NAME=$key START>\n";   
    print OUTFILE "$value\n";   
    print OUTFILE "<GDFORM_VARIABLE NAME=$key END>\n";   
    if ($key eq "redirect") { $landing_page = $value;}  
    } 
    
    close (OUTFILE);  
    
    if ($landing_page ne "") {   
    $scheck = index(lc($landing_page), "location:");   
    if ($scheck >= 0) {     
    print "Location: http://$ENV{'HTTP_HOST'}/\n\n";   
    } else {     
    print "Location: http://$ENV{'HTTP_HOST'}/$landing_page\n\n";   
    } 
    } else {   
    print "Location: http://$ENV{'HTTP_HOST'}/\n\n"; 
    }
    So basically since the server is sending duplicates how would I make the PHP form I coded (added to the gdform.php) show the fields below and only submit once:

    Name :
    Phone AM :
    Phone PM :
    Email Address :
    Street Address :
    City :
    Zip Code :
    Number of Windows :
    Comments :


    and NOT show as Godaddy is processing it like:

    City:
    Comments:
    Email_Address:
    Name:
    Number_Windows:
    Phone_AM:
    Phone_PM:
    Street_Address:
    Zip_Code:
    captcha_code:


    The form on the HTML page code is :
    Code:
    <form method="post" id="contactform" action="gdform.php" onsubmit="return formCheck(this);">
                                              <table width="211" border="0" align="center" cellpadding="0" cellspacing="0">
                                                <tr>
                                                  <td><table width="211" border="0" align="center" cellpadding="0" cellspacing="0">
                                                    <tr>
                                                      <td width="94"><div align="left"><span class="style2">Name:</span><span class="style21"><span class="style22">*</span></span></div></td>
                                                      <td width="114"><div align="left">
                                                          <input name="Name" type="text" id="Name" size="16" maxlength="55" />
                                                      </div></td>
                                                    </tr>
                                                    <tr>
                                                      <td><div align="left"><span class="style2">Phone (AM):</span><span class="style21"><span class="style22">*</span></span></div></td>
                                                      <td><div align="left">
                                                          <input name="Phone_AM" type="text" id="Phone_AM" size="16" maxlength="55" />
                                                      </div></td>
                                                    </tr>
                                                    <tr>
                                                      <td><div align="left"><span class="style2">Phone (PM):</span><span class="style22"> *</span></div></td>
                                                      <td><div align="left">
                                                          <input name="Phone_PM" type="text" id="Phone_PM" size="16" maxlength="55" />
                                                      </div></td>
                                                    </tr>
                                                    <tr>
                                                      <td><div align="left"><span class="style2">Email:</span><span class="style21"><span class="style22">*</span></span></div></td>
                                                      <td><div align="left">
                                                          <input name="Email_Address" type="text" id="Email_Address" size="16" maxlength="55" />
                                                      </div></td>
                                                    </tr>
                                                    <tr>
                                                      <td><div align="left"><span class="style2">Address:</span></div></td>
                                                      <td><div align="left">
                                                          <input name="Street_Address" type="text" id="Street_Address" size="16" maxlength="55" />
                                                      </div></td>
                                                    </tr>
                                                    <tr>
                                                      <td><div align="left"><span class="style2">City:</span></div></td>
                                                      <td><div align="left">
                                                          <input name="City" type="text" id="City" size="16" maxlength="55" />
                                                      </div></td>
                                                    </tr>
                                                    <tr>
                                                      <td><div align="left"><span class="style2">Zip Code:</span></div></td>
                                                      <td><div align="left">
                                                          <input name="Zip_Code" type="text" id="Zip_Code" size="16" maxlength="55" />
                                                      </div></td>
                                                    </tr>
                                                  </table></td>
                                                </tr>
                                                <tr>
                                                  <td>&nbsp;</td>
                                                </tr>
                                                <tr>
                                                  <td><div align="left"><span class="style2"><strong>Num.(#) Windows Needed:</strong></span><span class="style22">*</span></div></td>
                                                </tr>
                                                <tr>
                                                  <td height="21"><div align="left" class="style24">(6 Window Minimum)</div></td>
                                                </tr>
                                                <tr>
                                                  <td><div align="center"><span class="style21">
                                                    <select name="Number_Windows" id="Number_Windows">
                                                      <option value="ps" selected="selected">Please Select # of Windows</option>
                                                      <option value="6 - 10">6 - 10</option>
                                                      <option value="10 - 15">10 - 15</option>
                                                      <option value="15 +">15 +</option>
                                                      <option value="Undecided">Undecided</option>
                                                    </select>
                                                  </span></div></td>
                                                </tr>
                                                <tr>
                                                  <td>&nbsp;</td>
                                                </tr>
                                                
                                                <tr>
                                                  <td><div align="left"><span class="style2">Comments:</span></div></td>
                                                </tr>
                                                <tr>
                                                  <td><div align="center">
                                                    <textarea name="Comments" cols="19" rows="4" id="Comments"></textarea>
                                                  </div></td>
                                                </tr>
                                              </table>
                                              <p align="center">
            <img id="captcha" src="/securimage/securimage_show.php" alt="CAPTCHA Image" /><br />
            <span class="style31">Enter Code:</span><br />
            <input type="text" name="captcha_code" size="26" maxlength="26" />
            <br />
            <span class="style24">Click Below to Refresh Code </span>        <br />
            <a href="#" onclick="document.getElementById('captcha').src = '/securimage/securimage_show.php?' + Math.random(); return false"><img src="/securimage/images/refresh.png" alt="Reload Image" onclick="this.blur()" style="padding: 5px; height: 32px; width: 32px" align="bottom" /></a>
            <br />
            <input type="hidden" name="redirect" value="thankyou.html" />
            <input type="submit" value="Send Request" />
                                              </p>
                                          </form>
    NOTE: SORRY FOR THE CONFUSION AND DELETED POSTS BELOW - I AM STARTING TO GET THE HANG OF POSTING ON THIS FORUM NOW..

    Thanks in advance,
    JD
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,378
    Rep Power
    594
    You need to start by editing your post so your code is readable. You need to enclose your code in [ PHP ] tags. See the sticky at the top of this forum that says READ THIS BEFORE POSTING. At this point the easiest thing to do is remove the [ CODE ] tags, highlight the code, properly formatted, then click the PHP icon.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    32
    Rep Power
    1

    OK sorry about that and did the CODE tags by error


    deleted..
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    32
    Rep Power
    1

    That came out wrong above - let me see if this displays correctly


    deleted..
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    32
    Rep Power
    1

    Here it is with the lines in their correct alignment - will see how to delete post


    deleted...
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,378
    Rep Power
    594
    This is all very confusing, at least to me. You should have edited your original post rather than repost the code. You still did not use the tags correctly although at least it is now readable. Use code tags for HTML or perl and PHP tags for PHP. At this point it is also not clear what the issue is. Where is the form that has your PHP code as its action?
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    32
    Rep Power
    1

    Sorry - Cleaned up main post and removed others


    Originally Posted by gw1500se
    This is all very confusing, at least to me. You should have edited your original post rather than repost the code. You still did not use the tags correctly although at least it is now readable. Use code tags for HTML or perl and PHP tags for PHP. At this point it is also not clear what the issue is. Where is the form that has your PHP code as its action?
    Removed the other posts (marked deleted) and re-did the original post at the top. Thanks for being patient with a Newbie..
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,378
    Rep Power
    594
    OK, now you need to explain what you mean by duplicate submissions. Are you saying you are getting 2 emails?
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    32
    Rep Power
    1

    Yes


    Originally Posted by gw1500se
    OK, now you need to explain what you mean by duplicate submissions. Are you saying you are getting 2 emails?
    Yes, I receive one with the TO field as what is in the PHP form : MFW <info@mydomainname.com>

    and a duplicate submission coming from Godaddy's server showing info@mydomainname.com in a basic email form that I set in the Godaddy admin for the FORMAIL email.

    So their form is probably automatic and going to send unless I can tweak the PHP or CGI file code to not send from the server using that email.

    OR if that is too complicated I would need to tweak the form to ONLY pull from the server and list the fields in correct order (not alphabetical) and OMIT the captcha code in the email sent.

    Thx again..
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,378
    Rep Power
    594
    You won't be able to control what Go-Daddy does with the submission unless they offer some kind of optional setting that says to suppress the email. I see nothing in either script that specifically sends an email so it must be done outside of your control.

    The form itself has nothing to do with what you decide to put into your copy of the email. You control that content not Go-Daddy.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  20. #11
  21. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    32
    Rep Power
    1
    Originally Posted by gw1500se
    You won't be able to control what Go-Daddy does with the submission unless they offer some kind of optional setting that says to suppress the email. I see nothing in either script that specifically sends an email so it must be done outside of your control.

    The form itself has nothing to do with what you decide to put into your copy of the email. You control that content not Go-Daddy.
    Ok, well if I remove all of the code I added to that form and use the original code in the PHP itself (below) what would I add or tweak to have the fields ($vals ???) be in a certain order that I want and not arriving in alphabetical output?

    PHP Code:
    <?php
        $request_method 
    $_SERVER["REQUEST_METHOD"];
        if(
    $request_method == "GET"){
          
    $query_vars $_GET;
        } elseif (
    $request_method == "POST"){
          
    $query_vars $_POST;
        }
        
    reset($query_vars);
        
    $t date("U");

        
    $file $_SERVER['DOCUMENT_ROOT'] . "/../data/gdform_" $t;
        
    $fp fopen($file,"w");
        while (list (
    $key$val) = each ($query_vars)) {
         
    fputs($fp,"<GDFORM_VARIABLE NAME=$key START>\n");
         
    fputs($fp,"$val\n");
         
    fputs($fp,"<GDFORM_VARIABLE NAME=$key END>\n");
         if (
    $key == "redirect") { $landing_page $val;}
        }
        
    fclose($fp);
        if (
    $landing_page != ""){
        
    header("Location: http://".$_SERVER["HTTP_HOST"]."/$landing_page");
        } else {
        
    header("Location: http://".$_SERVER["HTTP_HOST"]."/");
        }
    ?>
    Is there some way to add a SORT VAL in the HTML form or through the PHP file above?
  22. #12
  23. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2009
    Location
    Nebraska, USA
    Posts
    867
    Rep Power
    275
    have you tried using the GODaddy support system ?

    I found THIS and THIS which may put you [or whomever decides to try to help with this] on the right track.

    IF the OP has webformmailer.php, it is suggested to use it if you want to control sorting...as gdform.php doesn't have that ability to control the sorting.
    Last edited by DonR; September 3rd, 2013 at 03:12 PM.
  24. #13
  25. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    32
    Rep Power
    1
    Originally Posted by DonR
    have you tried using the GODaddy support system ?

    I found THIS and THIS which may put you [or whomever decides to try to help with this] on the right track.

    IF the OP has webformmailer.php, it is suggested to use it if you want to control sorting...as gdform.php doesn't have that ability to control the sorting.
    Thanks and I will try it through the other method (webformmailer) since the gdform is alphabetizing the results and the only control you have is that they sort CAPITALS first, then lower case and then numbers, but I can not use that to get what is desired.

    Thanks again!

IMN logo majestic logo threadwatch logo seochat tools logo