Warning: Undefined variable: action in

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
metalhardscripts
Forum Newbie
Posts: 8
Joined: Thu May 22, 2003 8:29 pm
Location: Michigan
Contact:

Warning: Undefined variable: action in

Post by metalhardscripts »

Need some help with this tryed a few things and cant get it fixed maybe someone can help me with this heres the code error is on line 4 Warning: Undefined variable: action in D:\Webserver\www.everything.32k.org\topsite\sendpass.php on line 4
here it is

Code: Select all

<?php
include("design.php");
design_topp();
IF($action == "") &#123; 
print $lang&#1111;'forgot_pass'];
?>
<br>
<form name="form1" method="post" action="sendpass.php?action=send">
  <input type="text" name="email">
  <input type="submit" name="Submit" value="<?=$lang&#1111;'recive_pass']?>">
</form>
<?php
&#125;
elseif($action == "send") &#123;
$sql = "SELECT * FROM sites WHERE mail = '$email'";
$res = mysql_query($sql);
IF(mysql_num_rows($res) > 0) &#123;
$out = mysql_fetch_array($res);
mail($out&#1111;'mail'], $conf&#1111;'title'], $lang&#1111;'your_pass'] . " "" . $out&#1111;'pass'] . ""\n\n" . $conf&#1111;'title'], "From: " . $conf&#1111;'mail']);
print $lang&#1111;'pass_sent']; &#125;
elseIF(mysql_num_rows($res) < 1) &#123; print $lang&#1111;'no_mail']; &#125;
&#125;
design_bunn();
?>
there it is please helpppppppppp
User avatar
Sevengraff
Forum Contributor
Posts: 232
Joined: Thu Apr 25, 2002 9:34 pm
Location: California USA
Contact:

Post by Sevengraff »

im guessing $action was suppost to be defined in the URL?
put this before line 4:

Code: Select all

if(isset($_GET['action']) {
   $action = $_GET['action'];
} else {
   $action = 'default action value';
}
User avatar
metalhardscripts
Forum Newbie
Posts: 8
Joined: Thu May 22, 2003 8:29 pm
Location: Michigan
Contact:

even more errors

Post by metalhardscripts »

nope that didnt work at all just made so many errors it was unreal canstill need help with this tho if you want to see this script error right now the codes at top and heres the page running the script http://www.everything.32k.org/topsite/sendpass.php
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

which version of php do you use and what is register_globals set to?

Code: Select all

<?php phpinfo(); ?>
will tell you.
User avatar
metalhardscripts
Forum Newbie
Posts: 8
Joined: Thu May 22, 2003 8:29 pm
Location: Michigan
Contact:

php is

Post by metalhardscripts »

php is 4.1.1 and the register_globals on-on and i only have space on this server so i dont control any of these setting my webserver host does
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

then maybe it's simply
IF($action == "") {
you're trying to (read-)access a variable that might not exist, try

Code: Select all

if(empty($action)) {
or if $action might contain the (valid) value 0

Code: Select all

if (!isset($action) || $action=="") {
Post Reply