Page 2 of 2
Re: needing help for contact.php form
Posted: Mon Sep 08, 2008 3:11 pm
by bilginxx
is it possible that this php on hosting wont accept []
i don't know what to do
i search on google in different places and i can see they are not using [] ..
any advice
--
the links i found same script
http://forums.htmlhelp.com/lofiversion/ ... t3762.html
http://forums.htmlhelp.com/index.php?ac ... =16&t=3762
Re: needing help for contact.php form
Posted: Mon Sep 08, 2008 3:19 pm
by onion2k
bilginxx wrote:is it possible that this php on hosting wont accept []
No PHP install anywhere will accept "$fields = array[];" because array in that context is a function call. It has to be array(). You use () when you're calling the array function to define the array, and [] when you're setting a value in it once it's been defined.
bilginxx wrote:i search on google in different places and i can see they are not using [] ..
So what? Those people are getting it wrong. People in this thread have told you how to fix the problem. Change all the {} to [] and that bit of the code will work. There may be other problems that stop the script working but until these two points are correct I don't think there's any way to find the rest of the issues.
Re: needing help for contact.php form
Posted: Mon Sep 08, 2008 3:25 pm
by bilginxx
thank you very much for your time and advice
am i going to change $fields only ? or all script ?
Re: needing help for contact.php form
Posted: Mon Sep 08, 2008 3:59 pm
by bilginxx
http://codepad.org/tbedFtZy
this is the place i found checking code online
Re: needing help for contact.php form
Posted: Mon Sep 08, 2008 4:18 pm
by onion2k
Right. The array problem is fixed. Good.
The new problem is that something in your if..else block at the end isn't closed properly so the script gets to the end without closing an if statement. If we reformat the code a bit so it's nice and tidy the error is obvious:
Code: Select all
if($from == 'diane@lowerprice4u.com') {
print "You have not entered an email, please go back and try again ";
} else {
{ //This opening brace shouldn't be here.
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 ";
}
}
}
I've put a corrected version here:
http://codepad.org/iV1oJx9k
I think you've got an extra $ on line 215 as well.
And, as you'll see from the 'output' section on that website, there are a HUGE number of notices from that code. They won't stop it running but you should read them, and Google them to find out what they mean. Your code will improve if you do.