<?php
function printForm($strMessage){
echo "<strong>" .$strMessage."</strong>";
echo "<form method=\"post\" action=\"" .$_SERVER['PHP_SELF']. "\" name=\"form\">\n";
echo "First Name: <input type=\"text\" name=\"fname\" value=\"" trim($_POST['fname'])."\"
echo "Last Name: <input type=\"text\" name=\"lname\" value=\"" trim($_POST['lname'])."\"
echo "<input type=\submit\" value=\"send\" name=\"submit\"/>\n";
echo "</form>\n";
}
?>
<html>
<head>
<title>Self Submitting Sticky Form</title>
</head>
<body>
<?php
if(isset($_POST['submit'])){
$firstname=trim($_POST['fname']);
$lastname=trim($_POST['lname']);
if ($firstname==''){
$strMessage='Please enter your first name.';
printForm($strMessage);
}
elseif ($lastname==''){
$strMessage='Please enter your last name.';
printForm($strMessage);
}
else{
$strMessage='Thank you. your information was sent.';
echo $strMessage;
}
}
else{
$strMessage='Please enter all fields below:';
printForm($strMessage);
}
?>
</body>
</html>
10 Replies - 224 Views - Last Post: 11 February 2013 - 02:06 AM
#1
Can you Find my syntax error expecting ',' or ';' plea
Posted 10 February 2013 - 11:49 PM
This is driving me crazy trying to figure out what I am doing wrong with this form I am guessing something is not closing correctly but i have no clue what I have submitted my code below if anyone can please help!
Replies To: Can you Find my syntax error expecting ',' or ';' plea
#2
Re: Can you Find my syntax error expecting ',' or ';' plea
Posted 10 February 2013 - 11:52 PM
lines #5 and #6: concatenation between string and trim() missing, closing semi-colon missing.
This post has been edited by Dormilich: 10 February 2013 - 11:52 PM
#3
Re: Can you Find my syntax error expecting ',' or ';' plea
Posted 10 February 2013 - 11:54 PM
These lines (on top):
Do not end with an ;
Next time read the error, it usually contains a line number, simply look near the code at that line number and see what's wrong. 'Expecting ;' means the interpreter (PHP) expects an ;, which means you forgot one.
echo "First Name: <input type=\"text\" name=\"fname\" value=\"" trim($_POST['fname'])."\" 06 echo "Last Name: <input type=\"text\" name=\"lname\" value=\"" trim($_POST['lname'])."\"
Do not end with an ;
Next time read the error, it usually contains a line number, simply look near the code at that line number and see what's wrong. 'Expecting ;' means the interpreter (PHP) expects an ;, which means you forgot one.
This post has been edited by Dormilich: 10 February 2013 - 11:54 PM
#4
Re: Can you Find my syntax error expecting ',' or ';' plea
Posted 11 February 2013 - 12:59 AM
TheKirk, on 11 February 2013 - 01:54 AM, said:
These lines (on top):
Do not end with an ;
Next time read the error, it usually contains a line number, simply look near the code at that line number and see what's wrong. 'Expecting ;' means the interpreter (PHP) expects an ;, which means you forgot one.
echo "First Name: <input type=\"text\" name=\"fname\" value=\"" trim($_POST['fname'])."\" 06 echo "Last Name: <input type=\"text\" name=\"lname\" value=\"" trim($_POST['lname'])."\"
Do not end with an ;
Next time read the error, it usually contains a line number, simply look near the code at that line number and see what's wrong. 'Expecting ;' means the interpreter (PHP) expects an ;, which means you forgot one.
Its not that I know what it means but even with you close them like you are saying it will not work for some reason any other ideas
#5
Re: Can you Find my syntax error expecting ',' or ';' plea
Posted 11 February 2013 - 01:02 AM
see post #2
#6
Re: Can you Find my syntax error expecting ',' or ';' plea
Posted 11 February 2013 - 01:17 AM
Dormilich, on 11 February 2013 - 03:02 AM, said:
see post #2
Thank you for your help I was actually looking at you post but did not understand it exactly I understand the part about the closing semi colon but not the other part any way you could show me those two lines the way they should be thank you
#7
Re: Can you Find my syntax error expecting ',' or ';' plea
Posted 11 February 2013 - 01:40 AM
hm, how do you normally concatenate two strings?
#8
Re: Can you Find my syntax error expecting ',' or ';' plea
Posted 11 February 2013 - 01:43 AM
#9
Re: Can you Find my syntax error expecting ',' or ';' plea
Posted 11 February 2013 - 01:46 AM
since you need it to read anyways:
- string operators
- echo
hint: you’re already doing that in your code
- string operators
- echo
hint: you’re already doing that in your code
#10
Re: Can you Find my syntax error expecting ',' or ';' plea
Posted 11 February 2013 - 01:51 AM
Thanks for your help I'm reading the links but still not quite seeing what I am doing wrong although I am seeing it may have something to do with parentheses
#11
Re: Can you Find my syntax error expecting ',' or ';' plea
Posted 11 February 2013 - 02:06 AM
solved thanks for everyone's help
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote



|