Error on line... 15... parse? Help please

Hello everybody.

I have another problem with the design of my website.

I have build a form and have done some coding (copying from another one and trying to follow the logic as I am not a proprammer).

I do realise that when I am on line 15, Dreamwever itself indicates the line but I do not know what is wrong with it.

I get this message when I submit my form;
Parse error: syntax error, unexpected T_VARIABLE in /websites/123reg/LinuxPackage21/pc/ho/me/pchometech.co.uk/public_html/thank_you.php on line 15

This is what I have written in my php page;

<?php
$to = $_REQUEST['query'];
$from = $_REQUEST['email'];
$name = $_REQUEST['f_name'];
$headers = "From: $from";
$subject = "Web Contact Data.";

$fields = array ();
$fields{"Name"} = "Name";

$headers2 = "From: [email]noreply@company.com[/email]";
$subject2 = "Thank you for contacting us.";
$autoreply = "Thank you for contacting us. We will get back to you as soon as possible, usualy within 6 hours. If you have any more questions, please consult our website at [Company.com](http://www.company.com). kind regards, Customer Care Dep."

$body ="We have received the following information:\
\
"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\
",$b,$_REQUEST[$a]); }


$send = mail($to, $subject, $body, $headers);
$send2 = mail($from, $subject2, $autoreply, $headers2);

?>

I have more fields to includ on it but for now I am just trying to get it to work.

Any help or comments about it are really appreciated.

To my previous html post, I extend my gratitude to all of those who helped.
Thanks.

You are missing a semicolon on line 13, where you assign a value to $autoreply

you have missed the semi colon ; off the end of the $autoreply line.

It’s one of those two lines. Put them on different lines for a start and that will give you more indication as to which one it is.

No need to put both on the same line especially when doing multiple things including a loop.

Hello everybody.

Many thanks for the fast replys and all the help provided within.

Now the form is working and sending the data away to an e-mail account accordingly to the query type selected.

One thing I wanted to do is to includ the initial, first and last name on the body answer to the customer as like;

Dear {Title}{First Name}{Last Name};
Thank you for contacting us…

Can this be done with PHP?

Again, any help well apprecited.

By the way, I have this sort of thing included now on the thank_you.php page but when I tried to include it on the body message of the autoreply Dreamwever reported as line being in error.

Thanks everybody.

Yes it can be done but you need to collect that information from your form. It’s done like this:

“Dear $Title $First $Last”

Like I said, you need to get those details from your form though so if you don’t have a first and last name text box you’re not going to be able to get their names from anywhere.

yep


$autoreply = "Dear $name, Thank you for contacting us. .....";

That should put the variable in place

Hello.

My Title, First and Last Name fields are as follow;

title
f_name
l_name
.

I have done as sugested but I get the e-mail as only Dear, and nothing comes through.

<?php
$to = $_REQUEST['query'];
$from = $_REQUEST['email'];
$name = $_REQUEST['f_name'];
$headers = "From: $from";
$subject = "Web Contact Data.";

$fields = array ();
$fields{"f_name"} = "First Name";
$fields{"l_name"} = "Last Name";

$headers2 = "From: [email]noreply@company.co.uk[/email]";
$subject2 = "Thank you for contacting us.";
$autoreply = "Dear $title $f_name $l_name,

Thank you for contacting us. 

