You don't have permission to access /method="get" on this server.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dice
    New Member
    • Aug 2012
    • 1

    You don't have permission to access /method="get" on this server.

    Code:
    <html>
    <title> if-elseif</title>
    <body>
    <?php
    if (empty($_get["username"])){
    ?>
    <form action=<?php echo $_server["php_self"] ?>method="get">
    my name is :<input type=text name=username> <Br>
    i am:<br>
    <input type=radio name=sex value=1>man<br>
    <input type=radio name=sex value=2>woman<br>
    <input type=submit value="send out">
    <input type=reset value="refill">
    </form>
    <?php
    }
    else
    {
    if ($_get["sex"]==1)
    echo $_get["username"]."hi sir";
    elseif ($_get["sex"]==2)
    echo $_get["username"]."hi madam";
    else
    {
    echo "u haven't choose ur gender <br>";
    echo "plz rechoose <br>";
    }
    }
    ?>
    </body>
    </html>
    Last edited by Dormilich; Aug 13 '12, 09:52 AM. Reason: Please use [CODE] [/CODE] tags when posting code.
  • ariful alam
    New Member
    • Jan 2011
    • 185

    #2
    when i ran your code on WAMP, it shows me the following error:
    Code:
    Notice: Undefined variable: _server in C:\wamp\www\file.php on line 8 Call Stack #TimeMemoryFunctionLocation 10.0009140160{main}( )..\file.php:0
    but after changeing your
    Code:
    $_server['php_self']
    to
    Code:
    $_SERVER['PHP_SELF']
    , the error had gone.

    but no message shown.

    Comment

    • Dormilich
      Recognized Expert Expert
      • Aug 2008
      • 8694

      #3
      the same is true for $_get. PHP’s superglobals are always written uppercase.

      Comment

      • rampriya
        New Member
        • Aug 2012
        • 1

        #4
        Try the following. I think this is what you are actually looking for...

        Code:
        <?php
        if(isset($_GET["username"])){
        					if ($_GET["sex"]==1)
        						echo $_GET["username"]." hi sir";
        					elseif ($_GET["sex"]==2)
        						echo $_GET["username"]." hi madam";
        					else {
        						echo "u haven't chosen ur gender <br>";
        					}
        				} else{
        					//get the current page url
        					function curPageURL() {
        						$pageURL = 'http';
        						if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
        						$pageURL .= "://";
        						if ($_SERVER["SERVER_PORT"] != "80") {
        							$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
        						} else {
        							$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
        						}
        						return $pageURL;
        					}
        					$URI=curPageURL();
        					echo $URI;
        					?>
        					<form action=<?php echo $URI; ?> method="get">
        					my name is :<input type=text name=username> <Br>
        					i am:<br>
        					<input type=radio name=sex value=1>man<br>
        					<input type=radio name=sex value=2>woman<br>
        					<input type=submit value="send out">
        					<input type=reset value="refill">
        					</form>
        					<?php
        				}
        			?>

        Comment

        Working...