
|
View Full Version : PHP Problem
Netunt 02-22-2009, 10:55 AM Not really suited to this forum but I guess you guys will know how to help so I'm asking it here.
This is the error:
Parse error: syntax error, unexpected T_IF in /home/username/public_html/sendmail.php on line 3
This is line 3:
if($submit) //If submit is hit{ mail("my@email.com", "$name", "$email", "$message");}?>
ThatScriptGuy 02-22-2009, 11:45 AM This really belongs in the programming forums.
And in order to diagnose your problem, we need to see the lines BEFORE line 3, as that is there the problem is. Most likely a missing ; or ) or } or ] in line 2.
This really belongs in the programming forums.
Isn't it? :angel: (moved)
FrankLaszlo 02-22-2009, 11:57 AM Why do you have a ; after the closing the PHP code? it should look something like this:
<?php
if($submit) //If submit is hit
{
mail("my@email.com", "$name", "$email", "$message");
}
?>
Netunt 02-22-2009, 12:29 PM This is the html (it's inside body, html tags ect)
<form method="post" action="sendmail.php"><fieldset>
Name:
<p>
<input type = "text" id = "name"/>
</p>
Email:
<p>
<input type = "text" id = "email"/>
</p>
Message:
<p>
<textarea type = "text"
rows = "10"
cols = "40"
id = "message" ></textarea>
</p>
<p>
<input type = "submit"
value = "Submit Message"/>
<input type = "reset" />
</p>
</feildset></form>
This is sendmail.php
<?php
if($submit) //If submit is hit
{
mail("contact@mydomain.com", "$name", "$email", "$message");
}
?>
FrankLaszlo 02-22-2009, 12:36 PM Did you get a different error after the changes I told you to do?
BTW, this is a very insecure script.
AH, and you're not processesing the variables correctly, you need to set $submit, $name, $email, and $message. Like this:
$submit = $_POST['submit'];
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$submit is really unneeded.. its not really a variable to be processed like that. when they click it, we already know its being submitted.
The input fields on the HTML arent defined correctly either. you need to replace 'id' with 'name' on all occurances. id is for styles and such.
Whats with the fieldset? I have no idea what you're trying to do with that.
Whats with the fieldset? I have no idea what you're trying to do with that.
Never going to work anyway:
<fieldset>
</feildset>
:P
Netunt 02-22-2009, 01:39 PM It had it in the book I own. :s
(it was misspelled in the book too?...) ;)
ie vs ei
Netunt 02-22-2009, 01:49 PM :blush: Erm... yeah... ;)
You got me there. Nope, I think I did it without glasses and without aptana sudio.
Notepad should come with spell checker.
Harzem 02-22-2009, 01:56 PM The script is relying on register_globals, which is very insecure.
If this PHP code is what your books tells you to use, then you have a big proglem with your book choices. In which year was it written?
Steve_Arm 02-22-2009, 02:07 PM </fieldset> is in the standards but no one uses it.
FrankLaszlo 02-22-2009, 02:20 PM Ya, must be a really old book.. Nobody uses fieldsets anymore as Steve said.
Netunt 02-22-2009, 05:02 PM Book is printed 2008.
Anyway. One last question. How exactly do I put it in the php file?
<?php
{
mail("name@domain.tld"
$submit = $_POST['submit'];
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
}
?>
I know that is wrong but no idea how it is meant to look. By insecure, does that mean I will be spammed or something more severe?
FrankLaszlo 02-22-2009, 05:53 PM The variable declaration should go before the mail statement. Leave the mail statement unaltered from how you had it before.
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
mail("contact@mydomain.com", "$name", "$email", "$message");
?>
And yes, insecure like you will get spammed.
sasha 02-22-2009, 06:39 PM </fieldset> is in the standards but no one uses it.
fieldset and legend are very cool tags. I see people using divs and spans to recreate functionality those builtin tags provide. Here is an example of nice use of those tags. Once you get used to them, they just make sense.
<form>
<fieldset>
<legend>Contact info</legend>
<ol>
<li><label for="name">Name</label><input id="name" name="name" /></li>
<li><label for="email">Email</label><input id="email" name="email" /></li>
</ol>
</fieldset>
<fieldset>
<legend>Second form segment</legend>
<ol>
<li><label for="field1">Field 1</label><input id="field1" name="field1" /></li>
<li><label for="field2">Field 2</label><input id="field2" name="field2" /></li>
</ol>
</fieldset>
</form>
Adam-AEC 02-22-2009, 07:59 PM fieldset and legend are very cool tags. I see people using divs and spans to recreate functionality those builtin tags provide. Here is an example of nice use of those tags. Once you get used to them, they just make sense.
No kidding. I guess nobody has to code according to WAI.
I'm in bed with fieldset and label had my children.
Netunt 02-22-2009, 08:03 PM It works :D
Thanks to all contributers of this thread.
sat-jokar 02-23-2009, 12:06 PM hello , I send you message , please contact me
thanks
|