Jump to content

[SOLVED] Need little bit help code is not correct


chrissie18

Recommended Posts

hello i have a code and it`s not correct getting:

Notice: Undefined index: dername

Notice: Undefined index: welcomet

in my php script can you help me out this is my code:

if(isset($logged['id'])) { 
if(isset($_GET['update'])) { 
$email = addslashes(htmlspecialchars($_POST[email])); 
$location = addslashes(htmlspecialchars($_POST[location])); 
$dername =  addslashes(htmlspecialchars($_POST[dername])); 
$welcomet = addslashes(htmlspecialchars($_POST[welcomet]));
//updates there profile in the db 
$update = mysql_query("UPDATE `members` SET `email` = '$email', `welcomet` = '$welcomet', `dername` = '$dername', `location` = '$location' WHERE `username` = '$logged[username]'"); 
echo "Profile updated!"; 
}
$getuser = mysql_query("SELECT * FROM `members` WHERE `username` = '$logged[username]'"); 
$user = mysql_fetch_array($getuser); 
echo "<form action='editprofile.php?update' method='post'> 
Email: <input type='text' name='email' size='30' maxlength='55' value='$user[email]'><br> 
Location: <input type='text' name='location' size='30' maxlength='40' value='$user[location]'><br> 
dealer naam: <input type='text' name='dername' size='30' maxlength='40' value='$user[dername]'><br> 
Welkom text: <input type='text' name='welcomet' size='90' maxlength='240' value='$user[welcomet]'><br> 
<input type='submit' value='Update'> 
</form>"; 

 

Thanx alot,

chris

You're testing to see if a value coming in from the URL is set. That does not guarantee that the $_POST array has been set. You should add a name to the the "submit" button and check whether that has been set.

 

<?php
if(isset($logged['id'])) { 
if(isset($_POST['submit'])) { 
$email = addslashes(htmlspecialchars($_POST['email'])); 
$location = addslashes(htmlspecialchars($_POST['location'])); 
$dername =  addslashes(htmlspecialchars($_POST['dername'])); 
$welcomet = addslashes(htmlspecialchars($_POST['welcomet']));
//updates there profile in the db 
$update = mysql_query("UPDATE `members` SET `email` = '$email', `welcomet` = '$welcomet', `dername` = '$dername', `location` = '$location' WHERE `username` = '$logged[username]'"); 
echo "Profile updated!"; 
}
$getuser = mysql_query("SELECT * FROM `members` WHERE `username` = '$logged[username]'"); 
$user = mysql_fetch_array($getuser); 
echo "<form action='editprofile.php?update' method='post'> 
Email: <input type='text' name='email' size='30' maxlength='55' value='$user[email]'><br> 
Location: <input type='text' name='location' size='30' maxlength='40' value='$user[location]'><br> 
dealer naam: <input type='text' name='dername' size='30' maxlength='40' value='$user[dername]'><br> 
Welkom text: <input type='text' name='welcomet' size='90' maxlength='240' value='$user[welcomet]'><br> 
<input type='submit' value='Update' name='submit'> 
</form>";
?>

 

Ken

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.