Form problem :-\

I know there are lotsa form quesitons around, as well as tutes. But i wanted to do it my way (i’m doing html/php form btw), beceause there were some bits i didn’t understand in jubba’s html/php tute. I could also learn by my mistakes by doing everything myself…

ok so heres the code i have in my HTML page.


<body>
<form action="sendEmail.php" method="post" name="form1">
<input type="text" value="Entertexthere" name="input1"> 
<textarea cols=25 rows=8>Entertext here</textarea>
<input type="submit" value="submit" name="submit1">
</form>
</body>

ANd heres the code for my php page:


<?php
$Subject = "Mail form";
$toMail = "whatever@hotmail.com";
if (submit1) {
mail($toMail, $Subject, $input1)
}
?>

Look ok to you? well i get an error after i click the submit button which says theres an error on LINE 14 on my php page. And the only thing on line14 is:

}

Only a curly bracket :-\ Do any of you guys know whats wrong? thanks!!

FYI When you get an error on the last line of your code, that generally means that one of your if/for statements is not correct. By not correct I mean either missing a bracket or a parse error or something like that.

There is an error with your if statement. Can you figure it out?

Oh, and can you tell me what you didn’t understand about my tutorial? Just so I can fix it and make it clearer for people in the future. :slight_smile:

In your tute:
Mainly just this line:

mail($fromEmail, $Subject, $nMessage.“
From: “.$fromName.”<”.$fromEmail.">");

because there are so many extra dots everywhere :-\

And i had also tested it, and it didn’t work for some reason ??

Ok so back to my problem…

i’m guessing the problem is this line:

if (submit1) {

Maybe i am targetting something wrong? Most likely :stuck_out_tongue:

submit1 is a variable right? whats the syntax for variables in PHP?

and the . is just an operator to connect strings together :slight_smile:

Well submit1 is not actually a variable (i think)…I just thought it was appropriate because in my HTML page, you can see i named my submit button ‘submit1’. So i thought it would be correct to target the name of the submit button name.

ANd yea i just realized the . connects strings together after reading lower down in the posts :stuck_out_tongue:

its still a variable, so it still needs the $… so it should be

if($submit1)

and that should work. :slight_smile: It is correct to target the name, but its still a variable that PHP takes in and checks to see it its true… actually FYI if you do this:

print $submit1;

you should get the value that you define in your HTML, so in this case it will be:

submit

ahh it works. Yet again jubba saves the day :stuck_out_tongue: