POST data not posting, and other issues...

I have a fom that uses passed values from a linked page. I am writing a simple form for people to request an auto quote from some insurance agents that are helping our charity fundraiser. It uses two values “agent” and “agentEml” from a prior page so that the form data can be sent to the proper agent. I want the form to write to a basic text file on the server, and also send the date in a formatted email to the agent.

Right now I am going step by step just making sure things are working as I go. It seems that some of my POST items are not writing to the txt file. Also, it seems that data does not always write to the txt file either. Its not consistent. I will hit the submit button once, and the form seems to post successfully, but there is nothing in the data file. I do it again, and still nothing. Then again and it writes, but not all of the data from the form. Its driving me nuts. I cant find any problems that I can see. So maybe someone here can help.

Here is the URL that is passing the initial data:

here is the form code[code]

CureT1 - Alfa Quote Request Form <?php $agent = $_GET['agent']; $agentEml = $_GET['agentEml']; ?>

and here is the php file code: [php]<?php

$agent = $_POST[‘agent’];
$agentEml = $_GET[‘agentEml’];
$FN = $_POST[‘FN’];
$LN = $_POST[‘LN’];
$PH = $_POST[‘PH’];
$Eml = $_POST[‘Eml’];
//the data
$data = “$agent | $agentEml | $FN | $LN | $PH | $Eml”;

//open the file and choose the mode
$fh = fopen(“requests.txt”, “a”);

fwrite($fh, $data); //close the file
print “Request Submitted”;

//close the file


Please help. I really need to get this figured out and I am stumped now…

Agent Name
Your First Name
Your Last Name
Your Email
Your Phone Number


This might not resolve your issues, but it might be worth going over your form with a fine comb. There are a few things that stand out:

  1. The use of 'id’s for all of your input fields seems unnecessary if you’re not going to use that id for something. I would therefore remove them, as it might lead to unnecessary mistakes such as: id="“PH”.
    I would create inputs as follows:
<input type="text" name="PH" style="width: 200px" value="000-000-0000"/>
  1. Match up the ‘name’ of your form with the $_POST in your final page, eg:
    will not match up with
    $PH = $_POST[‘PH’];

  2. Recognize that the Agent e-mail is not being passed to the next page:
    On your form page you have a line: $agentEml = $_GET[‘agentEml’];
    And on your inquiry page you have a line: $agentEml = $_GET[‘agentEml’];
    But there is nothing that passed this value from the form page to the enquiry page.

I would personally create a hidden input that passes this variable along:

<input type="hidden" name="agentEml" value="<?php echo $agentEml; ?>"/>

Which you would then retrieve as a $_POST variable on your enquiry page

$agentEml = $_POST['agentEml'];

This might not resolve your entire problem, but it will be a good start.

Sponsor our Newsletter | Privacy Policy | Terms of Service