We will get back to you as soon as possible, usualy within 6 hours. 
If you have any more questions, please consult our website at [Company](http://www.company.co.uk). 

kind regards, 
Customer Care Dep.";

$body ="We have received the following information:\
\
"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\
",$b,$_REQUEST[$a]); }


$send = mail($to, $subject, $body, $headers);
$send2 = mail($from, $subject2, $autoreply, $headers2);

?>

My HTML is;

</div>
  <div id="text_box_left"><span class="first_line">Customer contact form...</span><br />
    <br />
    <br />
    <form id="form1" name="form1" method="post" action="thank_you.php">
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="32%"><span id="spryselect1">
            <label for="title4">Title</label>
            <br />
            <select name="title" class="titlebox" id="title4">
              <option value="-1">Choose one...</option>
              <option>Mr</option>
              <option>Mrs</option>
              <option>Ms</option>
              <option>Miss</option>
            </select>
          <span class="selectInvalidMsg">*</span><span class="selectRequiredMsg">*</span></span></td>
          <td width="36%"><span id="sprytextfield1">
          <label for="f_name">First Name</label>
          <br />
          <input name="f_name" type="text" class="name_fields" id="f_name" />
          <span class="textfieldRequiredMsg">*</span><span class="textfieldMinCharsMsg">*</span><span class="textfieldMaxCharsMsg">*</span></span></td>
          <td width="32%"><span id="sprytextfield2">
          <label for="l_name">Last Name</label>
          <br />
          <input name="l_name" type="text" class="name_fields" id="l_name" />
          <span class="textfieldRequiredMsg">*</span><span class="textfieldMinCharsMsg">*</span><span class="textfieldMaxCharsMsg">*</span></span></td>
        </tr>
      </table>
      <br />
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="50%"><span id="sprytextfield3">
          <label for="email">E-Mail</label>
          <br />
          <input name="email" type="text" class="email" id="email" />
          <span class="textfieldRequiredMsg">*</span><span class="textfieldInvalidFormatMsg">*</span><span class="textfieldMinCharsMsg">*</span><span class="textfieldMaxCharsMsg">*</span></span></td>
          <td width="50%"><p>Subscribe newsletter? 
              <label>
              <input name="newsletter" type="radio" id="newsletter_0" value="Yes" checked="checked" />
              Yes</label> 
            <label>
              <input type="radio" name="newsletter" value="No" id="newsletter_1" />
              No</label>
            <br />
          </p></td>
        </tr>
      </table>
      <br />
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="55%"><span id="spryselect2">
            <label for="query">Query Type</label>
            <br />
            <select name="query" class="query_found" id="query">
              <option value="-1">Choose one...</option>
              <option value="general@company.co.uk">General</option>
              <option value="sales@company.co.uk">Sales</option>
              <option value="support@company.co.uk">Support</option>
              <option value="accounts@company.co.uk">Accounts</option>
              <option value="webmaster@company.co.uk">WebMaster</option>
            </select>
          <span class="selectInvalidMsg">*</span><span class="selectRequiredMsg">*</span></span></td>
          <td width="45%"><span id="spryselect3">
            <label for="found_us">You found us on...</label>
            <br />
            <select name="found_us" class="query_found" id="found_us">
              <option value="-1">Choose one...</option>
              <option>Google search</option>
              <option>Local add</option>
              <option>Advertiser</option>
              <option>Radio add</option>
              <option>World of mouth</option>
              <option>Already a customer</option>
            </select>
          <span class="selectInvalidMsg">*</span></span></td>
        </tr>
      </table>
      <br />
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td><span id="sprytextarea1">
          <label for="message">Your Message</label>
          <br />
          <textarea name="message" cols="45" rows="5" class="text_box" id="message"></textarea>
          <span id="countsprytextarea1">&nbsp;</span><span class="textareaRequiredMsg">*</span><span class="textareaMinCharsMsg">*</span><span class="textareaMaxCharsMsg">*</span></span></td>
        </tr>
      </table>
      <br />
      <input name="Submit" type="submit" class="button_size_left" id="Submit" value="Submit" />
      <input name="Clear" type="reset" class="button_size_right" id="Clear" value="Clear" />
    </form>
  </div>

Thanks for your fast reply.

Any help well apprecited.

Cheers.

You set those variables like this:
$f_name = $_REQUEST[‘f_name’];
$l_name = $_REQUEST[‘l_name’];

Then you can use them in your script.

Hello.

Funny enough I wast just to do that as I had this tutorial downloaded from tewizarddotcom and noticed that.

Cheers for all your help.

Thanks to eberybody and all the comments.

Hello again.

I have forgoton to ask this.

I have bumped into a form that I have downloaded and have deleted it somehow.
This form would do something quite useful.
On sendig the e-mail booth to the customer and to us, it would includ on the bottom of the boddy message the customers IP address, date and time and and ID number generated somehow.

How can I includ these? I have googled ever since for this of the form I got this so that I could have a peak at the code but could not fid it.

Any help, as before, well appreciated you guys and girls.

Cheers.

Albert, C

It’s not the form that generates that. You want to look at $_SERVER and specifically $_SERVER[‘REMOTE_ADDR’] which is the visitors IP address. Time and date you can work out using google, and ID number is almost certainly the auto_increment id of a mysql database table. You get the id of the inserted record by using mysql_insert_id()

Hello.

I must say that you lost me a bit there.

Do I have to have a SQL database on my hosting end?

I shall look into it tomorrow as today is time to hit the bed.

Everybody, thanks ever so much for all the help and support.

Cheers,
A very good night to you all.

Albert, C

Yes… it’s called mysql normally.

Oh boy.

In 15 years of IT I have never dealt with databases ever.

I have just checked with my hosting provider and yes, I can have up to 2 databases.

I have just created one and from now onwards I am clueless as to what to do. I have managed to go as far as creat a table which I believe I will have to right?

Any help with matter is trully apprecited as this is right over my head I’m afraid.

Cheers you guys.

I’ll be back tomorrow and most defenatelly will be Googling away. It seems that I can no longer run away from Google and forums on a daily basis now. I just want to finish this website.

Good night to you all.

Keep on the good work.

Yes you will need a table.

Basically think of a table as a spreadsheet. Each column has a name but importantly it also has a datatype (which in a spreadsheet you can do to by right clicking on the column header and selecting its type).

The difference being with a database you can have multiple tables and there is a good reason for that. You can setup a relational database and then link records from several tables together. Initially it sounds very daunting but once you’ve got the hang of it you’ll be fine and you’ll wonder how you ever managed without them.

Far superior to using text files for storing data.

Incidentally what have you been doing in IT for 15 years that 1)pays an income and 2) doesn’t need you to use databases? - Tell me I want that job!

