needing help for contact.php form
Moderator: General Moderators
needing help for contact.php form
hi this is the contact.php file it isnt working for me and the site link is http://www.lowerprice4u.co.uk/contactus.html
could you please help me for this..
<?php
$to = $_REQUEST['sendto'] ;
$from = $_REQUEST['Email'] ;
$name = $_REQUEST['Name'] ;
$headers = "From: $from";
$subject = "Web Contact Data";
$fields = array();
$fields{"Name"} = "Name";
$fields{"Company"} = "Company";
$fields{"Email"} = "Email";
$fields{"Phone"} = "Phone";
$fields{"list"} = "Mailing List";
$fields{"Message"} = "Message";
$fields{"esupplier"} = "Electricity Supplier :";
$fields{"electricityspend"} = "Annual Electricity Spend :";
$fields{"contracte"} = "Electricity cont. End Day :";
$fields{"gsupplier"} = "Gas Supplier";
$fields{"incontractE"} = "Still in Contract ?";
$fields{"datecontracte"} = "When will Expire Elec.cont ?";
$fields{"gasspend"} = "Annual Gas Spend ? ";
$fields{"datecontractg"} = "When will Expire Gas.cont ?";
$fields{"gasmeter"} = "Main Meter Point Reference no :";
$fields{"salutation"} = "Title :";
$fields{"jobtitle"} = "Jobtitle :";
$fields{"premisess"} = "How many premisess :";
$fields{"street"} = "Address :";
$fields{"city"} = "City :";
$fields{"state"} = "Country";
$fields{"zip"} = "Post Code :";
$fields{"gasmeter0"} = "Gas Meter 0 :";
$fields{"gasmeter1"} = "Gas Meter 0 :";
$fields{"gasmeter2"} = "Gas Meter 0 :";
$fields{"gasmeter3"} = "Gas Meter 0 :";
$fields{"gasmeter4"} = "Gas Meter 0 :";
$fields{"gasmeter5"} = "Gas Meter 0 :";
$fields{"gasmeter6"} = "Gas Meter 0 :";
$fields{"gasmeter7"} = "Gas Meter 0 :";
$fields{"gasmeter8"} = "Gas Meter 0 :";
$fields{"gasmeter9"} = "Gas Meter 0 :";
$fields{"gasmeter10"} = "Gas Meter 0 :";
$fields{"gasmeter11"} = "Gas Meter 0 :";
$fields{"gasmeter12"} = "Gas Meter 0 :";
$fields{"gasmeter13"} = "Gas Meter 0 :";
$fields{"gasmeter14"} = "Gas Meter 0 :";
$fields{"gasmeter15"} = "Gas Meter 0 :";
$fields{"gasmeter16"} = "Gas Meter 0 :";
$fields{"gasmeter17"} = "Gas Meter 0 :";
$fields{"gasmeter18"} = "Gas Meter 0 :";
$fields{"gasmeter19"} = "Gas Meter 0 :";
$fields{"Sup1"} = "Sup1";
$fields{"Sup2"} = "Sup2";
$fields{"Sup3"} = "Sup3";
$fields{"Sup4"} = "Sup4";
$fields{"Sup5"} = "Sup5";
$fields{"Sup6"} = "Sup6";
$fields{"Sup7"} = "Sup7";
$fields{"Sup1"} = "Sup1";
$fields{"Sup2"} = "Sup2";
$fields{"Sup3"} = "Sup3";
$fields{"Sup4"} = "Sup4";
$fields{"Sup5"} = "Sup5";
$fields{"Sup6"} = "Sup6";
$fields{"Sup7"} = "Sup7";
$fields{"Sup1"} = "Sup1";
$fields{"Sup2"} = "Sup2";
$fields{"Sup3"} = "Sup3";
$fields{"Sup4"} = "Sup4";
$fields{"Sup5"} = "Sup5";
$fields{"Sup6"} = "Sup6";
$fields{"Sup7"} = "Sup7";
$fields{"Sup1"} = "Sup1";
$fields{"Sup2"} = "Sup2";
$fields{"Sup3"} = "Sup3";
$fields{"Sup4"} = "Sup4";
$fields{"Sup5"} = "Sup5";
$fields{"Sup6"} = "Sup6";
$fields{"Sup7"} = "Sup7";
$fields{"Sup1"} = "Sup1";
$fields{"Sup2"} = "Sup2";
$fields{"Sup3"} = "Sup3";
$fields{"Sup4"} = "Sup4";
$fields{"Sup5"} = "Sup5";
$fields{"Sup6"} = "Sup6";
$fields{"Sup7"} = "Sup7";
$fields{"Sup1"} = "Sup1";
$fields{"Sup2"} = "Sup2";
$fields{"Sup3"} = "Sup3";
$fields{"Sup4"} = "Sup4";
$fields{"Sup5"} = "Sup5";
$fields{"Sup6"} = "Sup6";
$fields{"Sup7"} = "Sup7";
$fields{"Sup1"} = "Sup1";
$fields{"Sup2"} = "Sup2";
$fields{"Sup3"} = "Sup3";
$fields{"Sup4"} = "Sup4";
$fields{"Sup5"} = "Sup5";
$fields{"Sup6"} = "Sup6";
$fields{"Sup7"} = "Sup7";
$fields{"Sup1"} = "Sup1";
$fields{"Sup2"} = "Sup2";
$fields{"Sup3"} = "Sup3";
$fields{"Sup4"} = "Sup4";
$fields{"Sup5"} = "Sup5";
$fields{"Sup6"} = "Sup6";
$fields{"Sup7"} = "Sup7";
$fields{"Sup1"} = "Sup1";
$fields{"Sup2"} = "Sup2";
$fields{"Sup3"} = "Sup3";
$fields{"Sup4"} = "Sup4";
$fields{"Sup5"} = "Sup5";
$fields{"Sup6"} = "Sup6";
$fields{"Sup7"} = "Sup7";
$fields{"Sup1"} = "Sup1";
$fields{"Sup2"} = "Sup2";
$fields{"Sup3"} = "Sup3";
$fields{"Sup4"} = "Sup4";
$fields{"Sup5"} = "Sup5";
$fields{"Sup6"} = "Sup6";
$fields{"Sup7"} = "Sup7";
$fields{"Sup1"} = "Sup1";
$fields{"Sup2"} = "Sup2";
$fields{"Sup3"} = "Sup3";
$fields{"Sup4"} = "Sup4";
$fields{"Sup5"} = "Sup5";
$fields{"Sup6"} = "Sup6";
$fields{"Sup7"} = "Sup7";
$fields{"Sup1"} = "Sup1";
$fields{"Sup2"} = "Sup2";
$fields{"Sup3"} = "Sup3";
$fields{"Sup4"} = "Sup4";
$fields{"Sup5"} = "Sup5";
$fields{"Sup6"} = "Sup6";
$fields{"Sup7"} = "Sup7";
$fields{"Sup1"} = "Sup1";
$fields{"Sup2"} = "Sup2";
$fields{"Sup3"} = "Sup3";
$fields{"Sup4"} = "Sup4";
$fields{"Sup5"} = "Sup5";
$fields{"Sup6"} = "Sup6";
$fields{"Sup7"} = "Sup7";
$body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }
$headers2 = "From: diane@lowerprice4u.com";
$subject2 = "Thank you for contacting us";
$autoreply = "We appreciate your contact. Please don't reply to this e-mail. We will get back to you as soon as possible, usualy within 48 hours. In the meantime, please enjoy browsing our website at http://www.lowerprice4u.com";
if($from == '') {print "You have not entered an email, please go back and try again";}
else {
if($name == '') {print "You have not entered a name, please go back and try again";}
else {
$send = mail($to, $subject, $body, $headers);
$send2 = mail($from, $subject2, $autoreply, $headers2);
if($send)
{header( "Location: ../thankyou.html" );}
else
{print "We encountered an error sending your mail, please notify diane@lowerprice4u.com"; }
}
}
?>
could you please help me for this..
<?php
$to = $_REQUEST['sendto'] ;
$from = $_REQUEST['Email'] ;
$name = $_REQUEST['Name'] ;
$headers = "From: $from";
$subject = "Web Contact Data";
$fields = array();
$fields{"Name"} = "Name";
$fields{"Company"} = "Company";
$fields{"Email"} = "Email";
$fields{"Phone"} = "Phone";
$fields{"list"} = "Mailing List";
$fields{"Message"} = "Message";
$fields{"esupplier"} = "Electricity Supplier :";
$fields{"electricityspend"} = "Annual Electricity Spend :";
$fields{"contracte"} = "Electricity cont. End Day :";
$fields{"gsupplier"} = "Gas Supplier";
$fields{"incontractE"} = "Still in Contract ?";
$fields{"datecontracte"} = "When will Expire Elec.cont ?";
$fields{"gasspend"} = "Annual Gas Spend ? ";
$fields{"datecontractg"} = "When will Expire Gas.cont ?";
$fields{"gasmeter"} = "Main Meter Point Reference no :";
$fields{"salutation"} = "Title :";
$fields{"jobtitle"} = "Jobtitle :";
$fields{"premisess"} = "How many premisess :";
$fields{"street"} = "Address :";
$fields{"city"} = "City :";
$fields{"state"} = "Country";
$fields{"zip"} = "Post Code :";
$fields{"gasmeter0"} = "Gas Meter 0 :";
$fields{"gasmeter1"} = "Gas Meter 0 :";
$fields{"gasmeter2"} = "Gas Meter 0 :";
$fields{"gasmeter3"} = "Gas Meter 0 :";
$fields{"gasmeter4"} = "Gas Meter 0 :";
$fields{"gasmeter5"} = "Gas Meter 0 :";
$fields{"gasmeter6"} = "Gas Meter 0 :";
$fields{"gasmeter7"} = "Gas Meter 0 :";
$fields{"gasmeter8"} = "Gas Meter 0 :";
$fields{"gasmeter9"} = "Gas Meter 0 :";
$fields{"gasmeter10"} = "Gas Meter 0 :";
$fields{"gasmeter11"} = "Gas Meter 0 :";
$fields{"gasmeter12"} = "Gas Meter 0 :";
$fields{"gasmeter13"} = "Gas Meter 0 :";
$fields{"gasmeter14"} = "Gas Meter 0 :";
$fields{"gasmeter15"} = "Gas Meter 0 :";
$fields{"gasmeter16"} = "Gas Meter 0 :";
$fields{"gasmeter17"} = "Gas Meter 0 :";
$fields{"gasmeter18"} = "Gas Meter 0 :";
$fields{"gasmeter19"} = "Gas Meter 0 :";
$fields{"Sup1"} = "Sup1";
$fields{"Sup2"} = "Sup2";
$fields{"Sup3"} = "Sup3";
$fields{"Sup4"} = "Sup4";
$fields{"Sup5"} = "Sup5";
$fields{"Sup6"} = "Sup6";
$fields{"Sup7"} = "Sup7";
$fields{"Sup1"} = "Sup1";
$fields{"Sup2"} = "Sup2";
$fields{"Sup3"} = "Sup3";
$fields{"Sup4"} = "Sup4";
$fields{"Sup5"} = "Sup5";
$fields{"Sup6"} = "Sup6";
$fields{"Sup7"} = "Sup7";
$fields{"Sup1"} = "Sup1";
$fields{"Sup2"} = "Sup2";
$fields{"Sup3"} = "Sup3";
$fields{"Sup4"} = "Sup4";
$fields{"Sup5"} = "Sup5";
$fields{"Sup6"} = "Sup6";
$fields{"Sup7"} = "Sup7";
$fields{"Sup1"} = "Sup1";
$fields{"Sup2"} = "Sup2";
$fields{"Sup3"} = "Sup3";
$fields{"Sup4"} = "Sup4";
$fields{"Sup5"} = "Sup5";
$fields{"Sup6"} = "Sup6";
$fields{"Sup7"} = "Sup7";
$fields{"Sup1"} = "Sup1";
$fields{"Sup2"} = "Sup2";
$fields{"Sup3"} = "Sup3";
$fields{"Sup4"} = "Sup4";
$fields{"Sup5"} = "Sup5";
$fields{"Sup6"} = "Sup6";
$fields{"Sup7"} = "Sup7";
$fields{"Sup1"} = "Sup1";
$fields{"Sup2"} = "Sup2";
$fields{"Sup3"} = "Sup3";
$fields{"Sup4"} = "Sup4";
$fields{"Sup5"} = "Sup5";
$fields{"Sup6"} = "Sup6";
$fields{"Sup7"} = "Sup7";
$fields{"Sup1"} = "Sup1";
$fields{"Sup2"} = "Sup2";
$fields{"Sup3"} = "Sup3";
$fields{"Sup4"} = "Sup4";
$fields{"Sup5"} = "Sup5";
$fields{"Sup6"} = "Sup6";
$fields{"Sup7"} = "Sup7";
$fields{"Sup1"} = "Sup1";
$fields{"Sup2"} = "Sup2";
$fields{"Sup3"} = "Sup3";
$fields{"Sup4"} = "Sup4";
$fields{"Sup5"} = "Sup5";
$fields{"Sup6"} = "Sup6";
$fields{"Sup7"} = "Sup7";
$fields{"Sup1"} = "Sup1";
$fields{"Sup2"} = "Sup2";
$fields{"Sup3"} = "Sup3";
$fields{"Sup4"} = "Sup4";
$fields{"Sup5"} = "Sup5";
$fields{"Sup6"} = "Sup6";
$fields{"Sup7"} = "Sup7";
$fields{"Sup1"} = "Sup1";
$fields{"Sup2"} = "Sup2";
$fields{"Sup3"} = "Sup3";
$fields{"Sup4"} = "Sup4";
$fields{"Sup5"} = "Sup5";
$fields{"Sup6"} = "Sup6";
$fields{"Sup7"} = "Sup7";
$fields{"Sup1"} = "Sup1";
$fields{"Sup2"} = "Sup2";
$fields{"Sup3"} = "Sup3";
$fields{"Sup4"} = "Sup4";
$fields{"Sup5"} = "Sup5";
$fields{"Sup6"} = "Sup6";
$fields{"Sup7"} = "Sup7";
$fields{"Sup1"} = "Sup1";
$fields{"Sup2"} = "Sup2";
$fields{"Sup3"} = "Sup3";
$fields{"Sup4"} = "Sup4";
$fields{"Sup5"} = "Sup5";
$fields{"Sup6"} = "Sup6";
$fields{"Sup7"} = "Sup7";
$fields{"Sup1"} = "Sup1";
$fields{"Sup2"} = "Sup2";
$fields{"Sup3"} = "Sup3";
$fields{"Sup4"} = "Sup4";
$fields{"Sup5"} = "Sup5";
$fields{"Sup6"} = "Sup6";
$fields{"Sup7"} = "Sup7";
$body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }
$headers2 = "From: diane@lowerprice4u.com";
$subject2 = "Thank you for contacting us";
$autoreply = "We appreciate your contact. Please don't reply to this e-mail. We will get back to you as soon as possible, usualy within 48 hours. In the meantime, please enjoy browsing our website at http://www.lowerprice4u.com";
if($from == '') {print "You have not entered an email, please go back and try again";}
else {
if($name == '') {print "You have not entered a name, please go back and try again";}
else {
$send = mail($to, $subject, $body, $headers);
$send2 = mail($from, $subject2, $autoreply, $headers2);
if($send)
{header( "Location: ../thankyou.html" );}
else
{print "We encountered an error sending your mail, please notify diane@lowerprice4u.com"; }
}
}
?>
Re: needing help for contact.php form
First, you've not actually told us what the problem is. Are we meant to guess?
Second, noone is going to fill in that form. It's far too confusing: there are too many fields, there's nothing helping the user to work out what is needed and what is optional, and it's very messy. Break it up over a number of pages, tidy up the layout, and put in lots of text to help the user understand what each field means.
Second, noone is going to fill in that form. It's far too confusing: there are too many fields, there's nothing helping the user to work out what is needed and what is optional, and it's very messy. Break it up over a number of pages, tidy up the layout, and put in lots of text to help the user understand what each field means.
- jayshields
- DevNet Resident
- Posts: 1912
- Joined: Mon Aug 22, 2005 12:11 pm
- Location: Leeds/Manchester, England
Re: needing help for contact.php form
I haven't fully understood your whole post, but from what I can gather, there are a number of fundamental errors. First off, array indexes need to be in square brackets [] not curly ones {}. Also, you're reassigning alot of variables many times which is completely unnecessary.
Re: needing help for contact.php form
Sorry , Thank you for your replies, I do appreciate your effort and time to help me.
My problem is this form isnt sending me the email when they click to submit button after completing it.
I dont have full understanding with coding but I will be very appreciative of your help. My friend is an IT engineer but he hasn't trained on coding. But he's confident of sorting this out with some help.
We will make it as seperate Gas and Electricity forms. But it would help us greatly if we could understand why it isnt working. I'm so glad of the advice about splitting the form up to several pages, I recently filled in a car insurance application, and I can see where you're coming from. It will definately be better that way. If you were willing to speak to us either by phone or skype it would be good, if you are pse let me have your info.
Once again, thank you very much
Diane Pardoe
My problem is this form isnt sending me the email when they click to submit button after completing it.
I dont have full understanding with coding but I will be very appreciative of your help. My friend is an IT engineer but he hasn't trained on coding. But he's confident of sorting this out with some help.
We will make it as seperate Gas and Electricity forms. But it would help us greatly if we could understand why it isnt working. I'm so glad of the advice about splitting the form up to several pages, I recently filled in a car insurance application, and I can see where you're coming from. It will definately be better that way. If you were willing to speak to us either by phone or skype it would be good, if you are pse let me have your info.
Once again, thank you very much
Diane Pardoe
Re: needing help for contact.php form
Smaller version. Please let me know if this is ok. still not working.
<?php
$to = $_REQUEST['sendto'] ;
$from = $_REQUEST['Email'] ;
$name = $_REQUEST['Name'] ;
$headers = "From: $from";
$subject = "Web Contact Data";
$fields = array [];
$fields{"Name"} = "Name";
$fields{"Company"} = "Company";
$fields{"Email"} = "Email";
$fields{"Phone"} = "Phone";
$fields{"list"} = "Mailing List";
$fields{"Message"} = "Message";
$fields{"esupplier"} = "Electricity Supplier :";
$fields{"electricityspend"} = "Annual Electricity Spend :";
$fields{"contracte"} = "Electricity cont. End Day :";
$fields{"gsupplier"} = "Gas Supplier";
$fields{"incontractE"} = "Still in Contract ?";
$fields{"datecontracte"} = "When will Expire Elec.cont ?";
$fields{"gasspend"} = "Annual Gas Spend ? ";
$fields{"datecontractg"} = "When will Expire Gas.cont ?";
$fields{"gasmeter"} = "Main Meter Point Reference no :";
$fields{"salutation"} = "Title :";
$fields{"jobtitle"} = "Jobtitle :";
$fields{"premisess"} = "How many premisess :";
$fields{"street"} = "Address :";
$fields{"city"} = "City :";
$fields{"state"} = "Country";
$fields{"zip"} = "Post Code :";
$body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }
$headers2 = "From: diane@lowerprice4u.com";
$subject2 = "Thank you for contacting us";
$autoreply = "We appreciate your contact. Please don't reply to this e-mail. We will get back to you as soon as possible, usualy within 48 hours. In the meantime, please enjoy browsing our website at http://www.lowerprice4u.com";
if($from == '') {print "You have not entered an email, please go back and try again";}
else {
if($name == '') {print "You have not entered a name, please go back and try again";}
else {
$send = mail($to, $subject, $body, $headers);
$send2 = mail($from, $subject2, $autoreply, $headers2);
if($send)
{header( "Location: ../thankyou.html" );}
else
{print "We encountered an error sending your mail, please notify diane@lowerprice4u.com"; }
}
}
?>
<?php
$to = $_REQUEST['sendto'] ;
$from = $_REQUEST['Email'] ;
$name = $_REQUEST['Name'] ;
$headers = "From: $from";
$subject = "Web Contact Data";
$fields = array [];
$fields{"Name"} = "Name";
$fields{"Company"} = "Company";
$fields{"Email"} = "Email";
$fields{"Phone"} = "Phone";
$fields{"list"} = "Mailing List";
$fields{"Message"} = "Message";
$fields{"esupplier"} = "Electricity Supplier :";
$fields{"electricityspend"} = "Annual Electricity Spend :";
$fields{"contracte"} = "Electricity cont. End Day :";
$fields{"gsupplier"} = "Gas Supplier";
$fields{"incontractE"} = "Still in Contract ?";
$fields{"datecontracte"} = "When will Expire Elec.cont ?";
$fields{"gasspend"} = "Annual Gas Spend ? ";
$fields{"datecontractg"} = "When will Expire Gas.cont ?";
$fields{"gasmeter"} = "Main Meter Point Reference no :";
$fields{"salutation"} = "Title :";
$fields{"jobtitle"} = "Jobtitle :";
$fields{"premisess"} = "How many premisess :";
$fields{"street"} = "Address :";
$fields{"city"} = "City :";
$fields{"state"} = "Country";
$fields{"zip"} = "Post Code :";
$body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }
$headers2 = "From: diane@lowerprice4u.com";
$subject2 = "Thank you for contacting us";
$autoreply = "We appreciate your contact. Please don't reply to this e-mail. We will get back to you as soon as possible, usualy within 48 hours. In the meantime, please enjoy browsing our website at http://www.lowerprice4u.com";
if($from == '') {print "You have not entered an email, please go back and try again";}
else {
if($name == '') {print "You have not entered a name, please go back and try again";}
else {
$send = mail($to, $subject, $body, $headers);
$send2 = mail($from, $subject2, $autoreply, $headers2);
if($send)
{header( "Location: ../thankyou.html" );}
else
{print "We encountered an error sending your mail, please notify diane@lowerprice4u.com"; }
}
}
?>
Re: needing help for contact.php form
It's very difficult to offer an helpful advice if all you say is "still not working". You wouldn't take your car in for a service when there's something wrong with it and just tell the mechanic "it's not working", would you?bilginxx wrote:still not working.
What happens when you run the script?
Do you get any error messages? If so, what are they?
Is there anything in the web server error log?
Also, the script you posted there still has the curly brackets problem that jayshields pointed out. $fields{"Name"} = "Name"; should be $fields["Name"] = "Name"; otherwise it's not a valid array entry.
- jayshields
- DevNet Resident
- Posts: 1912
- Joined: Mon Aug 22, 2005 12:11 pm
- Location: Leeds/Manchester, England
Re: needing help for contact.php form
Also you need to define $fields as an array like thisinstead of what you're currently doing.
You'd be better off constructing a very basic contact form and building up from it, it will be less confusing.
Like onion2k said, if you want our help, post some specific errors, these will be more verbose (or visible) if you put this line at the top of your script
Code: Select all
$fields = array();You'd be better off constructing a very basic contact form and building up from it, it will be less confusing.
Like onion2k said, if you want our help, post some specific errors, these will be more verbose (or visible) if you put this line at the top of your script
Code: Select all
error_reporting(E_ALL);Re: needing help for contact.php form
hi
i just add and change it
and this is coming up
What would it be ?
Thank you very much
We encountered an error sending your mail, please notify diane@lowerprice4u.com
i just add and change it
and this is coming up
What would it be ?
Thank you very much
We encountered an error sending your mail, please notify diane@lowerprice4u.com
Re: needing help for contact.php form
That mail script is exploitable, and if you leave it like that, it will almost certainly be used to send spam until your host notices something is wrong and terminates you or the script.
To begin with, hardcode the recipient address in php. There is absolutely no reason to have the user submit it as part of the form. Thus:
becomes
Then check all the user inputted headers for newlines, and reject if found.
I'm not an expert on mail() security, having not used it myself, so make sure to Google and find out more.
To begin with, hardcode the recipient address in php. There is absolutely no reason to have the user submit it as part of the form. Thus:
Code: Select all
$to = $_REQUEST['sendto'] ;Code: Select all
$to = 'whatever@lolwut.com';Code: Select all
if (strstr($whatever, "\n") || strstr($whatever, "\r")) {
exit("<span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span> off");
}Re: needing help for contact.php form
hi
after i contact hosting service they opened the error monitor for me and this is coming up error .
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in contact.php on line 217
what would be the reason ?
<?php
error_reporting(E_ALL);
$to = $_REQUEST['sendto'] ;
$from = $_REQUEST['Email'] ;
$name = $_REQUEST['Name'] ;
$headers = "From: $from";
$subject = "Web Contact Data";
$fields = array();
$fields{"Company"} = "Company";
$fields{"sendto"} = "Department";
$fields{"jobtitle"} = "Jobtitle ";
$fields{"salutation"} = "Title ";
$fields{"Name"} = "Name";
$fields{"Email"} = "Email";
$fields{"Phone"} = "Phone ";
$fields{"city"} = "City ";
$fields{"state"} = "Country ";
$fields{"street"} = "Address";
$fields{"zip"} = "Post Code ";
$fields{"tprovider"} = "Current Telecom Provider";
$fields{"tspend"} = "Annual Telecom Spend";
$fields{"tlineno"} = "How many Telecom Lines";
$fields{"iprovider"} = "Current Internet Provider";
$fields{"cusers"} = "Number of Computer or Users";
$fields{"icost"} = "Current Internet Monthly Cost";
$fields{"icontract"} = "Broadband Contract End date";
$fields{"premisess"} = "How many premises";
$fields{"."} = ". ";
$fields{"esupplier"} = "Electricity Supplier ";
$fields{"electricityspend"} = "Annual Electricity Spend ";
$fields{"incontractE"} = "Still in Contract ?";
$fields{"datecontracte"} = "When will Elec.cont Expire ?";
$fields{"."} = ". ";
$fields{"gsupplier"} = "Gas Supplier";
$fields{"gasspend"} = "Annual Gas Spend ?";
$fields{"datecontractg"} = "Still in Contract ?";
$fields{"datecontractg"} = "When will Gas.cont Expire ?";
$fields{"gasmeter"} = "Main Meter Point Reference no ";
$fields{"."} = ". ";
$fields{"Message"} = "Message ";
$fields{"."} = ". ";
$fields{"gasmeter0"} = "Gas Meter 0 : ";
$fields{"gasmeter1"} = "Gas Meter 1 : ";
$fields{"gasmeter2"} = "Gas Meter 2 : ";
$fields{"gasmeter3"} = "Gas Meter 3 : ";
$fields{"gasmeter4"} = "Gas Meter 4 : ";
$fields{"gasmeter5"} = "Gas Meter 5 : ";
$fields{"gasmeter6"} = "Gas Meter 6 : ";
$fields{"gasmeter7"} = "Gas Meter 7 : ";
$fields{"gasmeter8"} = "Gas Meter 8 : ";
$fields{"gasmeter9"} = "Gas Meter 9 : ";
$fields{"gasmeter10"} = "Gas Meter 10 : ";
$fields{"gasmeter11"} = "Gas Meter 11 : ";
$fields{"gasmeter12"} = "Gas Meter 12 : ";
$fields{"gasmeter13"} = "Gas Meter 13 : ";
$fields{"gasmeter14"} = "Gas Meter 14 : ";
$fields{"gasmeter15"} = "Gas Meter 15 : ";
$fields{"gasmeter16"} = "Gas Meter 16 : ";
$fields{"gasmeter17"} = "Gas Meter 17 : ";
$fields{"gasmeter18"} = "Gas Meter 18 : ";
$fields{"gasmeter19"} = "Gas Meter 19 : ";
$fields{"Sup1"} = "Meter-1Sup1 ";
$fields{"Sup2"} = "Sup2 ";
$fields{"Sup3"} = "Sup3 ";
$fields{"Sup4"} = "Sup4 ";
$fields{"Sup5"} = "Sup5 ";
$fields{"Sup6"} = "Sup6 ";
$fields{"Sup7"} = "Meter-1Sup7 ";
$fields{"Sup8"} = "Meter-2Sup1 ";
$fields{"Sup9"} = "Sup2 ";
$fields{"Sup10"} = "Sup3 ";
$fields{"Sup11"} = "Sup4 ";
$fields{"Sup12"} = "Sup5 ";
$fields{"Sup13"} = "Sup6 ";
$fields{"Sup14"} = "Meter-2Sup7 ";
$fields{"Sup15"} = "Sup1 ";
$fields{"Sup16"} = "Sup2 ";
$fields{"Sup17"} = "Sup3 ";
$fields{"Sup18"} = "Sup4 ";
$fields{"Sup19"} = "Sup5 ";
$fields{"Sup20"} = "Sup6 ";
$fields{"Sup21"} = "Sup7 ";
$fields{"Sup22"} = "Sup1 ";
$fields{"Sup23"} = "Sup2 ";
$fields{"Sup24"} = "Sup3 ";
$fields{"Sup25"} = "Sup4 ";
$fields{"Sup26"} = "Sup5 ";
$fields{"Sup27"} = "Sup6 ";
$fields{"Sup28"} = "Sup7 ";
$fields{"Sup29"} = "Sup1 ";
$fields{"Sup30"} = "Sup2 ";
$fields{"Sup31"} = "Sup3 ";
$fields{"Sup32"} = "Sup4 ";
$fields{"Sup33"} = "Sup5 ";
$fields{"Sup34"} = "Sup6 ";
$fields{"Sup35"} = "Sup7 ";
$fields{"Sup36"} = "Sup1 ";
$fields{"Sup37"} = "Sup2 ";
$fields{"Sup38"} = "Sup3 ";
$fields{"Sup39"} = "Sup4 ";
$fields{"Sup40"} = "Sup5 ";
$fields{"Sup41"} = "Sup6 ";
$fields{"Sup42"} = "Sup7 ";
$fields{"Sup43"} = "Sup1 ";
$fields{"Sup44"} = "Sup2 ";
$fields{"Sup45"} = "Sup3 ";
$fields{"Sup46"} = "Sup4 ";
$fields{"Sup47"} = "Sup5 ";
$fields{"Sup48"} = "Sup6 ";
$fields{"Sup49"} = "Sup7 ";
$fields{"Sup50"} = "Sup1 ";
$fields{"Sup51"} = "Sup2 ";
$fields{"Sup52"} = "Sup3 ";
$fields{"Sup53"} = "Sup4 ";
$fields{"Sup54"} = "Sup5 ";
$fields{"Sup55"} = "Sup6 ";
$fields{"Sup56"} = "Sup7 ";
$fields{"Sup57"} = "Sup1 ";
$fields{"Sup58"} = "Sup2 ";
$fields{"Sup59"} = "Sup3 ";
$fields{"Sup60"} = "Sup4 ";
$fields{"Sup61"} = "Sup5 ";
$fields{"Sup62"} = "Sup6 ";
$fields{"Sup63"} = "Sup7 ";
$fields{"Sup64"} = "Sup1 ";
$fields{"Sup65"} = "Sup2 ";
$fields{"Sup66"} = "Sup3 ";
$fields{"Sup67"} = "Sup4 ";
$fields{"Sup68"} = "Sup5 ";
$fields{"Sup69"} = "Sup6 ";
$fields{"Sup70"} = "Sup7 ";
$fields{"Sup71"} = "Sup1 ";
$fields{"Sup72"} = "Sup2 ";
$fields{"Sup73"} = "Sup3 ";
$fields{"Sup74"} = "Sup4 ";
$fields{"Sup75"} = "Sup5 ";
$fields{"Sup76"} = "Sup6 ";
$fields{"Sup77"} = "Sup7 ";
$fields{"Sup78"} = "Sup1 ";
$fields{"Sup79"} = "Sup2 ";
$fields{"Sup80"} = "Sup3 ";
$fields{"Sup81"} = "Sup4 ";
$fields{"Sup82"} = "Sup5 ";
$fields{"Sup83"} = "Sup6 ";
$fields{"Sup84"} = "Sup7 ";
$fields{"Sup85"} = "Sup1 ";
$fields{"Sup86"} = "Sup2 ";
$fields{"Sup87"} = "Sup3 ";
$fields{"Sup88"} = "Sup4 ";
$fields{"Sup89"} = "Sup5 ";
$fields{"Sup90"} = "Sup6 ";
$fields{"Sup91"} = "Sup7 ";
$fields{"Sup92"} = "Sup1 ";
$fields{"Sup93"} = "Sup2 ";
$fields{"Sup94"} = "Sup3 ";
$fields{"Sup95"} = "Sup4 ";
$fields{"Sup96"} = "Sup5 ";
$fields{"Sup97"} = "Sup6 ";
$fields{"Sup98"} = "Sup7 ";
$fields{"Sup99"} = "Sup1 ";
$fields{"Sup100"} = "Sup2 ";
$fields{"Sup101"} = "Sup3 ";
$fields{"Sup102"} = "Sup4 ";
$fields{"Sup103"} = "Sup5 ";
$fields{"Sup104"} = "Sup6 ";
$fields{"Sup105"} = "Sup7 ";
$fields{"Sup106"} = "Sup1 ";
$fields{"Sup107"} = "Sup2 ";
$fields{"Sup108"} = "Sup3 ";
$fields{"Sup109"} = "Sup4 ";
$fields{"Sup110"} = "Sup5 ";
$fields{"Sup111"} = "Sup6 ";
$fields{"Sup112"} = "Sup7 ";
$fields{"Sup113"} = "Sup1 ";
$fields{"Sup114"} = "Sup2 ";
$fields{"Sup115"} = "Sup3 ";
$fields{"Sup116"} = "Sup4 ";
$fields{"Sup117"} = "Sup5 ";
$fields{"Sup118"} = "Sup6 ";
$fields{"Sup119"} = "Sup7 ";
$fields{"Sup120"} = "Sup1 ";
$fields{"Sup121"} = "Sup2 ";
$fields{"Sup122"} = "Sup3 ";
$fields{"Sup123"} = "Sup4 ";
$fields{"Sup124"} = "Sup5 ";
$fields{"Sup125"} = "Sup6 ";
$fields{"Sup126"} = "Sup7 ";
$fields{"Sup127"} = "Sup1 ";
$fields{"Sup128"} = "Sup2 ";
$fields{"Sup129"} = "Sup3 ";
$fields{"Sup130"} = "Sup4 ";
$fields{"Sup131"} = "Sup5 ";
$fields{"Sup132"} = "Sup6 ";
$fields{"Sup133"} = "Sup7 ";
$fields{"Sup134"} = "Sup1 ";
$fields{"Sup135"} = "Sup2 ";
$fields{"Sup136"} = "Sup3 ";
$fields{"Sup137"} = "Sup4 ";
$fields{"Sup138"} = "Sup5 ";
$fields{"Sup139"} = "Sup6 ";
$fields{"Sup140"} = "Sup7 ";
$body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]);}
$headers2 = "From: diane@lowerprice4u.com ";
$subject2 = "Thank you for contacting us ";
$autoreply = "We appreciate your contact. Please don't reply to this e-mail. We will get back to you as soon as possible, usualy within 48 hours. In the meantime, please enjoy browsing our website at http://www.lowerprice4u.com";
if($from == 'diane@lowerprice4u.com'') {print "You have not entered an email, please go back and try again ";}
else {
{
if($Name == '')
{
print "You have not entered a name, please go back and try again";
}
else
{
$send = mail($to,$subject,$body,$headers,$array,'-fdiane@lowerprice4u.com');
$send2 = mail($from,$subject2,$autoreply,$headers2);
if($send)
{header( "Location: ../thankyou.html" );}
else
{print "We encountered an error sending your mail, please notify diane@lowerprice4u.com "; }
}
}
?>
after i contact hosting service they opened the error monitor for me and this is coming up error .
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in contact.php on line 217
what would be the reason ?
<?php
error_reporting(E_ALL);
$to = $_REQUEST['sendto'] ;
$from = $_REQUEST['Email'] ;
$name = $_REQUEST['Name'] ;
$headers = "From: $from";
$subject = "Web Contact Data";
$fields = array();
$fields{"Company"} = "Company";
$fields{"sendto"} = "Department";
$fields{"jobtitle"} = "Jobtitle ";
$fields{"salutation"} = "Title ";
$fields{"Name"} = "Name";
$fields{"Email"} = "Email";
$fields{"Phone"} = "Phone ";
$fields{"city"} = "City ";
$fields{"state"} = "Country ";
$fields{"street"} = "Address";
$fields{"zip"} = "Post Code ";
$fields{"tprovider"} = "Current Telecom Provider";
$fields{"tspend"} = "Annual Telecom Spend";
$fields{"tlineno"} = "How many Telecom Lines";
$fields{"iprovider"} = "Current Internet Provider";
$fields{"cusers"} = "Number of Computer or Users";
$fields{"icost"} = "Current Internet Monthly Cost";
$fields{"icontract"} = "Broadband Contract End date";
$fields{"premisess"} = "How many premises";
$fields{"."} = ". ";
$fields{"esupplier"} = "Electricity Supplier ";
$fields{"electricityspend"} = "Annual Electricity Spend ";
$fields{"incontractE"} = "Still in Contract ?";
$fields{"datecontracte"} = "When will Elec.cont Expire ?";
$fields{"."} = ". ";
$fields{"gsupplier"} = "Gas Supplier";
$fields{"gasspend"} = "Annual Gas Spend ?";
$fields{"datecontractg"} = "Still in Contract ?";
$fields{"datecontractg"} = "When will Gas.cont Expire ?";
$fields{"gasmeter"} = "Main Meter Point Reference no ";
$fields{"."} = ". ";
$fields{"Message"} = "Message ";
$fields{"."} = ". ";
$fields{"gasmeter0"} = "Gas Meter 0 : ";
$fields{"gasmeter1"} = "Gas Meter 1 : ";
$fields{"gasmeter2"} = "Gas Meter 2 : ";
$fields{"gasmeter3"} = "Gas Meter 3 : ";
$fields{"gasmeter4"} = "Gas Meter 4 : ";
$fields{"gasmeter5"} = "Gas Meter 5 : ";
$fields{"gasmeter6"} = "Gas Meter 6 : ";
$fields{"gasmeter7"} = "Gas Meter 7 : ";
$fields{"gasmeter8"} = "Gas Meter 8 : ";
$fields{"gasmeter9"} = "Gas Meter 9 : ";
$fields{"gasmeter10"} = "Gas Meter 10 : ";
$fields{"gasmeter11"} = "Gas Meter 11 : ";
$fields{"gasmeter12"} = "Gas Meter 12 : ";
$fields{"gasmeter13"} = "Gas Meter 13 : ";
$fields{"gasmeter14"} = "Gas Meter 14 : ";
$fields{"gasmeter15"} = "Gas Meter 15 : ";
$fields{"gasmeter16"} = "Gas Meter 16 : ";
$fields{"gasmeter17"} = "Gas Meter 17 : ";
$fields{"gasmeter18"} = "Gas Meter 18 : ";
$fields{"gasmeter19"} = "Gas Meter 19 : ";
$fields{"Sup1"} = "Meter-1Sup1 ";
$fields{"Sup2"} = "Sup2 ";
$fields{"Sup3"} = "Sup3 ";
$fields{"Sup4"} = "Sup4 ";
$fields{"Sup5"} = "Sup5 ";
$fields{"Sup6"} = "Sup6 ";
$fields{"Sup7"} = "Meter-1Sup7 ";
$fields{"Sup8"} = "Meter-2Sup1 ";
$fields{"Sup9"} = "Sup2 ";
$fields{"Sup10"} = "Sup3 ";
$fields{"Sup11"} = "Sup4 ";
$fields{"Sup12"} = "Sup5 ";
$fields{"Sup13"} = "Sup6 ";
$fields{"Sup14"} = "Meter-2Sup7 ";
$fields{"Sup15"} = "Sup1 ";
$fields{"Sup16"} = "Sup2 ";
$fields{"Sup17"} = "Sup3 ";
$fields{"Sup18"} = "Sup4 ";
$fields{"Sup19"} = "Sup5 ";
$fields{"Sup20"} = "Sup6 ";
$fields{"Sup21"} = "Sup7 ";
$fields{"Sup22"} = "Sup1 ";
$fields{"Sup23"} = "Sup2 ";
$fields{"Sup24"} = "Sup3 ";
$fields{"Sup25"} = "Sup4 ";
$fields{"Sup26"} = "Sup5 ";
$fields{"Sup27"} = "Sup6 ";
$fields{"Sup28"} = "Sup7 ";
$fields{"Sup29"} = "Sup1 ";
$fields{"Sup30"} = "Sup2 ";
$fields{"Sup31"} = "Sup3 ";
$fields{"Sup32"} = "Sup4 ";
$fields{"Sup33"} = "Sup5 ";
$fields{"Sup34"} = "Sup6 ";
$fields{"Sup35"} = "Sup7 ";
$fields{"Sup36"} = "Sup1 ";
$fields{"Sup37"} = "Sup2 ";
$fields{"Sup38"} = "Sup3 ";
$fields{"Sup39"} = "Sup4 ";
$fields{"Sup40"} = "Sup5 ";
$fields{"Sup41"} = "Sup6 ";
$fields{"Sup42"} = "Sup7 ";
$fields{"Sup43"} = "Sup1 ";
$fields{"Sup44"} = "Sup2 ";
$fields{"Sup45"} = "Sup3 ";
$fields{"Sup46"} = "Sup4 ";
$fields{"Sup47"} = "Sup5 ";
$fields{"Sup48"} = "Sup6 ";
$fields{"Sup49"} = "Sup7 ";
$fields{"Sup50"} = "Sup1 ";
$fields{"Sup51"} = "Sup2 ";
$fields{"Sup52"} = "Sup3 ";
$fields{"Sup53"} = "Sup4 ";
$fields{"Sup54"} = "Sup5 ";
$fields{"Sup55"} = "Sup6 ";
$fields{"Sup56"} = "Sup7 ";
$fields{"Sup57"} = "Sup1 ";
$fields{"Sup58"} = "Sup2 ";
$fields{"Sup59"} = "Sup3 ";
$fields{"Sup60"} = "Sup4 ";
$fields{"Sup61"} = "Sup5 ";
$fields{"Sup62"} = "Sup6 ";
$fields{"Sup63"} = "Sup7 ";
$fields{"Sup64"} = "Sup1 ";
$fields{"Sup65"} = "Sup2 ";
$fields{"Sup66"} = "Sup3 ";
$fields{"Sup67"} = "Sup4 ";
$fields{"Sup68"} = "Sup5 ";
$fields{"Sup69"} = "Sup6 ";
$fields{"Sup70"} = "Sup7 ";
$fields{"Sup71"} = "Sup1 ";
$fields{"Sup72"} = "Sup2 ";
$fields{"Sup73"} = "Sup3 ";
$fields{"Sup74"} = "Sup4 ";
$fields{"Sup75"} = "Sup5 ";
$fields{"Sup76"} = "Sup6 ";
$fields{"Sup77"} = "Sup7 ";
$fields{"Sup78"} = "Sup1 ";
$fields{"Sup79"} = "Sup2 ";
$fields{"Sup80"} = "Sup3 ";
$fields{"Sup81"} = "Sup4 ";
$fields{"Sup82"} = "Sup5 ";
$fields{"Sup83"} = "Sup6 ";
$fields{"Sup84"} = "Sup7 ";
$fields{"Sup85"} = "Sup1 ";
$fields{"Sup86"} = "Sup2 ";
$fields{"Sup87"} = "Sup3 ";
$fields{"Sup88"} = "Sup4 ";
$fields{"Sup89"} = "Sup5 ";
$fields{"Sup90"} = "Sup6 ";
$fields{"Sup91"} = "Sup7 ";
$fields{"Sup92"} = "Sup1 ";
$fields{"Sup93"} = "Sup2 ";
$fields{"Sup94"} = "Sup3 ";
$fields{"Sup95"} = "Sup4 ";
$fields{"Sup96"} = "Sup5 ";
$fields{"Sup97"} = "Sup6 ";
$fields{"Sup98"} = "Sup7 ";
$fields{"Sup99"} = "Sup1 ";
$fields{"Sup100"} = "Sup2 ";
$fields{"Sup101"} = "Sup3 ";
$fields{"Sup102"} = "Sup4 ";
$fields{"Sup103"} = "Sup5 ";
$fields{"Sup104"} = "Sup6 ";
$fields{"Sup105"} = "Sup7 ";
$fields{"Sup106"} = "Sup1 ";
$fields{"Sup107"} = "Sup2 ";
$fields{"Sup108"} = "Sup3 ";
$fields{"Sup109"} = "Sup4 ";
$fields{"Sup110"} = "Sup5 ";
$fields{"Sup111"} = "Sup6 ";
$fields{"Sup112"} = "Sup7 ";
$fields{"Sup113"} = "Sup1 ";
$fields{"Sup114"} = "Sup2 ";
$fields{"Sup115"} = "Sup3 ";
$fields{"Sup116"} = "Sup4 ";
$fields{"Sup117"} = "Sup5 ";
$fields{"Sup118"} = "Sup6 ";
$fields{"Sup119"} = "Sup7 ";
$fields{"Sup120"} = "Sup1 ";
$fields{"Sup121"} = "Sup2 ";
$fields{"Sup122"} = "Sup3 ";
$fields{"Sup123"} = "Sup4 ";
$fields{"Sup124"} = "Sup5 ";
$fields{"Sup125"} = "Sup6 ";
$fields{"Sup126"} = "Sup7 ";
$fields{"Sup127"} = "Sup1 ";
$fields{"Sup128"} = "Sup2 ";
$fields{"Sup129"} = "Sup3 ";
$fields{"Sup130"} = "Sup4 ";
$fields{"Sup131"} = "Sup5 ";
$fields{"Sup132"} = "Sup6 ";
$fields{"Sup133"} = "Sup7 ";
$fields{"Sup134"} = "Sup1 ";
$fields{"Sup135"} = "Sup2 ";
$fields{"Sup136"} = "Sup3 ";
$fields{"Sup137"} = "Sup4 ";
$fields{"Sup138"} = "Sup5 ";
$fields{"Sup139"} = "Sup6 ";
$fields{"Sup140"} = "Sup7 ";
$body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]);}
$headers2 = "From: diane@lowerprice4u.com ";
$subject2 = "Thank you for contacting us ";
$autoreply = "We appreciate your contact. Please don't reply to this e-mail. We will get back to you as soon as possible, usualy within 48 hours. In the meantime, please enjoy browsing our website at http://www.lowerprice4u.com";
if($from == 'diane@lowerprice4u.com'') {print "You have not entered an email, please go back and try again ";}
else {
{
if($Name == '')
{
print "You have not entered a name, please go back and try again";
}
else
{
$send = mail($to,$subject,$body,$headers,$array,'-fdiane@lowerprice4u.com');
$send2 = mail($from,$subject2,$autoreply,$headers2);
if($send)
{header( "Location: ../thankyou.html" );}
else
{print "We encountered an error sending your mail, please notify diane@lowerprice4u.com "; }
}
}
?>
- jayshields
- DevNet Resident
- Posts: 1912
- Joined: Mon Aug 22, 2005 12:11 pm
- Location: Leeds/Manchester, England
Re: needing help for contact.php form
jayshields wrote:array indexes need to be in square brackets [] not curly ones {}
Re: needing help for contact.php form
i changed the $fields = array[];
and this is coming up
Parse error: syntax error, unexpected '[', expecting '(' in contact.php on line 8
and this is coming up
Parse error: syntax error, unexpected '[', expecting '(' in contact.php on line 8
- jayshields
- DevNet Resident
- Posts: 1912
- Joined: Mon Aug 22, 2005 12:11 pm
- Location: Leeds/Manchester, England
Re: needing help for contact.php form
$fields is an array. Not an array index. To declare a variable to be of array type it needs to be:When referencing indexes of that array, for example, index 3, you would use this syntax:or if the index is a string, for example 'three', you would use this syntax
Code: Select all
$fields = array();Code: Select all
$fields[3];Code: Select all
$fields['three'];Re: needing help for contact.php form
i did and still same error message on same line
Re: needing help for contact.php form
You changed $fields = array[]; to $fields = array(); and it's still saying "Parse error: syntax error, unexpected '[', expecting '(' in contact.php on line 8"? No it isn't. That's not possible.