Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

phplease help!

Options
  • 19-01-2007 6:49pm
    #1
    Registered Users Posts: 304 ✭✭


    Ok, so I've created a contact form in php, and I have uploaded it, however, when I enter data into the contact form I get this error:

    Parse error: syntax error, unexpected T_VARIABLE in /misc/25/000/102/320/6/user/web/websitename/contact.php on line 10

    this is the code I have for the contact.php file

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body>
    <?
    $EmailFrom = Trim(stripslashes($_POST));
    $EmailTo = "eilyis@gmail.com";
    $Subject = "Information from Large Male1";
    $Name = Trim(stripslashes($_POST));


    $validationOK=true;
    if (Trim($EmailFrom)=="") $validationOK=false;
    if (Trim($Name)=="") $validationOK=false;
    if (!$validationOK) {
    print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
    exit;
    }


    $Body = "";
    $Body .= "Name: ";
    $Body .= $Name;
    $Body .= "\n";


    $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");


    if ($success){
    print "<meta http-equiv=\"refresh\" content=\"0;URL=thanku.htm\">";
    }
    else{
    print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
    }
    ?>

    </body>
    </html>

    Please go easy on me, I'm still learning, and having a bit of difficulty with this form thing at the moment.

    Also, this is the code for the form box - incase I have done something wrong there!

    <font face="Verdana, Arial, Helvetica, sans-serif">  </font>
    <form method="POST" action="contact.php">


    <p><font face="Verdana, Arial, Helvetica, sans-serif">Please Enter Your Number
    and Your Choice </font><br>
    <input type="text" name="Name">
    <p>
    <input type="submit" name="submit" value="Submit">
    </form>


    You guys have helped me soooo much with this, I am hoping this will be the last request for help!


Comments

  • Closed Accounts Posts: 8,866 ✭✭✭Adam


    Link?

    Can't see the problem...


  • Registered Users Posts: 304 ✭✭Smiley012


    http://edate.bravehost.com/smallfemale.htm

    ok its for a psychology experiment, so please ignore content, as it would be unethical for me to release details etc etc, but thats the form box at the bottom of the page, see I'm very much a novice at this, so I could have uploaded the wrong files, or named the files incorrectly,

    In my files, I have a contact.php, and then the initial file which is called smallfemale.htm, so I'm not sure where I have gone wrong with this? Maybe I have just labelled something incorrectly!


  • Registered Users Posts: 68,317 ✭✭✭✭seamus


    trim() should have a lowercase t

    :)


  • Closed Accounts Posts: 8,866 ✭✭✭Adam


    Strange, I tested the script and it didn't give me an error for that...


  • Registered Users Posts: 304 ✭✭Smiley012


    ok, did it give u an error at all? cos its still not working on the site for me? is it that I haven't uploaded the right files? or put the right link in for the next page?


  • Advertisement
  • Registered Users Posts: 32,136 ✭✭✭✭is_that_so


    Smiley012 wrote:
    ok, did it give u an error at all? cos its still not working on the site for me? is it that I haven't uploaded the right files? or put the right link in for the next page?

    It doesn't look like you have passed value for $EmailFrom. On the link you posted there is only a box for a number. That would explain the error on line 10. It is not empty , it is not even defined. Line 10 tests the value of EmailFrom.

    Put these line in contact.php after the braces <?

    print_r($_POST);
    exit;

    The output will tell you what details you have received from the form.


  • Registered Users Posts: 304 ✭✭Smiley012


    see I don't want an e-mail box on the website, I just want the one input box... I don't know what I need to delete from the code so that it just has one text box, is that possible? or does there have to be two?


  • Registered Users Posts: 32,136 ✭✭✭✭is_that_so


    Your file is expecting details that have been sent to it using the POST method which is what that code above does. It can tell you what has been passed.
    One of these things included in your code is Emailfrom.

    If you had the following form on your page you would get valeus from each.
    If you just want predefined values then change the type to type="hidden" as below and add a value.

    <form method="post" action="anotherfile.php">
    <input type="hidden" name="name" value="Me">
    <input type="hidden" name="email" value="emailaddress">
    <input type="hidden" name="phone" value="123">
    <input type="submit" name="submit" value="Submit">
    </form>


  • Registered Users Posts: 304 ✭✭Smiley012


    Ok I have decided to have two input boxes as will make life easier, but it still isn't working, i just keep being diverted to error.htm, but I cannot for the life of me see why,


    This is the code from the php document - should I have all the html tags there too?

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body>
    <?


    // get posted data into local variables
    $EmailFrom = Trim(stripslashes($_POST));
    $EmailTo = "eilyis@gmail.com";
    $Subject = "Information from my form";
    $Name = Trim(stripslashes($_POST));

    // validation
    $validationOK=true;
    if (Trim($ParticipantNumber)=="") $validationOK=false;
    if (Trim($Decision)=="") $validationOK=false;
    if (!$validationOK) {
    print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
    exit;
    }

    // prepare email body text
    $Body = "";
    $Body .= "Decision: ";
    $Body .= $Decision;
    $Body .= "\n";

    // send email
    $success = mail($EmailTo, $Subject, $Body, "From: <$ParticipantNumber>");

    // redirect to success page
    if ($success){
    print "<meta http-equiv=\"refresh\" content=\"0;URL=largefemale.htm\">";
    }
    else{
    print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
    }
    ?>
    </body>
    </html>



    This is the code for the form

    <form method="POST" action="contact.php">

    <p>Please enter your number here: <br>
    <input type="text" name="ParticipantNumber">
    <p>Please enter your decision here: <br>
    <input type="text" name="Decision">
    <p><input type="submit" name="submit" value="Submit">
    </form>
    <p>

    here is address again

    http://edate.bravehost.com/smallfemale.htm

    thanks for the replies so far, it means a lot!


  • Registered Users Posts: 304 ✭✭Smiley012


    Ok so it turns out that the decision box is working, I hadn't changed the names of the variables, I just need to get the Participant number box working, and I'm sorted!


  • Advertisement
  • Registered Users Posts: 683 ✭✭✭Gosh


    Had a look at page source and it's different to your post

    [HTML]
    <input type="text" name="DecisionSF1">
    [/HTML]your post says the fieldname is 'Decision'


Advertisement