473,385 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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

1
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <title> if-elseif</title>
  3. <body>
  4. <?php
  5. if (empty($_get["username"])){
  6. ?>
  7. <form action=<?php echo $_server["php_self"] ?>method="get">
  8. my name is :<input type=text name=username> <Br>
  9. i am:<br>
  10. <input type=radio name=sex value=1>man<br>
  11. <input type=radio name=sex value=2>woman<br>
  12. <input type=submit value="send out">
  13. <input type=reset value="refill">
  14. </form>
  15. <?php
  16. }
  17. else
  18. {
  19. if ($_get["sex"]==1)
  20. echo $_get["username"]."hi sir";
  21. elseif ($_get["sex"]==2)
  22. echo $_get["username"]."hi madam";
  23. else
  24. {
  25. echo "u haven't choose ur gender <br>";
  26. echo "plz rechoose <br>";
  27. }
  28. }
  29. ?>
  30. </body>
  31. </html>
Aug 11 '12 #1
3 3167
ariful alam
185 100+
when i ran your code on WAMP, it shows me the following error:
Expand|Select|Wrap|Line Numbers
  1. 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
Expand|Select|Wrap|Line Numbers
  1. $_server['php_self'] 
to
Expand|Select|Wrap|Line Numbers
  1. $_SERVER['PHP_SELF']
, the error had gone.

but no message shown.
Aug 11 '12 #2
Dormilich
8,658 Expert Mod 8TB
the same is true for $_get. PHP’s superglobals are always written uppercase.
Aug 13 '12 #3
Try the following. I think this is what you are actually looking for...

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. if(isset($_GET["username"])){
  3.                     if ($_GET["sex"]==1)
  4.                         echo $_GET["username"]." hi sir";
  5.                     elseif ($_GET["sex"]==2)
  6.                         echo $_GET["username"]." hi madam";
  7.                     else {
  8.                         echo "u haven't chosen ur gender <br>";
  9.                     }
  10.                 } else{
  11.                     //get the current page url
  12.                     function curPageURL() {
  13.                         $pageURL = 'http';
  14.                         if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
  15.                         $pageURL .= "://";
  16.                         if ($_SERVER["SERVER_PORT"] != "80") {
  17.                             $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
  18.                         } else {
  19.                             $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
  20.                         }
  21.                         return $pageURL;
  22.                     }
  23.                     $URI=curPageURL();
  24.                     echo $URI;
  25.                     ?>
  26.                     <form action=<?php echo $URI; ?> method="get">
  27.                     my name is :<input type=text name=username> <Br>
  28.                     i am:<br>
  29.                     <input type=radio name=sex value=1>man<br>
  30.                     <input type=radio name=sex value=2>woman<br>
  31.                     <input type=submit value="send out">
  32.                     <input type=reset value="refill">
  33.                     </form>
  34.                     <?php
  35.                 }
  36.             ?>
Aug 14 '12 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

16
by: Dave Opstad | last post by:
In this snippet: d = {'x': 1} value = d.get('x', bigscaryfunction()) the bigscaryfunction is always called, even though 'x' is a valid key. Is there a "short-circuit" version of get that...
11
by: Ohaya | last post by:
Hi, I'm trying to understand a situation where ASP seems to be "blocking" of "queuing" requests. This is on a Win2K Advanced Server, with IIS5. I've seen some posts (e.g.,...
7
by: Javaman59 | last post by:
This is probably common knowledge to .Net gurus, but please bear with me while I share a discovery with the group... I needed to create a public lock on a class, as follows... class Locked {...
3
by: Kathy Burke | last post by:
Hi. Totally lost on this one (ok, I admit I'm USUALLY lost!). All works fine in dev environment (P4, localhost server IIS, XP Pro) Asp.net and .Net 1.1 In order to access doc files needed for...
5
by: Tom Vogel | last post by:
Creating a subfolder within my ASP.NET application folder fails with the above error, but only at my hosting provider. The command: Directory.CreateDirectory(path) Path is set to...
4
by: SH | last post by:
I wish to create a program (really a Windows Service) that sits and waits for a client PC to communicate with it, but I can't come up with a good method of doing so. I want to have a service...
10
by: Pete | last post by:
I have the following code: <built-in method close of file object at 0xb7cc76e0> The file "temp.html" is created, but it doesn't look like the page at www.python.org. I'm guessing there are...
3
by: Frank Milverckowitz | last post by:
Hi, Newbie question about SqlDataReader column value access... In java jdbc code to get a value from a table column we can pass the column name (instead of an int index or offset): String...
8
by: ssecorp | last post by:
I first learned about OO from Java. I much prefer to program in Python though. However I am consufed about 2 things. 1. Why do I have to pass self into every method in a class? Since I am...
6
by: Luigi | last post by:
Dear all, I'm writing an XML-RPC server which should be able to modify the incoming request before dispatching it. In particular I wand to added two fixed parameters to the method called: one is...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.