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

Link to comment
Share on other sites

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

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.