needing help for contact.php form

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

bilginxx
Forum Newbie
Posts: 10
Joined: Fri Sep 05, 2008 6:15 am

Re: needing help for contact.php form

Post 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
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: needing help for contact.php form

Post 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.
bilginxx
Forum Newbie
Posts: 10
Joined: Fri Sep 05, 2008 6:15 am

Re: needing help for contact.php form

Post by bilginxx »

thank you very much for your time and advice

am i going to change $fields only ? or all script ?
bilginxx
Forum Newbie
Posts: 10
Joined: Fri Sep 05, 2008 6:15 am

Re: needing help for contact.php form

Post by bilginxx »

http://codepad.org/tbedFtZy

this is the place i found checking code online
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: needing help for contact.php form

Post 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.
Post Reply