Lol…

I was always self-employed doing the occasional works here and there.
Worked in Portugal mainly for schools on the network side of things and yeah, there was a database but nothing complicated. Just install the application on the server side and clients to keep records for every student like grades, attendance, establish the connection between clients and server etc… And I did not have anything to do with the database once it was up and running.

Been on the UK for the past 9 years and trying to step into the IT industry but that has proven to be quite hard.

I have done a Cisco qualification (CCNA) to which I have 1 more year remaining on my certification. I am planning on recertifying to the next level CCNP.

Even though I have not been employed on IT field, I do the occasional computer repair here and there and design and deploy small to medium networks whenever I have the chance to do it.

Anyways, I shall have a go at this MySQL thing and hope that I can count with you guys as, like I have said before, I am clueless to what to do next.

Going to work now.

Kind regards,
A very nice day to you all nice people.
Albert, C

Yes getting into IT here in the UK is very hard. I’ve been trying for years and unless you’ve got multiple bits of paper that say qualified no-one wants to know. I’ve seen support desk jobs advertised that want you to have a degree - for £12k!

Then you get people like my cousin… started for a small company putting networks together and got very lucky with 0 qualifications now working as a java programmer earning just under £50K. No idea how these people have such luck but I wish they’d give me some!

Hello everybody.

Here I am again.

I am ready to crack on this sql thing so that I can the query ID feature on each message sent as a result of subimiting the form.

I have already been on google and youtube and haven’t come anything accross that will let me in the right direction.

Can anybody help me with this feature on my form please?

Cheers.
Albert, C