phpnewbei Posted September 27, 2010 Share Posted September 27, 2010 Notice: Undefined index: uname in C:\wamp\www\project\members.php on line 26 Notice: Undefined index: uname in C:\wamp\www\project\members.php on line 39 Notice: Undefined index: changeinfo in C:\wamp\www\project\members.php on line 46 Here's the code: <html> <head> <style type="text/css" media="all"> @import url("style.css"); </style> </head> <body> <div id="header"> <h1><a href="index.php">ProjecTM</a></h1> </div> <div id="menu"> <ul> <a href="index.php">News</a> <a href="guestbook.php">Guestbook</a> <a href="changepassword.php">Change Password</a> <a href="logout.php">Log out</a> </ul> </div> <?php include("dbconnect.php"); session_start(); echo "<div id=\"homeform\">"; if(isset($_SESSION["username"])){ $link1 =' <a href="members.php?uname&changeinfo=' . $_SESSION["username"] . '"> Change information </a>'; Line 26 -> if($_SESSION["username"] == $_GET["uname"]){ echo "<h3>Here you can change private information, what you would like to show to other users and change account information!</h3>"; $uname = $_GET["uname"]; $sql = mysql_query("SELECT * FROM userinfo WHERE username='$uname'"); echo "<div id=\"loginform\">"; while($row = mysql_fetch_array($sql)){ echo "Förnamn: " . $row["firstname"] . "<br>"; echo "Efternamn: " . $row["lastname"]; } echo "</div>"; echo $link1; } else { Line 39 -> $hamta = $_GET["uname"]; $sql = mysql_query("SELECT * FROM userinfo WHERE username='$hamta'"); while($row = mysql_fetch_array($sql)){ echo ($row["firstname"]) . " "; echo ($row["lastname"]) . " "; } } Line 46 -> if ($_GET["changeinfo"] == $_SESSION["username"]){ echo "byt saker"; $hamta = $_GET["changeinfo"]; $sql = mysql_query("SELECT * FROM userinfo WHERE username='$hamta'"); if(isset($_GET["submit"])){ $update = "UPDATE userinfo SET firstname='$firstname' WHERE username=machram"; mysql_query($update); } while($row = mysql_fetch_array($sql)){ echo "<form method=\"get\" action=\"members.php?uname&changeinfo=\"" . $_SESSION["username"] . "&\">"; echo "Förnamn: "; echo "<input type=\"text\" name=\"firstname\" value=\"" . $row["firstname"] . "\">"; echo "<input type=\"submit\" name=\"submit\">"; } } } echo "</div>"; ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/214523-problems-with-update-and-undefined-index/ Share on other sites More sharing options...
rwwd Posted September 27, 2010 Share Posted September 27, 2010 Is the url set at all, as your assigning the $uname var from the $_GET which is URL, $_POST is from a form, ensure you have it correctly assigned. Rw Link to comment https://forums.phpfreaks.com/topic/214523-problems-with-update-and-undefined-index/#findComment-1116278 Share on other sites More sharing options...
phpnewbei Posted September 27, 2010 Author Share Posted September 27, 2010 Yeah it was set, but at sometimes it wasn't! But now I deleted almost everything to do a fresh start, I noticed I messed up every code I had haha Anyone know how you do a "Profile Page"? I want to do, if($_SESSION["username"] == $_GET["uname"]){ echo "Edit your information"; } else{ echo "Checking someone elses profile"; } Here's my code: <html> <head> <style type="text/css" media="all"> @import url("style.css"); </style> </head> <body> <div id="header"> <h1><a href="index.php">ProjecTM</a></h1> </div> <div id="menu"> <ul> <a href="index.php">News</a> <a href="guestbook.php">Guestbook</a> <a href="changepassword.php">Change Password</a> <a href="logout.php">Log out</a> </ul> </div> <?php include("dbconnect.php"); session_start(); echo "<div id=\"homeform\">"; if(isset($_SESSION["username"])){ $link1 =' <a href="members.php?uname&changeinfo=' . $_SESSION["username"] . '"> Change information </a>'; if($_SESSION["username"] == isset($_GET["uname"])){ echo "hello"; } elseif ($_SESSION["username"] != isset($_GET["uname"])) { echo "goodbye"; } } echo "</div>"; ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/214523-problems-with-update-and-undefined-index/#findComment-1116281 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.