Contact form headache!

Hi all,

My first post here. I would be very thankful if you could help me with a recent problem of mine.

I have been asked to put together a website for my friend, as I used to dabble with a little HTML in my teens - I have been ‘out of it’ for 10 years and a lot has changed! so I am trying to play catch up as you can imagine.

One of my friend’s requests was for a contact form with a few, in my view, complicated components - like checkboxes and alternative questions than the usual ‘Name’ ‘Email’ ‘Contact number’ etc.

I have copied across the code I am using, I was wondering if any of you could highlight where I am going wrong. On a test run of the form, I am receiving the error: ‘Parse error: syntax error, unexpected ‘<’ in D:\Hosting\11889492\html\contact_nextstep\contact.php on line 15’

[code]

What would you like to achieve with your health and fitness?:
Out of the following, which are your top 3 concerns?:

 Weight    Tone    Shape    Mobility    Energy  
 Water retention    Fitness    Improve appearance  

When you look in the mirror, physically how do you view yourself?:
Does the way you view yourself, make you feel...:

 Content    Frustrated    Sad  

What potential problem(s) could get in the way of you achieving your goals?:
How does the way you look and feel hold you back in life?:
How would achieving this goal impact your life?:
Name:
Email:
Contact number:

Only click the Next Step button if you are ready to begin
your transformation and get the results you deserve.



[/code]

[php]<?php
$q1 = $_POST[‘q1’];
$q2 = $_POST[‘q2’];
$q3 = $_POST[‘q3’];
$q4 = $_POST[‘q4’];
$q5 = $_POST[‘q5’];
$q6 = $_POST[‘q6’];
$q7 = $_POST[‘q7’];
$name = $_POST[‘name’];
$email = $_POST[‘email’];
$contact = $_POST[‘contact’];
$formcontent=" From: $name \n Contact number: $contact \n What would you like to achieve with your health and fitness: $q1 \n Out of the following which are your top 3 concerns: $q2 \n When you look in the mirror physically how do you view yourself: $q3 \n Does the way you view yourself make you feel: $q4 \n What potential problems could get in the way of you achieving your goals: $q5 \n How does the way you look and feel hold you back in life: $q6 \n How would achieving this goal impact your life: $q7";
$recipient = "[email protected]";
$subject = “JP Budget Fitness website submission”;
$mailheader = “From: $email \r\n”;
mail($recipient, $subject, $formcontent, $mailheader) or die(“Error!”);
echo “Thank you!”;
?>[/php]

Also, I feel really cheeky asking for some reason but do any of you know how to redirect the user to my own thankyou.html and error.html pages? As again, that is another request from my friend that without your help, I doubt I would be able to achieve. Google has not been kind this time round!

Thank you in advance for your help. (if anyone helps that is…)

Pete

Line 13 (after the email) to line 17 is javascript, not PHP. What are you trying to do here?

I’m trying to put together a contact form for my friend’s website - which when the info is submitted is then emailed to him.

Google presented me with the original code which I have played around with.

Are you saying remove the JavaScript and it will be functional?

or are you just pointing out mistakes which I knew existed but couldn’t determine myself?

I just pointed out why you got an error. The php parser will throw lots of errors when you feed it javascript. Then I saw it was actually script tags and everything included in that variable holding the email address, so I was wondering what you were trying to accomplish there.

Changing this:
[php] $recipient = "[email protected]";[/php]

To this:
[php] $recipient = "[email protected]";[/php]

Should sort out the error you got. But not sure if there are any other errors.

Thank you!

I didn’t mean to sound tetchy or anything by the way, I am just a complete beginner when it comes to all this. (hence why I’m in the Beginners section)

I have removed the pesky JavaScript, it has presented a new error message:

’ Warning: mail() [function.mail]: SMTP server response: 451 See http://pobox.com/~djb/docs/smtplf.html. in D:\Hosting\11889492\html\contact_nextstep\contact.php on line 16
Error!’

I had a look at the URL it advised me to ‘See’ and I am at a loss.

I have a feeling I may have to start from scratch.

Can anyone direct me to some good tutorials on building contact forms? or advise where I am going wrong?

Thanks again.

No you are allright, no meed to start from scratch :slight_smile:

Try to google the error
Warning: mail() [function.mail]: SMTP server response: 451

as the error says its the mail function in your php script that has a problem

Sponsor our Newsletter | Privacy Policy | Terms of Service