PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
if(!isset($_POST['submit']) {
if(!isset($_POST['name']) {
echo "Please put your name";
} elseif(!isset($_POST['title']) {
echo "Please post your title";
} elseif(!isset($_POST['article']) {
echo "Please post an article";
}
}
?>
<?php
// $a will be set to false or true depending on whether this post var is set
$a = (!isset($_POST['name']));
// $b will be set to false or true depending on whether this post var is set
$b = (!isset($_POST['title']));
// $c will be set to false or true depending on whether this post var is set
$c = (!isset($_POST['article']));
// The is invalid HTML. You need to wrap your attribute values in double quotes
$submit = "<input type=submit value=submit your article name=submit>";
if($a) {
echo "Please put your name";
} elseif($b) {
echo "Please post your title";
} elseif($c) {
echo "Please post an article";
} else {
echo $submit;
}
?>
Off topic, but...
you need to wrap your html attributes... especially when the value is more than one word... how is the browser supposed to parse this?
The Ninja Space Goat wrote:Off topic, but...
you need to wrap your html attributes... especially when the value is more than one word... how is the browser supposed to parse this?
The Ninja Space Goat wrote:Off topic, but...
you need to wrap your html attributes... especially when the value is more than one word... how is the browser supposed to parse this?
I need not learn about HTML double quotation. I knew that already, however, I thought within the PHP if I double quoted everything I would throw the script for a loop.
Secondly, this isn't off topic, its a PHP question with the validation. if I'm wrong I'll leave this site if it pleases those who are so cathartic. If the off topic was not to me, I appoligize.
but just to make sure I was right before I said it, you can indeed use this
<input type=submit value=submit your article name=submit>
and it will be parsed just fine. However, its poor syntax and the only reason it was how it was, was because of my misunderstadning, I was under the impression that as I said before, if I put that in the PHP variable it would throw it off, because of the multiple double quotes.
I guess I could of concactanatted it, but I didn't really think of it at the time.
akimm wrote:Secondly, this isn't off topic, its a PHP question with the validation. if I'm wrong I'll leave this site if it pleases those who are so cathartic. If the off topic was not to me, I appoligize.
I wasn't saying you were off topic. I was saying that correcting your HTML was off topic.
akimm wrote:I'm not trying to sound like a jerk
but just to make sure I was right before I said it, you can indeed use this
<input type=submit value=submit your article name=submit>
and it will be parsed just fine. However, its poor syntax and the only reason it was how it was, was because of my misunderstadning, I was under the impression that as I said before, if I put that in the PHP variable it would throw it off, because of the multiple double quotes.
I guess I could of concactanatted it, but I didn't really think of it at the time.
No you can't. It renders a button, but does it say "submit your article" nope. It says "submit"
afterwards you'll be directed to a page that outputs what you wrote, then go ahead and follow the link to my philosophy section and you'll see your content, Thereby proving the syntactically retarded code does indeed work.