Jump to content

Problems with UPDATE and undefined index


phpnewbei

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.