Jump to content
xisto Community
Sign in to follow this  
wild20

Trouble With Form Script Please help

Recommended Posts

Hey I am setting up a form for my site, http://forums.xisto.com/no_longer_exists/ That is where the form is located. But guess what? It doesn't work. I used a free form generator. And it made me this code:

<?php// Website Contact Form Generator // http://forums.xisto.com/no_longer_exists/ // This script is free to use as long as you  // retain the credit link  // get posted data into local variables$EmailFrom = Trim(stripslashes($_POST['EmailFrom'])); $EmailTo = "contact@inneed.mxweb.co.uk";$Subject = "Contact form query";$Subject = Trim(stripslashes($_POST['Subject'])); $Name = Trim(stripslashes($_POST['Name'])); $Email = Trim(stripslashes($_POST['Email'])); $Problem/Query = Trim(stripslashes($_POST['Problem/Query'])); // validation$validationOK=true;if (Trim($EmailFrom)=="") $validationOK=false;if (!$validationOK) {  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";  exit;}// prepare email body text$Body = "";$Body .= "Subject: ";$Body .= $Subject;$Body .= "\n";$Body .= "Name: ";$Body .= $Name;$Body .= "\n";$Body .= "Email: ";$Body .= $Email;$Body .= "\n";$Body .= "Problem/Query: ";$Body .= $Problem/Query;$Body .= "\n";// send email $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");// redirect to success page if ($success){  print "<meta http-equiv=\"refresh\" content=\"0;URL=ok.htm\">";}else{  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";}?>

Anyway, so I did this, but it says that there is a parse error on line 14. Un unexpected '=' to be exact. Could someone please help me out and help me get this working? Thanks!

Share this post


Link to post
Share on other sites

I blame the forward slash. I dont think with such a thing as a variable is allowed. If removing it doesn't help, for each instance, then i'm not sure what to tell you.

Share this post


Link to post
Share on other sites

Yes, I would rename this variable to some thing like Problem_Query to avoid using the slash which is a special character in php and I don't think variables can contain them. If you rename it in this script, be sure to alter the form, too.

Share this post


Link to post
Share on other sites
:) It says it is a = sign actually. I mean, if that shows up after I find out what that is, then I will know to fix that as well, but something on line 14 right now. Could you help with out with that first? Thanks. Anyway, I don't know what would be causing that. Actualy, is that what the = sig coulod mean? I am so confused. Could you take one more look at the code? Thanks!

Share this post


Link to post
Share on other sites

The thing about parse errors is a funny thing. Just cause it says it deals with one thing doesnt mean that it is that thing. But that's not always the case. Did you change the slash, yet, wherever it occurs? Or do you still think it has something to do with an equal sign?

Share this post


Link to post
Share on other sites

I am pretty sure it is the equals sign. Also, it says line 14, and I have used lines before. They work great to pinpoint a location, but I don't know where to count down 14 on this script. It looks like I may need to skip some stuff. Anyway, I didn't try taking those out. I will try it though and get back to you tomorrow because I can't access it right now. In the meant time, maybe you oculd look and see if there is the equals sign that is causing the pronlem? I believe that is where it is.

Share this post


Link to post
Share on other sites

It would be easier to setup a forum by using a pre-installed script such as Fantastico or another script. Those should work. What did you use to create this script with? Their site/link should have what the script should look like, and you can compare it to yours.

Share this post


Link to post
Share on other sites

Also the best advice I could give is make the form yourself go to pixel2life.com they have tutorials on about almost everything for forms like security, mysql and php.So check them out, Cuz most of the time those form generator screw you over in terms of proper coding, the form actually being sent and all that.

Share this post


Link to post
Share on other sites

Line 14, would be this (if you counted down by what you gave us, if you start where the code start):

$Problem/Query = Trim(stripslashes($_POST['Problem/Query']));

And, if that's the case, it should be for certain, that the forward slash "/" is causing the problem. Because there are rules you need to follow when naming variables. And if it is the forward slash, you would also have to change line 36 - cause it has the same variable - to match the edited variable from line 14. Edited by truefusion (see edit history)

Share this post


Link to post
Share on other sites

It is the forward slash causing the problem. It's saying that it encountered an unexpected '=' symbol because it simply treating the slash as an operation of division - ie. divide the variable $Problem by the constant Query, which is perfectly legal in PHP (assuming, of course, the constant 'Query' has been defined). Because this is all perfectly ok, and PHP is assuming that you aren't trying to name the variable with a slash in it, it is unable to continue past the equals symbol as you obviously cannot assign a value to a dynamic equation, which is what it thinks '$Problem/Query' is.

 

Just remove the slash. Replace it with an underscore, or simply use '$ProblemQuery'. Then replace all instances of it within the script. This has already been mentioned in this thread...

Edited by Spectre (see edit history)

Share this post


Link to post
Share on other sites

Perfect! I juggled around a few other things, but it is now fixed. Thank you SO much. As you know, me and my bro, JC05, have been having problems with form scripts lately. And as you probably found out, we have more faith in the guys at Xisto than anything :) Hey thanks guys.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.