?action=something
Moderator: General Moderators
-
kakapeepee
- Forum Newbie
- Posts: 14
- Joined: Wed Oct 04, 2006 8:40 am
?action=something
how can i make something like
file.php?action=soemthing
something will sure be a function, but it is that ?action= that i donno how to do it
file.php?action=soemthing
something will sure be a function, but it is that ?action= that i donno how to do it
please start with http://www.php.net/manual/en/introduction.php
-
kakapeepee
- Forum Newbie
- Posts: 14
- Joined: Wed Oct 04, 2006 8:40 am
- n00b Saibot
- DevNet Resident
- Posts: 1452
- Joined: Fri Dec 24, 2004 2:59 am
- Location: Lucknow, UP, India
- Contact:
do you know about superglobals?
Code: Select all
echo $_GET['action'];You need to elaborate... what do you mean? How do you get the ?action=something in the url?
If so... there's a few ways...
If you mean how do you access that variable, use $_GET['action']
If so... there's a few ways...
Code: Select all
<form method="get" action="#">
<input type="hidden" name="action" value="something">
<input type="submit" value="Submit">
</form>Code: Select all
<a href="http://www.somesite.com?action=something">Click Here</a>
Last edited by Luke on Wed Oct 04, 2006 11:16 am, edited 1 time in total.
-
kakapeepee
- Forum Newbie
- Posts: 14
- Joined: Wed Oct 04, 2006 8:40 am
well yeah i know, actually this is a part of my code
im getting Undefined index: action
this is still under coding, but i stopped on that stage as u see, i wanna load that function submit() only when i click submit, for that reason i have created a hidden input called ACTION but it is sayin undefined :S
Code: Select all
global $_ENV, $_SERVER, $_POST;
echo "<html>
<head>
<title>Untitled Document</title>
</head>
<body>
<form name=\"decision\" method=\"post\" action=\"http://127.0.0.1/web/file.php\">
<input type=\"hidden\" name=\"action\" value=\"add\">
<input name=\"name\" type=\"text\">
<input name=\"lname\" type=\"text\">
<br />
<label title=\"choice\" >
yes <input name=\"choice\" type=\"radio\" value=\"yes\">
No <input name=\"choice\" type=\"radio\" value=\"yes\"></label>
<input type=\"submit\" value=\"submit\" />
</form>
".read()."
</body>
</html>";
if($_POST['action'] == "add")
{
$query = mysql_query("insert into m_record (name,lname,date,ip) values('$name','value2','value3','value4')");
}this is still under coding, but i stopped on that stage as u see, i wanna load that function submit() only when i click submit, for that reason i have created a hidden input called ACTION but it is sayin undefined :S
- n00b Saibot
- DevNet Resident
- Posts: 1452
- Joined: Fri Dec 24, 2004 2:59 am
- Location: Lucknow, UP, India
- Contact:
Code: Select all
if(isset($_POST['action']) && $_POST['action'] == "add")
$query = mysql_query("insert into m_record (name,lname,date,ip) values('$name','value2','value3','value4')");
also, you don't need to declare $_ENV, $_SERVER and $_POST global... they already are... in fact, they're Superglobals
-
kakapeepee
- Forum Newbie
- Posts: 14
- Joined: Wed Oct 04, 2006 8:40 am
thank you guys !! it is working
one more question
i have added the following below the query
but is is giving me Undifined variable:$result
why ?
one more question
i have added the following below the query
Code: Select all
if(!$query)
{
$result = "An error has occured";
}
else
{
$result = "Thanks...";
}why ?
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
-
kakapeepee
- Forum Newbie
- Posts: 14
- Joined: Wed Oct 04, 2006 8:40 am
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US