php help please
$url = "";
$_REQUEST["url"];
if ($url="") {
$_REQUEST["url"];
echo "<a href=$url>Your Link</a>";
}else {
echo "
<form method=post>
<center>
Enter Url: <input type=text name=url>
<input type=submit>
</center>
</form>";
}
?>```
can someone tell me whats wrong?
Ac1d wrote: two things that i can see wrong 1.u cant echo with quotes , a string.
- You SHould Always have a Value For Your Submit :P
Another case of Ac1d not understanding PHP
- You can echo with quotes
- Why should you always have a value for submit?
$url = $_POST["url"];
if ( $url != "" )
{
echo "<a href=" . htmlentities($url) . ">Your Link</a>";
}
else
{
echo "
<form method=post>
<center>
Enter Url: <input type=text name=url>
<input type=submit VALUE=SUBMIT>
</center>
</form>";
}
?>```
Corrected code
1. If statement shouldn't have semi colon
2. $_REQUEST is considered a security flaw
3. If statements require a test of != or == or === which can return true or false NOT =. = just sets the variable *
4. You should never echo and unfiltered variable
*[edit] That was your error, fi statements can also be functions which evaluate true or false [/edit] - Thanks T-Metal for noticing that was badly written
mozzer
PS I hope that helped you more that Ac1d's garbage [edit]Please try and make sense next time - even if you're wrong[/edit]
(Nearly fluent my ass)
mozzer: I'd just like to point out that if statements do not only take those comparison operators as you stated, which I'm sure you realize, but could be potentially misleading for beginners.
Comparison operators such as !== and === are strict in the fact that it compares the value as well as the type. Refer to the PHP documentation for further information.
P.S. - As a side note, I'd like to state that I'd prefer if people, who don't know WTF they are talking about, would stay out of the thread rather than give bad and incompetent advice. (no, that was not aimed at you mozzer;))
T-Metal-Risen wrote: mozzer: I'd just like to point out that if statements do not only take those comparison operators as you stated, which I'm sure you realize, but could be potentially misleading for beginners.
I know that, I was saying why he was wrong, not all the different things. Within the if parenthesis there is a statement which can be evaluated "TRUE" or "FALSE" (I do also know these should be written in lower case)
[edit] I know what I said sounds like I don't understand but it made sense in my head [/edit]