Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

php help please


mrdj204's Avatar
Member
0 0

$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?

ghost's Avatar
0 0

Change the "$_REQUEST['url']" to "$url = $_REQUEST['url']" and see if it works


ghost's Avatar
0 0

Ac1d wrote: two things that i can see wrong 1.u cant echo with quotes , a string.

  1. You SHould Always have a Value For Your Submit :P

Another case of Ac1d not understanding PHP

  1. You can echo with quotes
  2. 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)

mrdj204's Avatar
Member
0 0

thx for the help :)


ghost's Avatar
0 0

No problem

If you have any other questions feel free to PM me / contact me on MSN (check my profile)


mrdj204's Avatar
Member
0 0

im going to become your new best friend in that case :D


ghost's Avatar
0 0

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;))


mrdj204's Avatar
Member
0 0

double post


mrdj204's Avatar
Member
0 0

lol sure it wasnt


ghost's Avatar
0 0

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]


mrdj204's Avatar
Member
0 0

makes sense to me:D